Last active
August 22, 2020 04:07
-
-
Save hkamran80/b78ba189f0319efccaa534952f66ceb0 to your computer and use it in GitHub Desktop.
FanFiction.net - Keystrokes
This file contains 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 FanFiction.net - Keystrokes | |
// @namespace https://hkamran.com | |
// @version 1.0.4 | |
// @description Keystrokes for FanFiction.net | |
// @author H. Kamran | |
// @downloadUrl https://gist.github.com/hkamran80/b78ba189f0319efccaa534952f66ceb0/raw/fanfiction.user.js | |
// @updateUrl https://gist.github.com/hkamran80/b78ba189f0319efccaa534952f66ceb0/raw/fanfiction.user.js | |
// @match https://www.fanfiction.net/s/* | |
// @grant none | |
// ==/UserScript== | |
function pagination(e) { | |
var evtobj = window.event? event : e | |
if (evtobj.keyCode == 78 && evtobj.shiftKey) { | |
// Next Page Keystroke (Shift + N) | |
const next_button_element = document.evaluate("//button[contains(text(),'Next >')]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; | |
window.location.href = window.location.protocol + "//" + window.location.host + next_button_element.getAttribute("onclick").replace("self.location=", "").replace("'", "").replace("'", ""); | |
} else if (evtobj.keyCode == 80 && evtobj.shiftKey) { | |
// Previous Page Keystroke (Shift + P) | |
const prev_button_element = document.evaluate("//button[contains(text(),'< Prev')]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; | |
window.location.href = window.location.protocol + "//" + window.location.host + prev_button_element.getAttribute("onclick").replace("self.location=", "").replace("'", "").replace("'", ""); | |
} else if (evtobj.keyCode == 76 && evtobj.shiftKey) { | |
// Follow/Favorite Keystroke (Shift + L) | |
const follow_fav_button_element = document.evaluate("//button[contains(text(),'Follow/Fav')]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; | |
follow_fav_button_element.click(); | |
} | |
} | |
document.onkeydown = pagination; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment