| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- // ==UserScript==
- // @name Remove All Images
- // @namespace http://tampermonkey.net/
- // @version 0.1
- // @description Add a button to remove all images on the page
- // @author You
- // @match *://*/*
- // @grant none
- // ==/UserScript==
- (function() {
- 'use strict';
- // 创建按钮元素
- const button = document.createElement('button');
- button.textContent = "Remove Img";
- button.style.position = "fixed";
- button.style.top = "12.5%";
- button.style.right = "1%";
- button.style.transform = "translateY(-50%)";
- button.style.padding = "3px 8px";
- button.style.fontSize = "10px";
- button.style.backgroundColor = "#007baf";
- button.style.color = "#fff";
- button.style.border = "none";
- button.style.borderRadius = "5px";
- button.style.cursor = "pointer";
- button.style.zIndex = "10000";
- // 为按钮添加点击事件监听器
- button.addEventListener('click', function() {
- // 获取页面上的所有图片元素
- const images = document.querySelectorAll('img');
- // 遍历所有图片元素并移除它们
- images.forEach(image => {
- image.parentNode.removeChild(image);
- });
- });
- // 将按钮添加到页面的 body 元素中
- document.body.appendChild(button);
- })();
|