Last active
July 23, 2017 20:07
-
-
Save tstrachota/012d1518a08d5a9d441f 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 Foreman redmine issue links at GitHub | |
// @namespace https://github.com/ | |
// @include https://*github.com/* | |
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js | |
// @version 1.2 | |
// @grant none | |
// ==/UserScript== | |
(function($) { | |
function replace_issue_links(text) { | |
return text | |
.replace(/#([0-9]{4,6})/g, '<a style="color: #4183C4;" href="http://projects.theforeman.org/issues/$1/">#$1</a>') | |
.replace(/BZ([0-9]{7,8})/g, '<a style="color: #4183C4;" href="https://bugzilla.redhat.com/show_bug.cgi?id=$1">BZ$1</a>'); | |
} | |
function replace_issue_links_for(selector) { | |
$(selector).each(function(){ | |
$(this).html(replace_issue_links($(this).text())); | |
}); | |
} | |
function monkey_github_page() { | |
replace_issue_links_for('.gh-header-title .js-issue-title'); | |
replace_issue_links_for('.commit-title'); | |
} | |
$(document).ready(monkey_github_page); | |
$(window).bind('pjax:end', monkey_github_page); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment