Skip to content

Instantly share code, notes, and snippets.

@rgerganov
Last active February 12, 2020 09:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rgerganov/35382752557cb975354a to your computer and use it in GitHub Desktop.
Save rgerganov/35382752557cb975354a to your computer and use it in GitHub Desktop.
Userscript for hiding CI comments in Gerrit
// ==UserScript==
// @name Toggle CI comments in patches
// @author Radoslav Gerganov <rgerganov@vmware.com>
// @include https://review.openstack.org/#/c/*
// ==/UserScript==
function main() {
// these are CIs for Nova, feel free to modify this list
var ciNames = ["Jenkins",
"turbo-hipster",
"Hyper-V CI",
"IBM PowerKVM Testing",
"VMware Mine Sweeper",
"Elastic Recheck",
"XenServer CI",
];
var input = document.createElement("input");
input.type = "button";
input.className = "gwt-Button";
input.value = "Toggle CI";
input.onclick = function() {
// CI comments in New Screen
jQ("div").filter(function() {
return jQ.inArray(this.innerHTML, ciNames) >= 0;
}).parent().parent().parent().toggle();
// CI comments in Old Screen
jQ("div").filter(function() {
return jQ.inArray(this.getAttribute('name'), ciNames) >= 0;
}).toggle();
}
document.body.appendChild(input);
};
function addJQuery(callback) {
var script = document.createElement("script");
script.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js");
script.addEventListener('load', function() {
var script = document.createElement("script");
script.textContent = "window.jQ=jQuery.noConflict(true);(" + callback.toString() + ")();";
document.body.appendChild(script);
}, false);
document.body.appendChild(script);
}
addJQuery(main);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment