Created
April 7, 2025 22:28
-
-
Save Gabrielcarvfer/81f1b5a6c7a220845b1321881dd02568 to your computer and use it in GitHub Desktop.
Disable new GitLab issue drawer link hijacking
This file contains hidden or 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 Disable GitLab issues drawer | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Disable GitLab issues drawer | |
// @author Gabriel Ferreira | |
// @match https://gitlab.com/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=gitlab.com | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
// Nuke every event listener that hijacks links in the new issues board... | |
const observer = new MutationObserver((mutations, obs) => { | |
const links = document.getElementsByClassName('gl-link'); | |
if (links.length > 0) { | |
obs.disconnect(); | |
document.body.addEventListener('click', (e) => { | |
const classes = [...e.srcElement.classList, ...e.srcElement.parentElement.classList, ...e.srcElement.parentElement.parentElement.classList]; | |
if(classes.some(test_class => test_class.includes("issue-title"))) | |
{ | |
e.stopPropagation(); // prevents bubbling up | |
e.stopImmediatePropagation(); // blocks other handlers on same element | |
} | |
}, true); | |
obs.observe(document.body, { | |
childList: true, | |
subtree: true, | |
}); | |
} | |
}); | |
const url = window.location.pathname; | |
if (/\/issues(?:\/|-\/|\/?$)(?!\d)/.test(url)) { | |
observer.observe(document.body, { | |
childList: true, | |
subtree: true, | |
}); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment