Gerrit checkbox resolved is always unchecked

Never automatically check "resolved", even on Done or Ack.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name            Gerrit checkbox resolved is always unchecked
// @description     Never automatically check "resolved", even on Done or Ack.
// @include         https://gerrit.example.com/c/*
// @version         1
// @run-at          document-start
// @namespace https://greasyfork.org/users/767392
// ==/UserScript==


function patchScript() {
    text = this.responseText
    text = text.replace(/n.unresolved=i/g, "n.unresolved=true");
  
    var newScript = document.createElement('script');
    newScript.type = "text/javascript";
    newScript.textContent = text;
    var body = document.getElementsByTagName('body')[0];
    body.appendChild(newScript);
}

window.addEventListener('beforescriptexecute',
  function(event)
  {
    var originalScript = event.target;

    if(/\/gr-app\.js$/.test(originalScript.src)) 
    { 
      var replacementScript = document.createElement('script');
      console.log('Greasemonkey is patching:', originalScript.src);

      originalScript.parentNode.replaceChild(replacementScript, originalScript);

      // prevent execution of the original script
      event.preventDefault();
      
      // load script and patch
      var oReq = new XMLHttpRequest();
      oReq.addEventListener("load", patchScript);
      oReq.open("GET", originalScript.src);
      oReq.send();
    }
  }
);