qiita-hide-noisy-sections

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

Από την 04/10/2024. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         qiita-hide-noisy-sections
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  qiita の見た目をシンプルにします
// @author
// @match       https://qiita.com/*/items/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// @license      MIT
// ==/UserScript==

(function () {
  "use strict";

  // うるさいポップアップや項目を非表示に
  document.head.insertAdjacentHTML(
    "beforeend",
    `
<style>
  [data-testid^="popup-"]{ display: none !important; }
  div.coins-optin-dialog{ display: none !important; }
</style>
`
  );

  // うるさいセクションを非表示に
  var removeSections = function () {
    const noisy_sections = Array.from(document.querySelectorAll("h2, h3")).find(
      (el) =>
        el.textContent.includes("トレンド") ||
        el.textContent.includes("キャンペーン") ||
        el.textContent.includes("ピックアップ")

    );
    if (!!noisy_sections) {
      noisy_sections.closest("section").remove();
    }
    //コメントより後のセクションは削除
     const commentsNode=document.getElementById("comments");
     if(commentsNode){
         const noisy_=[];
         let section=commentsNode.parentNode.nextSibling;
         while(section){
             noisy_.push(section);
             section=section.nextSibling;
         }
         noisy_.forEach((e) => {
             e.remove();
         });
     }

    const register_links = Array.from(document.querySelectorAll("p")).find(
      (el) => el.textContent.includes("新規登録して")
    );
    if (!!register_links) {
      register_links.closest("div").remove();
    }

    const iine_login_links = Array.from(document.querySelectorAll("h3")).find(
       (el) => el.textContent.includes("いいね以上の気持ちはコメント")
    );
    // レイアウトくずれるので display none に
    if(iine_login_links) {iine_login_links.closest("div").style.display="none"};

     const footer = document.querySelector("[id^='GlobalFooter']");
     if(footer && footer.querySelector("footer")){
         [...footer.querySelector("footer").children].forEach((e) => {
             e.remove();
         });
     }
  };

  setInterval(removeSections, 1000);
})();