notion-双击打开.js 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. // ==UserScript==
  2. // @name T-notion-双击打开
  3. // @author tianyunperfect
  4. // @description 简介
  5. // @version 1.0.0
  6. // @update 2021-07-08 16:16:14
  7. // @include https://www.notion.so/tianyunperfect/*
  8. // @require https://git.tianyunperfect.cn/tianyunperfect/web-base/raw/master/tmp/monkey/util.js?a=1
  9. // ==/UserScript==
  10. (async () => {
  11. setInterval(() => {
  12. $("div[data-block-id]").off("dblclick").on("dblclick", (ev) => {
  13. if (ev.metaKey) {
  14. ev.stopPropagation();
  15. let block_id = $(ev.target).parents("div[data-block-id]").eq(0).attr('data-block-id');
  16. block_id = block_id.replaceAll("-", "");
  17. window.open("https://www.notion.so/tianyunperfect/" + block_id, "_blank");
  18. }
  19. });
  20. $("div[data-block-id]").off("click").on("click", (ev) => {
  21. if (ev.metaKey) {
  22. ev.stopPropagation();
  23. let triangle = $(ev.target).parents("div[data-block-id]")[0].querySelector(".pseudoSelection");
  24. if (triangle && triangle.querySelector(".triangle")) {
  25. triangle.querySelector('[role="button"]').click();
  26. }
  27. }
  28. })
  29. }, 2000)
  30. })();