Last active
April 20, 2022 06:33
-
-
Save ioma8/68fa4a7bc089d50e33dedf90a76a09e7 to your computer and use it in GitHub Desktop.
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 Open GitLab links in new tab | |
// @namespace https://github.com/ioma8 | |
// @version 1.0 | |
// @description Open GitLab links in new tab | |
// @author ioma8 | |
// @match *://gitlab/* | |
// @grant none | |
// @license MIT | |
// ==/UserScript== | |
(function () { | |
'use strict'; | |
function modifyLinks(selectors) { | |
try { | |
var nodes = document.querySelectorAll(selectors); | |
for (var m = 0; m < nodes.length; m++) { | |
var links = nodes[m].getElementsByTagName('a'); | |
for (var n = 0; n < links.length; n++) { | |
links[n].target = '_blank'; | |
} | |
} | |
} catch (err) { | |
console.error('[tampermonkey-gitlab-newtab] error: ' + err.toString()) | |
} | |
} | |
function checkBody() { | |
modifyLinks('.note-body'); | |
modifyLinks('.detail-page-description'); | |
} | |
setInterval(checkBody, 1000); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment