nodeBB remap shortcuts

remaps various nodeBB keyboard shortcuts to simple keypresses

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name                nodeBB remap shortcuts
// @namespace	        https://hoover.gplrank.de/
// @description	        remaps various nodeBB keyboard shortcuts to simple keypresses
// @description         author: hoover
// @description         You'll need to replace "hoover" with your forum username for the "chat" link to work below.
// @include             http*://forum.falcon-bms.com/*
// 
// @version 0.0.2.20211018140000
// ==/UserScript==

function findTopicLink()
{
    var anchors = document.getElementsByTagName('a');
    var href="/unread";
    for (var i = 0  ; i < anchors.length ; i++) {
       href = anchors[i].getAttribute('href');
       if (href) {
          if(href.match(/topic/)) {
              return(href);
             break ;

             }
          }
       }
}

var key_map = {
    "N" : "/unread",
    "R": "/recent",
    "P": "/popular",
    "H": "/",
    "C": "/user/hoover/chats",
    "S": "/search",
    "M": "/notifications",
    "G": findTopicLink()
    }

// stolen shamelessly from userscript.org's facebook key navigation
// Thanks to Droll Troll

function OnKeyUp(e)
{
  

    if (String.fromCharCode(e.keyCode) in key_map && 	
	(typeof e.target.type == "undefined" || (e.target.type != "text" && e.target.type != "textarea")) && 
	!e.altKey && !e.ctrlKey && e.keyCode <= 90)
    {
	window.location.replace(key_map[String.fromCharCode(e.keyCode)])
    }
}


window.addEventListener("keyup",function(event) { OnKeyUp(event); },false)