Greasy Fork is available in English.
给手机网站增加一个可以删除图片的按钮
当前为
// ==UserScript==
// @name 过图自定义
// @namespace http://tampermonkey.net/
// @version 0.0.03
// @description 给手机网站增加一个可以删除图片的按钮
// @author self
// @match *://*/*
// @grant none
// ==/UserScript==
if(typeof jQuery == 'undefined') {
console.info('jQuery已加载!');
}
else {
console.info('jQuery未加载!');
document.write("<script src='https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js'><\/script>");
}
function hidePic(){
var a = document.getElementsByTagName("img");
for(var i =0;i<a.length;i++){
a[i].style.display = "none";
a[i].style.width=0;
a[i].style.height=0;
alert(a[i].style.z-index);
}
}
function addbtn(){
(Array.from(document.querySelectorAll('body *'))).map(function (x){
((+window.getComputedStyle(x).zIndex || 0) >100)?($(x).css("z-index","-1")):"";
});
var div=document.createElement("button");
div.innerText = "关闭图片";
div.onclick=hidePic;
//把div元素节点添加到body元素节点中成为其子节点,但是放在body的现有子节点的最后
document.body.appendChild(div);
//插入到最前面
document.body.insertBefore(div, document.body.firstElementChild);
}
addbtn();