bloomberg archive.ph remove ai

Hides a specific div ancestor of path elements on archive.ph

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        bloomberg archive.ph remove ai
// @description Hides a specific div ancestor of path elements on archive.ph
// @match       https://archive.ph/*
// @version 0.0.1.20250718081600
// @namespace https://greasyfork.org/users/1435046
// ==/UserScript==

(function() {
    'use strict';

    function hideDivAncestorByPath(pathSelector, divLevel) {
        const path = document.querySelector(`path[d^="${pathSelector}"]`);
        if (path) {
            let ancestor = path.parentElement;
            let divCount = 0;
            while (ancestor) {
                if (ancestor.tagName === 'DIV') {
                    divCount++;
                    if (divCount === divLevel) {
                        ancestor.style.cssText = 'display: none !important';
                        return true;
                    }
                }
                ancestor = ancestor.parentElement;
            }
        }
        return false;
    }

    function hideTarget() {
        return hideDivAncestorByPath("M14.25 6.25L15.1875 4.1875L17.25", 3) ||
               hideDivAncestorByPath("m19 9 1.25-2.75L23", 2);
    }

    if (hideTarget()) return;

    const observer = new MutationObserver(function() {
        if (hideTarget()) {
            observer.disconnect();
        }
    });

    observer.observe(document.body, { childList: true, subtree: true });
})();