Last active
August 29, 2015 14:14
-
-
Save CezaryDanielNowak/0b71c2b696f15005c69f to your computer and use it in GitHub Desktop.
JIRA LINKS in Github pull requests
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 Issue tracking (JIRA) links on github | |
// @namespace github | |
// @include https://github.com/* | |
// @version 1 | |
// @grant none | |
(function() { | |
var ISSUE_TRACKING_LINKS = { | |
"TPE": "https://tptest.atlassian.net/browse/", | |
"OVO": "https://jira.10clouds.com/browse/" | |
}; | |
var tmpTimeout; | |
var $ = document.querySelector.bind(document); | |
var addLinks = function() { | |
clearTimeout(tmpTimeout); | |
tmpTimeout = setTimeout(function() { | |
var header = $('.js-issue-title:not(.jira-link-inside)') // PR | |
|| $('.commit-title:not(.jira-link-inside)'); // Commit | |
if(header) { | |
for(var i in ISSUE_TRACKING_LINKS) { | |
header.innerHTML = header.innerHTML.replace(new RegExp('(' + i + ')-([0-9]*)'), '<a href="' + ISSUE_TRACKING_LINKS[i] + '$1-$2" target="_blank">$1-$2</a>'); | |
} | |
header.className += ' jira-link-inside'; | |
} | |
}, 100); | |
}; | |
document.addEventListener("DOMContentLoaded", function() { | |
document.body.addEventListener("DOMSubtreeModified", addLinks); | |
addLinks(); | |
}); | |
})(); | |
// ==/UserScript== |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment