Skip to content

Instantly share code, notes, and snippets.

Created August 30, 2008 15:40
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 anonymous/8121 to your computer and use it in GitHub Desktop.
Save anonymous/8121 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name pixiv random pickup pagerize
// @namespace http://zuu9xi.sa.yona.la/
// @description pagerize random pickup page of pixiv
// @include http://www.pixiv.net/random_pickup.php
// ==/UserScript==
window.addEventListener( "load", function () {
var page = 0
if (typeof window.AutoPagerize != "undefined") {
window.AutoPagerize.addDocumentFilter(
function () {
var html = arguments[0]
var info = arguments[2]
var nextAnchor = getElementsByXPath(info.nextLink, html)[0]
// add dummy query to href
// to avoid autopagerize checking url
// not to loading same url twice.
// dummy query will be simply ignored.
nextAnchor.href.replace(/\?paged=\d+$/, '')
nextAnchor.href += "?paged=" + page++
// alert(nextAnchor.href)
}
)
}
}, false)
// copied from autopagerize (http://userscripts.org/scripts/show/8551)
function getElementsByXPath(xpath, node) {
var node = node || document
var doc = node.ownerDocument ? node.ownerDocument : node
var nodesSnapshot = doc.evaluate(xpath, node, null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null)
var data = []
for (var i = 0; i < nodesSnapshot.snapshotLength; i++) {
data.push(nodesSnapshot.snapshotItem(i))
}
return data
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment