VanishIt

通过快速 Alt+右键操作,让任何页面元素轻松消失。

当前为 2025-06-10 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         VanishIt
// @namespace    https://greasyfork.org/en/users/1451802
// @version      1.2
// @description  Make any page element disappear effortlessly using a quick Alt+Right-click.
// @description:de   Lassen Sie jedes Element der Seite mühelos verschwinden – mit einem schnellen Alt+Rechtsklick.
// @description:es   Haz desaparecer cualquier elemento de la página sin esfuerzo con un rápido Alt+Clic derecho.
// @description:fr   Faites disparaître n'importe quel élément de la page en un clin d'œil grâce à un rapide Alt+Clic droit.
// @description:it   Fai sparire qualsiasi elemento della pagina senza sforzo usando un rapido Alt+Clic destro.
// @description:ru   С легкостью заставьте любой элемент страницы исчезнуть с помощью быстрого Alt+правого клика.
// @description:zh-CN   通过快速 Alt+右键操作,让任何页面元素轻松消失。
// @description:zh-TW   透過快速 Alt+右鍵操作,輕鬆讓任何頁面元素消失。
// @description:ja   Alt+右クリックを使って、どんなページ要素も簡単に消し去ります。
// @description:ko   빠른 Alt+우클릭으로 페이지의 모든 요소를 손쉽게 제거합니다.
// @author       NormalRandomPeople (https://github.com/NormalRandomPeople)
// @match        *://*/*
// @grant        none
// @icon         https://www.svgrepo.com/show/253495/erase-clean.svg
// @compatible      chrome
// @compatible      firefox
// @compatible      opera
// @compatible      edge
// @compatible      brave
// @license      MIT
// ==/UserScript==

(function () {
    'use strict';

    const customMenu = document.createElement('div');
    customMenu.style.position = 'fixed';
    customMenu.style.zIndex = 2147483647;
    customMenu.style.pointerEvents = 'auto';
    customMenu.style.padding = '5px 10px';
    customMenu.style.boxShadow = '2px 2px 6px rgba(0,0,0,0.2)';
    customMenu.style.fontFamily = 'Arial, sans-serif';
    customMenu.style.fontSize = '14px';
    customMenu.style.cursor = 'pointer';
    customMenu.style.display = 'none';
    customMenu.textContent = 'Destroy';

    function applyTheme() {
        const darkMode = window.matchMedia('(prefers-color-scheme: dark)').matches;
        if (darkMode) {
            customMenu.style.backgroundColor = '#222';
            customMenu.style.color = '#eee';
            customMenu.style.border = '1px solid #555';
            customMenu.addEventListener('mouseover', () => {
                customMenu.style.backgroundColor = '#333';
            });
            customMenu.addEventListener('mouseout', () => {
                customMenu.style.backgroundColor = '#222';
            });
        } else {
            customMenu.style.backgroundColor = '#fff';
            customMenu.style.color = '#000';
            customMenu.style.border = '1px solid #ccc';
            customMenu.addEventListener('mouseover', () => {
                customMenu.style.backgroundColor = '#eee';
            });
            customMenu.addEventListener('mouseout', () => {
                customMenu.style.backgroundColor = '#fff';
            });
        }
    }

    applyTheme();

    window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', applyTheme);

    document.documentElement.appendChild(customMenu);
    let targetElement = null;

    document.addEventListener('contextmenu', (e) => {
        if (e.altKey) {
            e.preventDefault();
            e.stopPropagation();
            targetElement = e.target;
            customMenu.style.top = `${e.clientY}px`;
            customMenu.style.left = `${e.clientX}px`;
            customMenu.style.display = 'block';
        } else {
            customMenu.style.display = 'none';
        }
    }, true);

    document.addEventListener('click', () => {
        customMenu.style.display = 'none';
    }, true);

    customMenu.addEventListener('click', (e) => {
        if (targetElement && targetElement.parentNode) {
            targetElement.parentNode.removeChild(targetElement);
        }
        customMenu.style.display = 'none';
        e.stopPropagation();
    });

    document.addEventListener('keydown', (e) => {
        if (e.key === 'Escape') {
            customMenu.style.display = 'none';
        }
    }, true);

})();