Skip to content

Instantly share code, notes, and snippets.

@neetij
Created July 25, 2014 17:11
Show Gist options
  • Save neetij/04d21ef88710814011d8 to your computer and use it in GitHub Desktop.
Save neetij/04d21ef88710814011d8 to your computer and use it in GitHub Desktop.
Trigger portfolio links for http://greaterthanorequalto.net/ by @alantrotter
// ==UserScript==
// @name Tweaks for greaterthanorequalto.net
// @namespace http://github.com/neetij
// @version 0.1
// @description Triggers the portfolio links.
// @match http://greaterthanorequalto.net/*
// @copyright 2014+, Neetij
// ==/UserScript==
/* Hastily put together, but functional. Fork and improve.*/
/* must have: trigger the clicks one at a time */
var speed = 2000; /* 2s */
function triggerClicks(linkslength) {
links = $('a:visible:not(.outer):not(.clicked)');
linkslength = links.size();
if (linkslength == 0) {
clearInterval(clickTimer);
clickTimer = false;
} else {
for(j=0; j<1; j++) {
links.eq(j).click();
}
}
}
var clickTimer = setInterval(triggerClicks, speed);
/* nice to have: controls to play, pause and adjust speed */
var css = '.controls {font:0.75em sans-serif; background:#f2f2f2; line-height:1.4; padding:0.5em; position:fixed; bottom:0.5em; right:0.5em; cursor:default; text-align:right;} .controls span {padding:0.5em; display:block;} .control{color:#009; cursor:pointer;}';
var control = '<div class="controls"><span class="control play">PAUSE</span><span class="speed">SPEED: 2s</span><span class="control speedup">FASTER</span><span class="control slowdown">SLOWER</span></div>';
GM_addStyle(css);
$('body').append(control);
$('.play').on('click', function() {
if (clickTimer) {
clearInterval(clickTimer);
clickTimer = false;
$(this).html('PLAY');
} else {
clickTimer = setInterval(triggerClicks, speed);
$(this).html('PAUSE');
}
});
$('.speedup').on('click', function() {
speed = speed - 200;
updateSpeed();
});
$('.slowdown').on('click', function() {
speed = speed + 200;
updateSpeed();
});
function updateSpeed() {
$('.speed').html('SPEED: ' + speed/1000 + 's');
if (clickTimer) {
clearInterval(clickTimer);
clickTimer = setInterval(triggerClicks, speed);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment