过图自定义

给手机网站增加一个可以删除图片的按钮

当前为 2019-03-31 提交的版本,查看 最新版本

// ==UserScript==
// @name         过图自定义
// @namespace    https://greasyfork.org/zh-CN/scripts/381167
// @version      0.0.05
// @description  给手机网站增加一个可以删除图片的按钮
// @homepage     https://greasyfork.org/zh-CN/scripts/381167
// @author       unmht001
// @match        *://*/*
// @grant        none
// ==/UserScript==

function clearzindex(c){
  console.log("clear z-index > 100.");
 (Array.from(document.querySelectorAll('body *'))).map(function (x){
    ((+window.getComputedStyle(x).zIndex || 0) >100)?(x.style.cssText+=";z-index:-1"):"";
  });

  setTimeout(function (){
    clearzindex(c+c >300000?300000:c+c );
    
  },c)
  
}



function addbtn(){
  clearzindex(1000);
 (Array.from(document.querySelectorAll('body *'))).map(function (x){
    ((+window.getComputedStyle(x).zIndex || 0) >100)?(x.style.cssText+=";z-index:-1"):"";
  });
  var div=document.createElement("button");
  div.innerText = "关闭图片";
  div.style.cssText+=";z-index:100";
  div.onclick=function () {document.getElementsByTagName("img").map(function (x){x.style.cssText+=";display:none;width:0px;height:0px";})};
//把div元素节点添加到body元素节点中成为其子节点,但是放在body的现有子节点的最后
  document.body.appendChild(div);
//插入到最前面
  document.body.insertBefore(div, document.body.firstElementChild);    
}
addbtn();