Created
December 30, 2014 14:26
-
-
Save saveman71/4d03f882e49e425fb587 to your computer and use it in GitHub Desktop.
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 Compare Links on releases | |
// @version 0.1 | |
// @description Add links next to tags when there is no releases | |
// @author Antoine Bolvy <[email protected]> | |
// @match https://github.com/*/releases | |
// @grant none | |
// ==/UserScript== | |
var insertLinks = function() { | |
var elements = document.querySelectorAll('div.release-timeline a > span.tag-name, div.release-timeline a > span.css-truncate-target'); | |
for (var i = 0; elements[i]; i++) { | |
if(!elements[i + 1]) { | |
return; | |
} | |
var compare = elements[i + 1].textContent + '...' + elements[i].textContent; | |
var link = document.createElement("a"); | |
link.href = window.location.href.replace('releases', 'compare') + '/' + compare + '?a=a'; | |
link.innerHTML = 'Compare'; | |
link.style.cssFloat = "right" | |
link.target = "_blank"; | |
var insert = document.querySelector('div.release-timeline .tag-info h3 a[href$="' + elements[i].textContent + '"]'); | |
if(insert) { | |
insert.parentNode.appendChild(link); | |
} | |
} | |
}; | |
document.addEventListener('DOMContentLoaded', function() { | |
insertLinks(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment