Created
February 9, 2010 18:55
-
-
Save davidcoallier/299519 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 Assembla Changeset Navigator | |
// @namespace echolibre | |
// @description In assembla, navigate to previous and next changeset | |
// @include https://code.assembla.com/* | |
// @date 2009-03-02 | |
// @version 1.0 | |
// ==/UserScript== | |
var GM_JQ = document.createElement('script'); | |
GM_JQ.src = 'http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js'; | |
GM_JQ.type = 'text/javascript'; | |
document.getElementsByTagName('head')[0].appendChild(GM_JQ); | |
// Check if jQuery's loaded | |
function GM_wait() { | |
if (typeof unsafeWindow.jQuery == 'undefined') { | |
window.setTimeout(GM_wait,100); | |
} else { | |
$ = unsafeWindow.jQuery; getCurrentCs(); | |
} | |
} | |
GM_wait(); | |
function getCurrentCs() | |
{ | |
var elm = $('.changeset h1').html(); | |
if (elm != null) { | |
var cs = (elm.replace(/<\/?[^>]+(>|$)/g, "")); | |
var csNumber = cs.replace(/Changeset /g, ''); | |
var currentCs = parseInt(csNumber); | |
addTableRow(currentCs); | |
} | |
} | |
function addTableRow(currentCs) | |
{ | |
var previousCs = currentCs - 1; | |
var nextCs = currentCs + 1; | |
var tr = $('<tr>'); | |
var th = $('<th>'); | |
th.html('Navigate'); | |
var td = $('<td>'); | |
td.attr('colspan', '6'); | |
var a1 = $('<a>'); | |
a1.attr('href', previousCs); | |
a1.html('« Previous CS'); | |
var space = $('<span>'); | |
space.css({width: '30px;'}); | |
space.html(' '); | |
var a2 = $('<a>'); | |
a2.attr('href', nextCs); | |
a2.html('Next CS»'); | |
td.append(a1).append(space).append(a2); | |
tr.append(th).append(td); | |
var table = tr.appendTo('.changeset .internal-navigation table'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment