Last active
August 10, 2017 12:19
-
-
Save neongreen/022d496104456adb17b32d57cd4eb238 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 Youtrack highlight issues | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Highlight YT links | |
// @author Artyom | |
// @match https://github.com/* | |
// @grant none | |
// ==/UserScript== | |
// partly copied from https://gist.github.com/ampedandwired/8b62d7a5b7ca5e896615d782d7e279d0 | |
(function() { | |
'use strict'; | |
if (!NodeList.prototype.forEach) NodeList.prototype.forEach = Array.prototype.forEach; | |
if (!NodeList.prototype.indexOf) NodeList.prototype.indexOf = Array.prototype.indexOf; | |
var last = Date.now() - 2000; | |
function addYTLinks() { | |
// list of issues/PRs | |
var listPattern = /\s*(<a[^>]*>)\s*\[?(CSLA|CSLD|CSLTC|CSE|CSM|CSL|DAEF|DEVOPS|IMRF|LW|MT|SRK|SU|TW|VD)-?([0-9]{2,4})\]?/ig; | |
document.querySelectorAll('.js-issue-row .col-9').forEach(function(el) { | |
el.innerHTML = el.innerHTML.replace(listPattern, function(match, p1, p2, p3) { | |
return '<a class="h4 muted-link" href="https://issues.serokell.io/issue/' + | |
p2 + '-' + p3 + '">[' + p2 + '-' + p3 + ']</a>' + p1; | |
}); | |
}); | |
// issue headers | |
var titlePattern = /\s*(<span[^>]*>)\s*\[?(CSLA|CSLD|CSLTC|CSE|CSM|CSL|DAEF|DEVOPS|IMRF|LW|MT|SRK|SU|TW|VD)-?([0-9]{2,4})\]?/ig; | |
document.querySelectorAll('.gh-header-title').forEach(function(el) { | |
el.innerHTML = el.innerHTML.replace(titlePattern, function(match, p1, p2, p3) { | |
return p1 + '<a class="muted-link" href="https://issues.serokell.io/issue/' + | |
p2 + '-' + p3 + '">[' + p2 + '-' + p3 + ']</a>'; | |
}); | |
}); | |
} | |
function rerender() { | |
if (Date.now() - last > 1000) { | |
addYTLinks(); | |
last = Date.now(); | |
} | |
} | |
document.addEventListener('load', rerender, true); | |
window.setInterval(rerender, 100); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment