Skip to content

Instantly share code, notes, and snippets.

@davidcoallier
Created February 9, 2010 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidcoallier/299519 to your computer and use it in GitHub Desktop.
Save davidcoallier/299519 to your computer and use it in GitHub Desktop.
// ==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('&laquo; Previous CS');
var space = $('<span>');
space.css({width: '30px;'});
space.html('&nbsp;&nbsp;');
var a2 = $('<a>');
a2.attr('href', nextCs);
a2.html('Next CS&raquo;');
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