Last active
February 12, 2020 09:42
-
-
Save rgerganov/35382752557cb975354a to your computer and use it in GitHub Desktop.
Userscript for hiding CI comments in Gerrit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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