Skip to content

Instantly share code, notes, and snippets.

@negipo
Created May 7, 2010 05:44
Show Gist options
  • Save negipo/393108 to your computer and use it in GitHub Desktop.
Save negipo/393108 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name WikipediaRandomAutoPager
// @namespace http://polog.org/
// @include http://*.wikipedia.org/wiki/*
// @require http://gist.github.com/3242.txt
// ==/UserScript==
// requires AutoPagerize http://userscripts.org/scripts/show/8551 by swdyh
// using utility $X() http://gist.github.com/3242 by os0x
// notice: put this script ABOVE AutoPagerize
function randomPagerFilter(doc, url, info){
var content_element = $X('id("content")', doc)[0];
var links = $X('descendant-or-self::a[contains(@href, "/wiki/")]', content_element);
if(links.length < 1) return;
content_element.className = 'autopagerize_page_element';
links[Math.floor(Math.random() * links.length)].rel = "next";
}
randomPagerFilter(document, '', '');
setTimeout(function(){window.AutoPagerize.addDocumentFilter(randomPagerFilter)},10);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment