Skip to content

Instantly share code, notes, and snippets.

@antimatter15
Created June 25, 2010 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save antimatter15/a828411054fe1de22be9 to your computer and use it in GitHub Desktop.
Save antimatter15/a828411054fe1de22be9 to your computer and use it in GitHub Desktop.
//==UserScript==
// @name Future
// @namespace http://antimatter15.com
// @description lets the future represent the next page
// @include http://*
// @include https://*
//==/UserScript==
var linkel = {}, links = [].slice.call(document.getElementsByTagName("a"),0)
.filter(function(e){return /^[0-9]+$/.test(e.innerText.replace(/\s /g,''))})
.map(function(e){var num=parseInt(e.innerText);linkel[num]=e;return num});
function next_page(){
var last = 0;
for(var i = 0; i < links.length; i++){
//likely layout: ascending 1,4,5,6,8,9,10,126
//measure change: 0,3,1,1,2,1,1 ,136
//get first =2: <,>,<,<,*,<,< ,>
if(links[i] - last == 2){
//current page: links[i] -1
//next page: links[i]
//next page link: linkel[links[i]].href
//alert(links[i] - 1);
window.location = linkel[links[i]].href;
break; //bah beh
}
last = links[i];
}
}
if(links.length > 0){
history.pushState('_xPageNav', 'Next Page');
history.go(-1);
window.onpopstate = function(e){
if(e.state == '_xPageNav')
next_page();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment