Notion.so - Hide The Crap

Show/Hide the properties section in Notion pages

  1. // ==UserScript==
  2. // @name Notion.so - Hide The Crap
  3. // @name:en Notion.so - Hide The Crap
  4. // @description Show/Hide the properties section in Notion pages
  5. // @namespace https://github.com/smartnora
  6. // @match https://www.notion.so/*
  7. // @run-at document-start
  8. // @version 0.0.3
  9. // @grant GM.setValue
  10. // @grant GM.getValue
  11. // ==/UserScript==
  12. /* jshint esversion: 6 */
  13.  
  14. // Edit these to change the text
  15. const HIDE_TEXT = "🧹 Hide The Crap";
  16. const SHOW_TEXT = "💩 Show The Crap";
  17. ////////////////////////////////////
  18.  
  19. // Code below
  20. GM.getValue("hidecrap", false).then((val) => {
  21. window.hidden_crap = val;
  22. })
  23.  
  24. function set_crap(hide) {
  25. let crap = getCommentBlock().parentElement;
  26. if (hide) {
  27. crap.classList.add("hiddencrap");
  28. newButton.innerText = SHOW_TEXT;
  29. } else {
  30. crap.classList.remove("hiddencrap");
  31. newButton.innerText = HIDE_TEXT;
  32. }
  33. GM.setValue("hidecrap", hide);
  34. }
  35. function toggle_crap() {
  36. window.hidden_crap = !window.hidden_crap;
  37. set_crap(window.hidden_crap);
  38. }
  39.  
  40. function getCommentBlock() {
  41. let comments = document.querySelector('.notion-page-view-discussion');
  42. if (comments == null) {
  43. return null;
  44. }
  45. return comments;
  46. }
  47.  
  48. function createClass(name,rules){
  49. var style = document.createElement('style');
  50. style.type = 'text/css';
  51. document.getElementsByTagName('head')[0].appendChild(style);
  52. if(!(style.sheet||{}).insertRule)
  53. (style.styleSheet || style.sheet).addRule(name, rules);
  54. else
  55. style.sheet.insertRule(name+"{"+rules+"}",0);
  56. }
  57.  
  58. // TODO: Make this continuously look for new divs
  59. function button_setup() {
  60. console.log("Button Setup");
  61. if (getCommentBlock() == null) {
  62. window.requestAnimationFrame(button_setup);
  63. } else {
  64. // Let's double check something real quick
  65. if (getCommentBlock().classList.contains("crap-setup")) {
  66. // Abort
  67. return;
  68. }
  69. newButton = document.createElement("div");
  70. newButton.innerText = HIDE_TEXT;
  71. newButton.style="float:left; cursor: pointer; display: inline-flex;font-size: 14px; color: rgba(55, 53, 47, 0.4); margin: 10px";
  72. newButton.addEventListener('click', toggle_crap);
  73. getCommentBlock().parentElement.parentElement.insertAdjacentElement('beforebegin', newButton);
  74. getCommentBlock().classList.add("crap-setup");
  75. set_crap(window.hidden_crap);
  76. }
  77. }
  78. createClass('.hiddencrap',"display: none;");
  79. // Call it once
  80. button_setup();

QingJ © 2025

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