Notion.so bypass-preview

(c) 2020 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)

  1. // ==UserScript==
  2. // @name Notion.so bypass-preview
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description (c) 2020 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
  6. // @author Adihd based on dragonwocky
  7. // @include https://www.notion.so/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function () {
  12. "use strict";
  13. document.addEventListener("readystatechange", (event) => {
  14. if (document.readyState !== "complete") return false;
  15. const attempt_interval = setInterval(enhance, 500);
  16. function enhance() {
  17. const notion_elem = document.querySelector(".notion-app-inner");
  18. if (!notion_elem) return;
  19. clearInterval(attempt_interval);
  20. const observer = new MutationObserver(handle);
  21. observer.observe(notion_elem, {
  22. childList: true,
  23. subtree: true,
  24. });
  25.  
  26. let pageHistory = [];
  27. handle();
  28. function handle(list, observer) {
  29. const pageID = (location.search
  30. .slice(1)
  31. .split("&")
  32. .map((opt) => opt.split("="))
  33. .find((opt) => opt[0] === "p") || [
  34. "",
  35. ...location.pathname.split(/(-|\/)/g).reverse(),
  36. ])[1],
  37. preview = document.querySelector(
  38. '.notion-peek-renderer [style*="height: 45px;"] a'
  39. );
  40. if (
  41. pageID &&
  42. (!pageHistory[0] ||
  43. pageHistory[0][0] !== pageID ||
  44. pageHistory[0][1] !== !!preview)
  45. ) {
  46. if (preview) {
  47. if (
  48. pageHistory[1] &&
  49. pageHistory[0][0] === pageID &&
  50. pageHistory[1][0] === pageID &&
  51. pageHistory[1][1]
  52. ) {
  53. document.querySelector(".notion-history-back-button").click();
  54. } else preview.click();
  55. }
  56. // most recent is at start for easier access
  57. pageHistory.unshift([pageID, !!preview]);
  58. }
  59. }
  60. }
  61. });
  62. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址