qiita-hide-noisy-sections

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

اعتبارا من 23-09-2024. شاهد أحدث إصدار.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name         qiita-hide-noisy-sections
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  qiita の目障りな項目を非表示にする
// @author      tamura
// @match       https://qiita.com/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// @license      CC0-1.0
// ==/UserScript==

(function () {
  "use strict";

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

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

    [...noisy_sections].forEach((e) => {
      e.closest("section").remove();
    });
    const register_links = Array.from(document.querySelectorAll("p")).find(
      (el) => el.textContent.includes("新規登録して")
    );
    register_links && register_links.closest("div").remove();

    const footer = document.querySelector(".st-footer_navigation");
    footer && footer.remove();
  };
  // 遅延描画される項目どうすればよいかわからないので1秒ごとに探して消す
  setInterval(removeSections, 1000);
})();