Created
October 10, 2012 07:03
-
-
Save philwebb/3863611 to your computer and use it in GitHub Desktop.
Greasemonkey GitHub JIRA
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 github-jira | |
// @namespace http://springsource.org | |
// @description GitHub JIRA integration | |
// @include http://github.com/SpringSource/* | |
// @include https://github.com/SpringSource/* | |
// @include http://github.com/*/spring-* | |
// @include https://github.com/*/spring-* | |
// @version 1 | |
// @grant none | |
// ==/UserScript== | |
textNodes = document.evaluate("//*[not(self::a)]/text()", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); | |
var searchRE = new RegExp('([A-Z]{3,}\-[0-9]{3,})','g'); | |
var jiraReplacementDiv = document.createElement('div'); | |
for (var i=0;i<textNodes.snapshotLength;i++) { | |
var node = textNodes.snapshotItem(i); | |
if(searchRE.test(node.data)) { | |
jiraReplacementDiv.innerHTML = node.data.replace(searchRE, "<a href=\"https://jira.springsource.org/browse/$1\">$1</a>"); | |
while (jiraReplacementDiv.firstChild) { | |
node.parentNode.insertBefore(jiraReplacementDiv.firstChild, node); | |
} | |
node.parentNode.removeChild(node); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment