Created
May 4, 2014 07:57
-
-
Save quark-zju/7164223e523da8056a33 to your computer and use it in GitHub Desktop.
User script: Make Gerrit's "Change-Id" clickable from Phabricator Diffusion
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 PhabricatorGerritLink | |
// @namespace http://localhost | |
// @description Make Gerrit's "Change-Id" clickable from Phabricator Diffusion | |
// @include http://phabricator.localdomain/* | |
// @version 1 | |
// @grant none | |
// ==/UserScript== | |
var elements = document.getElementsByTagName('p'); | |
var GERRIT_CHANGE_LINK = "https://review.openstack.org/#q,$CHANGE_ID,n,z" | |
for (var i = 0; i < elements.length; ++i) { | |
var element = elements[i]; | |
var match = element.textContent.match(/Change-Id: ([A-Z0-9a-z]*)/m); | |
if (!match) continue; | |
var changeId = match[1]; | |
element.innerHTML = element.innerHTML.replace(changeId, ("<a href='" + GERRIT_CHANGE_LINK + "'>$CHANGE_ID</a>").replace(/\$CHANGE_ID/g, changeId)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment