qiita-hide-noisy-sections

qiita の目障りな項目を非表示にする

目前為 2024-09-23 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name qiita-hide-noisy-sections
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description qiita の目障りな項目を非表示にする
  6. // @author tamura
  7. // @match https://qiita.com/*
  8. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  9. // @grant none
  10. // @license CC0-1.0
  11. // ==/UserScript==
  12.  
  13. (function () {
  14. "use strict";
  15.  
  16. // うるさいポップアップや項目を非表示に
  17. document.head.insertAdjacentHTML(
  18. "beforeend",
  19. `
  20. <style>
  21. [data-testid^="popup-"]{ display: none !important; }
  22. div.coins-optin-dialog{ display: none !important; }
  23. </style>
  24. `
  25. );
  26.  
  27. // うるさいセクションを非表示に
  28. const noisy_texts = ["トレンド", "キャンペーン", "ピックアップ"];
  29. var removeSections = function () {
  30. const noisy_sections = Array.from(document.querySelectorAll("h2")).filter(
  31. (el) => noisy_texts.some((s) => el.textContent.includes(s))
  32. );
  33.  
  34. [...noisy_sections].forEach((e) => {
  35. e.closest("section").remove();
  36. });
  37. const register_links = Array.from(document.querySelectorAll("p")).find(
  38. (el) => el.textContent.includes("新規登録して")
  39. );
  40. register_links && register_links.closest("div").remove();
  41.  
  42. const footer = document.querySelector(".st-footer_navigation");
  43. footer && footer.remove();
  44. };
  45. // 遅延描画される項目どうすればよいかわからないので1秒ごとに探して消す
  46. setInterval(removeSections, 1000);
  47. })();