_Retaliate_ / Wuxiaworld QOL Script

// ==UserScript==
// @name         Wuxiaworld QOL Script
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Makes reading novels a bit easier
// @author       _Retaliate_
// @match        http://www.wuxiaworld.com/*-index/*/
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    document.onkeydown = checkKey;

function checkKey(e) {

    e = e || window.event;
    
    if (e.keyCode == '37') {
        var aTags = document.getElementsByTagName("a");
        var searchText = "Previous Chapter";
        var found;
        for (var i = 0; i < aTags.length; i++) {
            if (aTags[i].textContent == searchText) {
                found = aTags[i];
                break;
            }
        }
        window.location.href = found;
    }
    else if (e.keyCode == '39') {
        var aTags = document.getElementsByTagName("a");
        var searchText = "Next Chapter";
        var found;
        for (var i = 0; i < aTags.length; i++) {
            if (aTags[i].textContent == searchText) {
                found = aTags[i];
                break;
            }
        }
        window.location.href = found;
    }

}
})();