====== Go next/previous page ======
===== Description =====
Finds and follows the next/previous link on the page. This is very useful for navigating search results.
===== JavaScript =====
==== Next Page ====
(function() {
var el = document.querySelector("[rel='next']");
if (el) { // Wow a developer that knows what he's doing!
location = el.href;
}
else { // Search from the bottom of the page up for a next link.
var els = document.getElementsByTagName("a");
var i = els.length;
while ((el = els[--i])) {
if (el.text.search(/\bnext\b|\bmore[\.…]*$|[>»]$/i) > -1) {
location = el.href;
break;
}
}
}
})();
==== Previous Page ====
(function() {
var el = document.querySelector("[rel='prev']");
if (el) {
location = el.href;
}
else {
var els = document.getElementsByTagName("a");
var i = els.length;
while ((el = els[--i])) {
if (el.text.search(/\bprev|^[<«]/i) > -1) {
location = el.href;
break;
}
}
}
})();
==== Installation ====
Save the above scripts to a directory of your choice and add binds to them for example:
# Follow to next page
@bind ]] = script @scripts_dir/go_next_page.js
# Follow to previous page
@bind [[ = script @scripts_dir/go_prev_page.js