Notion.so bypass-preview

(c) 2020 dragonwocky <[email protected]> (https://dragonwocky.me/)

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Notion.so bypass-preview
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  (c) 2020 dragonwocky <[email protected]> (https://dragonwocky.me/)
// @author       Adihd based on dragonwocky
// @include      https://www.notion.so/*
// @grant        none
// ==/UserScript==

(function () {
  "use strict";
  document.addEventListener("readystatechange", (event) => {
    if (document.readyState !== "complete") return false;
    const attempt_interval = setInterval(enhance, 500);
    function enhance() {
      const notion_elem = document.querySelector(".notion-app-inner");
      if (!notion_elem) return;
      clearInterval(attempt_interval);
      const observer = new MutationObserver(handle);
      observer.observe(notion_elem, {
        childList: true,
        subtree: true,
      });

      let pageHistory = [];
      handle();
      function handle(list, observer) {
        const pageID = (location.search
            .slice(1)
            .split("&")
            .map((opt) => opt.split("="))
            .find((opt) => opt[0] === "p") || [
            "",
            ...location.pathname.split(/(-|\/)/g).reverse(),
          ])[1],
          preview = document.querySelector(
            '.notion-peek-renderer [style*="height: 45px;"] a'
          );
        if (
          pageID &&
          (!pageHistory[0] ||
            pageHistory[0][0] !== pageID ||
            pageHistory[0][1] !== !!preview)
        ) {
          if (preview) {
            if (
              pageHistory[1] &&
              pageHistory[0][0] === pageID &&
              pageHistory[1][0] === pageID &&
              pageHistory[1][1]
            ) {
              document.querySelector(".notion-history-back-button").click();
            } else preview.click();
          }
          // most recent is at start for easier access
          pageHistory.unshift([pageID, !!preview]);
        }
      }
    }
  });
})();