Notion Navigation Fixer

Allow browser nav options like back forward pgup pgdown

Від 05.06.2019. Дивіться остання версія.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension 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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Notion Navigation Fixer
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Allow browser nav options like back forward pgup pgdown
// @author       Andreas Huttenrauch
// @match        *://www.notion.so/*
// @run-at       document-end
// ==/UserScript==

console.log("fixing nav");

document.addEventListener('mousedown', function(e) {
    console.log(e);
    if ( (e.buttons & 8) == 8 ) {
        e.stopImmediatePropagation();
        e.preventDefault();
        window.history.back();
    }
    if ( (e.buttons & 16) == 16 ) {
        e.stopImmediatePropagation();
        e.preventDefault();
        window.history.forward();
    }
});

document.addEventListener('keydown', function(e) {
    console.log(e);
    /*
    if ( e.target.contentEditable ) {
        console.log("not moving because you are editing something important");
        return;
    }
    */
    var mainDiv = document.querySelector(".notion-frame .notion-scroller");
    if ( mainDiv == "undefined" ) return;
    var scrollAmt = parseInt(window.innerHeight*0.8);
    if ( e.keyCode == 34 && e.shiftKey == false && e.ctrlKey == false ) {
        e.stopImmediatePropagation();
        e.preventDefault();
        mainDiv.scrollBy(0, scrollAmt);
    }
    if ( e.keyCode == 33 && e.shiftKey == false && e.ctrlKey == false ) {
        e.stopImmediatePropagation();
        e.preventDefault();
        mainDiv.scrollBy(0, -scrollAmt);
    }
});