NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @namespace https://openuserjs.org/users/ldeflandre // @name Jenkins: Hide replay link // @description Hide confusing /replay link that is named Rebuild like the legit /rebuild link // @version 0.2 // @grant none // @include https://jenkins* // @license MIT // ==/UserScript== // ==OpenUserJS== // @author ldeflandre // ==/OpenUserJS== function xpath(context, expression) { const result = []; var i = document.evaluate(expression, context, null, XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null); if (!i) throw new Error("Invalid query: " + expression); var data; while (data = i.iterateNext()) { result.push(data); } return result; } console.log("Hiding replay link"); // Add hide class to style sheet var sheet = document.createElement('style') sheet.innerHTML = ".hide { display:none ; }"; document.body.appendChild(sheet); // Filter static side menu var nodes = xpath(document.getElementById("tasks"), './div/span/a[contains(@href,"/replay")]/../..'); nodes.forEach(function (node) { node.classList.add("hide"); return true; }); // Filter dynamically added drop-down menus var callback = function (mutations) { mutations.forEach(function (mutation) { mutation.addedNodes.forEach(function (node) { nodes = xpath(node, './div/ul/li/a[contains(@href,"/replay")]/..'); nodes.forEach(function (node) { node.classList.add("hide"); return true; }); return true; }) }) }; var observer = new MutationObserver(callback); observer.observe(document.getElementById("breadcrumb-menu-target"), { childList: true });