Created
May 22, 2014 05:32
-
-
Save negipo/c91d4f6153d2e45f56a1 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 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