跳转到内容
View in the app

A better way to browse. Learn more.

彼岸论坛

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
欢迎抵达彼岸 彼岸花开 此处谁在 -彼岸论坛

[VXNA] 屏蔽 VXNA 不想看到的数据源

发表于

有些大博客大量内容就几十个字,或者贴段代码自嗨。

不想被这些数据源刷屏,所以写了这个脚本。应该,也许,没有大问题吧?

// ==UserScript==
// @name         vxna_blacklist
// @namespace    http://tampermonkey.net/
// @version      2024-06-20
// @description  try to take over the world!
// @author       You
// @match        https://v2ex.com/xna*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// ==/UserScript==

(function() {
  'use strict';
  const vxna_blacklist = JSON.parse(localStorage.getItem("vxna_blacklist")) || [];
  let init = false;
  const handle = () => {
    document
      .querySelectorAll(".xna-entry.cell .xna-entry-source .node")
      .forEach((el) => {
        if (vxna_blacklist.includes(el.text)) {
          el.closest(".xna-entry.cell").style.display = "none";
        } else {
          if (init) return;
          const fragment = document.createDocumentFragment();
          const span1 = document.createElement("span");
          const span2 = document.createElement("span");
          span1.className = "fade";
          span2.className = "fade black";
          span1.innerHTML = " • ";
          span2.innerHTML = " 屏蔽 ";
          span2.setAttribute("data-name", el.text);
          fragment.appendChild(span1);
          fragment.appendChild(span2);
          el.closest("div").appendChild(fragment);
        }
      });
    init = true;
  };
  handle();
  document.querySelector("#Main>.box").addEventListener("click", (e) => {
    const target = e.target;
    if (!target) return;
    if (target.className === "fade black") {
      vxna_blacklist.unshift(target.getAttribute("data-name"));
      localStorage.setItem("vxna_blacklist", JSON.stringify(vxna_blacklist));
      handle();
    }
  });
})();

Featured Replies

No posts to show

创建帐户或登录来提出意见

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.