Notion Fix

Fix bugs in Notion

当前为 2021-08-11 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Notion Fix
  3. // @namespace https://github.com/alanleungcn/notion-fix
  4. // @version 1.0
  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. }
  32. }, checkInterval);
  33.  
  34. window.addEventListener('click', () => {
  35. applyFix();
  36. });
  37.  
  38. function fixTimelineDividerPosition() {
  39. document.querySelector('.pseudoSelection').style.position = '';
  40. }
  41.  
  42. function fixScrollbarPosition() {
  43. document.querySelector(
  44. '.notion-scroller.vertical.horizontal'
  45. ).scrollLeft = 0;
  46. }
  47.  
  48. function queryView() {
  49. viewList.forEach((view, i) => {
  50. if (document.querySelector(`.notion-${view}-view`)) {
  51. curView = viewList[i];
  52. }
  53. });
  54. }
  55.  
  56. function applyFix() {
  57. requestAnimationFrame(() => {
  58. queryView();
  59. if (curView === 'timeline') {
  60. fixTimelineDividerPosition();
  61. }
  62. if (curView !== preView && preView === 'timeline') {
  63. fixScrollbarPosition();
  64. }
  65. preView = curView;
  66. });
  67. }
  68. })();

QingJ © 2025

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