Notion.so - Hide The Crap

Show/Hide the properties section in Notion pages

目前为 2020-05-19 提交的版本。查看 最新版本

  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.1
  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. if (hide) {
  26. getCommentBlock().previousElementSibling.style.display='none';
  27. newButton.innerText = SHOW_TEXT;
  28. } else {
  29. getCommentBlock().previousElementSibling.style.display='inherit';
  30. newButton.innerText = HIDE_TEXT;
  31. }
  32. GM.setValue("hidecrap", hide);
  33. }
  34. function toggle_crap() {
  35. window.hidden_crap = !window.hidden_crap;
  36. set_crap(window.hidden_crap);
  37. }
  38.  
  39. function getCommentBlock() {
  40. let comments = document.querySelector('[placeholder^="Add a comment"]');
  41. if (comments == null) {
  42. return null;
  43. }
  44. return comments.parentElement.parentElement.parentElement.parentElement;
  45. }
  46.  
  47. // TODO: Make this continuously look for new divs
  48. function button_setup() {
  49. if (getCommentBlock() == null) {
  50. window.requestAnimationFrame(button_setup);
  51. } else {
  52. newButton = document.createElement("div");
  53. newButton.innerText = HIDE_TEXT;
  54. newButton.style="float:left; cursor: pointer; display: inline-flex;font-size: 14px; color: rgba(55, 53, 47, 0.4); margin: 10px";
  55. newButton.addEventListener('click', toggle_crap);
  56. getCommentBlock().previousElementSibling.insertAdjacentElement('beforebegin', newButton);
  57. set_crap(window.hidden_crap);
  58. }
  59. }
  60. button_setup();

QingJ © 2025

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