Notion Fix

Fix bugs in Notion

  1. // ==UserScript==
  2. // @name Notion Fix
  3. // @namespace https://github.com/alanleungcn/notion-fix
  4. // @version 1.3
  5. // @author Alan Leung
  6. // @description Fix bugs in Notion
  7. // @match https://www.notion.so/*
  8. // @license MIT
  9. // ==/UserScript==
  10.  
  11. (function () {
  12. 'use strict';
  13.  
  14. let preView = null;
  15. let curView = null;
  16. const checkInterval = 100;
  17. const viewList = [
  18. 'table',
  19. 'board',
  20. 'timeline',
  21. 'calendar',
  22. 'gallery',
  23. 'list',
  24. ];
  25.  
  26. const init = setInterval(() => {
  27. queryView();
  28. if (curView) {
  29. clearInterval(init);
  30. applyFix();
  31. fixFirefoxScrollbarWidth();
  32. }
  33. }, checkInterval);
  34.  
  35. window.addEventListener('click', () => {
  36. applyFix();
  37. });
  38.  
  39. // function fixTimelineDividerPosition() {
  40. // document.querySelector('.pseudoSelection').style.position = '';
  41. // }
  42.  
  43. function fixScrollbarPosition() {
  44. document.querySelector(
  45. '.notion-scroller.vertical.horizontal'
  46. ).scrollLeft = 0;
  47. }
  48.  
  49. function fixFirefoxScrollbarWidth() {
  50. const style = document.createElement('style');
  51. style.textContent = `.notion-scroller { scrollbar-width: thin }`;
  52. document.head.append(style);
  53. }
  54.  
  55. function queryView() {
  56. viewList.forEach((view, i) => {
  57. if (document.querySelector(`.notion-${view}-view`)) {
  58. curView = viewList[i];
  59. }
  60. });
  61. }
  62.  
  63. function applyFix() {
  64. requestAnimationFrame(() => {
  65. queryView();
  66. // if (curView === 'timeline') {
  67. // fixTimelineDividerPosition();
  68. // }
  69. if (curView !== preView && preView === 'timeline') {
  70. fixScrollbarPosition();
  71. }
  72. preView = curView;
  73. });
  74. }
  75. })();

QingJ © 2025

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