Skip to content

Instantly share code, notes, and snippets.

@tmplinshi
Created October 14, 2019 07:29
Show Gist options
  • Save tmplinshi/3c88f308667659bf6350d7a35967a634 to your computer and use it in GitHub Desktop.
Save tmplinshi/3c88f308667659bf6350d7a35967a634 to your computer and use it in GitHub Desktop.
; https://www.autohotkey.com/boards/viewtopic.php?f=28&t=61347
; F8::pageNav("pre") ; 上一页
; F9::pageNav("next") ; 下一页
pageNav(cmd = "next") {
static js
if (!js)
{
js =
(LTrim Join`s
function pageNav(cmd = "next") {
var r = (cmd=="next") ? "(下|后)" : "(上|前)";
var Re = new RegExp(r + "(一|\s)*(页|頁|章|篇|翻)", "i");
var a = document.getElementsByTagName("A");
for (var i=0; i<a.length; i++) {
if (Re.test(a[i].innerHTML)) {
if (a[i].href.substr(0,11).toLowerCase() == "javascript:")
a[i].click();
else
document.location.href = a[i].href;
break;
}
}
}
)
}
clipBackup := ClipboardAll
Send {Alt Down}d{Alt Up}
Sleep, 50
Clipboard := ".javascript:" . js . ";pageNav('" cmd "');"
SendInput {Ctrl Down}v{Ctrl Up}{Home}{Del}{Enter}
Sleep, 100
Clipboard := clipBackup
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment