Notion.so - Hide The Crap

Show/Hide the properties section in Notion pages

目前為 2020-05-19 提交的版本,檢視 最新版本

// ==UserScript==
// @name        Notion.so - Hide The Crap
// @name:en     Notion.so - Hide The Crap
// @description Show/Hide the properties section in Notion pages
// @namespace   https://github.com/smartnora
// @match       https://www.notion.so/*
// @run-at      document-start
// @version     0.0.1
// @grant       GM.setValue
// @grant       GM.getValue
// ==/UserScript==
/* jshint esversion: 6 */

// Edit these to change the text
const HIDE_TEXT = "🧹 Hide The Crap";
const SHOW_TEXT = "💩 Show The Crap";
////////////////////////////////////

// Code below
GM.getValue("hidecrap", false).then((val) => {
  window.hidden_crap = val;
})

function set_crap(hide) {
  if (hide) {
    getCommentBlock().previousElementSibling.style.display='none';
    newButton.innerText = SHOW_TEXT;
  } else {
    getCommentBlock().previousElementSibling.style.display='inherit';
    newButton.innerText = HIDE_TEXT;
  }
  GM.setValue("hidecrap", hide);
}
  
  
function toggle_crap() {
  window.hidden_crap = !window.hidden_crap;
  set_crap(window.hidden_crap);
}

function getCommentBlock() {
  let comments = document.querySelector('[placeholder^="Add a comment"]');
  if (comments == null) {
    return null;
  }
  return comments.parentElement.parentElement.parentElement.parentElement;
}

// TODO: Make this continuously look for new divs
function button_setup() {
  if (getCommentBlock() == null) {
    window.requestAnimationFrame(button_setup);
  } else {
    newButton = document.createElement("div");
    newButton.innerText = HIDE_TEXT;
    newButton.style="float:left; cursor: pointer; display: inline-flex;font-size: 14px; color: rgba(55, 53, 47, 0.4); margin: 10px";
    newButton.addEventListener('click', toggle_crap);
    getCommentBlock().previousElementSibling.insertAdjacentElement('beforebegin', newButton);
    set_crap(window.hidden_crap);
  }
}
button_setup();

QingJ © 2025

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