Last active
November 12, 2018 18:36
-
-
Save Martoon-00/9566df26317e2aecfa5af9f763662829 to your computer and use it in GitHub Desktop.
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 Serokell YouTrack link renderer for github pull requests. | |
// @namespace http://serokell/io | |
// @version 1.0 | |
// @description Turns Serokell YT ticket id in PR's name into a link. | |
// @author Martoon | |
// @match https://github.com/*/pull* | |
// @grant none | |
// ==/UserScript== | |
function applyYt4Github() { | |
'use strict'; | |
var logName = "yt4github: " | |
var titleElem = document.getElementsByClassName("js-issue-title")[0] | |
if (titleElem == undefined) { | |
return; | |
} | |
var title = titleElem.innerHTML.trim() | |
if (title.charAt(0) != '['){ | |
return; | |
} | |
var splitTitle = title.split("]", 2) | |
var ticket=splitTitle[0].split("[", 2)[1] | |
var bareTitle=splitTitle[1].trim() | |
titleElem.innerHTML = '<a href="https://issues.serokell.io/issue/' + ticket + '" target="_blank">[' + ticket + ']</a> ' + bareTitle | |
}; | |
// Thanks to AJAX, we cannot perform the action once. | |
setInterval(applyYt4Github, 500) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment