qiita-hide-noisy-sections

qiita の見た目をシンプルにします

目前為 2024-10-04 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name qiita-hide-noisy-sections
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description qiita の見た目をシンプルにします
  6. // @author
  7. // @match https://qiita.com/*/items/*
  8. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  9. // @grant none
  10. // @license MIT
  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. var removeSections = function () {
  29. const noisy_sections = Array.from(document.querySelectorAll("h2")).find(
  30. (el) =>
  31. el.textContent.includes("トレンド") ||
  32. el.textContent.includes("キャンペーン") ||
  33. el.textContent.includes("ピックアップ")
  34.  
  35. );
  36. if (!!noisy_sections) {
  37. noisy_sections.closest("section").remove();
  38. }
  39. //コメントより後のセクションは削除
  40. const commentsNode=document.getElementById("comments");
  41. if(commentsNode){
  42. const noisy_=[];
  43. let section=commentsNode.parentNode.nextSibling;
  44. while(section){
  45. noisy_.push(section);
  46. section=section.nextSibling;
  47. }
  48. noisy_.forEach((e) => {
  49. e.remove();
  50. });
  51. }
  52.  
  53. const register_links = Array.from(document.querySelectorAll("p")).find(
  54. (el) => el.textContent.includes("新規登録して")
  55. );
  56. if (!!register_links) {
  57. register_links.closest("div").remove();
  58. }
  59.  
  60. const iine_login_links = Array.from(document.querySelectorAll("h3")).find(
  61. (el) => el.textContent.includes("いいね以上の気持ちはコメント")
  62. );
  63. // レイアウトくずれるので display none に
  64. if(iine_login_links) {iine_login_links.closest("div").style.display="none"};
  65.  
  66. const footer = document.querySelector("[id^='GlobalFooter']");
  67. if(footer && footer.querySelector("footer")){
  68. [...footer.querySelector("footer").children].forEach((e) => {
  69. e.remove();
  70. });
  71. }
  72. };
  73.  
  74. setInterval(removeSections, 1000);
  75. })();