Skip to content

Instantly share code, notes, and snippets.

@lyricallogical
Created January 17, 2013 21:52
Show Gist options
  • Save lyricallogical/4560143 to your computer and use it in GitHub Desktop.
Save lyricallogical/4560143 to your computer and use it in GitHub Desktop.
github の scala リポジトリのコミットタイトルやメッセージ内の JIRA の Issue 番号にリンクをつけるだけの chrome 向け user script firefox でも動くかもしれない
// ==UserScript==
// @name add link to jira
// @description replace SI-NNNN with link to correspond issue page.
// @version 0.1
// @match https://github.com/scala/scala/commit/*
// @match https://github.com/scala/scala/commits/*
// ==/UserScript==
(function() {
var each = Array.prototype.forEach
var url = 'https://issues.scala-lang.org/browse/';
var doms = document.querySelectorAll(".commit-title, .commit-desc > pre")
each.call(doms, function(dom) {
var html = "";
each.call(dom.childNodes, function(child) {
if (child.nodeType != 3) {
html += new XMLSerializer().serializeToString(child);
} else {
html += child.nodeValue.replace(/SI\-\d+/g, '<a href="' + url + '$&" target="_blank">$&</a>');
}
});
dom.innerHTML = html;
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment