AutoHotKey script that toggles between arXiv abstract page and PDF. This script only supports Chrome for security (you won't want it to ruin other applications with possibly conflicting key bindings), but it's trivial to change.
/*
Under context of Chrome browser, and if the URL starts with "https://arxiv.org/":
"Windows + Alt + P" - Go to PDF is in abstract page, and go to abstract page if in PDF
(will not overwrite clipboard)
*/
#IfWinActive ahk_exe chrome.exe
#!p::
Send ^l
Sleep, 100
oldClipboard := Clipboard
Send ^c
Sleep, 200
if (RegExMatch(Clipboard, "^https:\/\/arxiv\.org\/") != 0)
{
if (RegExMatch(Clipboard, "O)^https:\/\/arxiv\.org\/pdf\/(\d+\.\d+(v\d+)?)\.pdf$", match) != 0)
{
arxivId := match.Value(1)
toUrl := "https://arxiv.org/abs/" . arxivId
Send % toUrl . "{Enter}"
}
else if (RegExMatch(Clipboard, "O)^https:\/\/arxiv\.org\/abs\/(\d+\.\d+(v\d+)?)$", match) != 0)
{
arxivId := match.Value(1)
toUrl := "https://arxiv.org/pdf/" . arxivId . ".pdf"
Send % toUrl . "{Enter}"
}
else
{
MsgBox % "Unrecognizable URL: " . Clipboard
Send, {Esc}
}
}
else
{
MsgBox, "#!p shortcut only functions under arXiv pages"
Send, {Esc}
}
Clipboard := oldClipboard
Return
#IfWinActive