You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.3 KiB
42 lines
1.3 KiB
// ==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);
|
|
})(); |