Skip to content

Instantly share code, notes, and snippets.

@Martoon-00
Last active November 12, 2018 18:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Martoon-00/9566df26317e2aecfa5af9f763662829 to your computer and use it in GitHub Desktop.
Save Martoon-00/9566df26317e2aecfa5af9f763662829 to your computer and use it in GitHub Desktop.
// ==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