过图自定义

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

  1. // ==UserScript==
  2. // @name 过图自定义
  3. // @namespace https://gf.qytechs.cn/zh-CN/scripts/381167
  4. // @version 0.0.08
  5. // @description 给手机网站增加一个可以删除图片的按钮
  6. // @homepage https://gf.qytechs.cn/zh-CN/scripts/381167
  7. // @author unmht001
  8. // @match *://*/*
  9. // @grant none
  10. // ==/UserScript==
  11. //
  12. var __clearflag=false;
  13. var __clearhistory=[];
  14. function clearzindex(c){
  15. if (__clearflag){
  16. console.log("clear z-index > 100.");
  17. Array.from(top.document.querySelectorAll('body *')).map(function (x){
  18. ((+window.getComputedStyle(x).zIndex || 0) >100) && (x.id != "cleartooldiv")?(x.style.cssText+=";z-index:-1;display:none"):"";
  19. });
  20. setTimeout(function (){clearzindex(c);},c)
  21. }else{
  22. console.log("stop clear z-index");
  23. }
  24. }
  25.  
  26.  
  27.  
  28.  
  29. function addbtn(){
  30.  
  31. var div =top.document.createElement("div");
  32. div.id="cleartooldiv";
  33. div.style.cssText+=";position:fixed;z-index:2147483647;right:0px";
  34. var b1=top.document.createElement("button");
  35. b1.innerText = "弹出文字";
  36. b1.onclick=function () {
  37. alert(top.document.body.innerText);
  38. window.scrollTo(0,top.document.body.clientHeight)
  39. };
  40. div.appendChild(b1);
  41.  
  42. var b2=top.document.createElement("button");
  43. b2.innerText = "关闭图片";
  44. b2.onclick=function () {
  45. Array.from(top.document.getElementsByTagName("img")).map(
  46. function (x){x.style.cssText+=";display:none;width:0px;height:0px";}
  47. );
  48. };
  49. div.appendChild(b2);
  50. var b3=top.document.createElement("button");
  51. b3.innerText = __clearflag?"正在清理":"清理上层";
  52. b3.onclick=function () {
  53. __clearflag = !__clearflag;
  54. this.innerText=__clearflag?"正在清理":"清理上层";
  55. if (__clearflag){
  56. clearzindex(1000);
  57. }
  58. };
  59.  
  60. div.appendChild(b3);
  61. var b4=top.document.createElement("button");
  62. b4.innerText = "还原消除";
  63.  
  64. b4.onclick=function () {
  65. top.document.execCommand("Undo");
  66. }
  67.  
  68. div.appendChild(b4);
  69. var b5=top.document.createElement("button");
  70. b5.innerText = "上层消除";
  71. b5.onclick=function () {
  72. var _b5=[];
  73. var _z=0
  74. Array.from(top.document.querySelectorAll('body *')).map( function (x){
  75. var _x =(+window.getComputedStyle(x).zIndex || 0)
  76. if (_x==_z){
  77. x.id=="cleartooldiv"?"":(_b5.push(x));
  78. }else if(_x >_z){
  79. if (x.id!="cleartooldiv"){
  80. _b5=[];
  81. _b5.push(x);
  82. _z=_x;
  83. }
  84. }
  85. });
  86. if (_z>0){
  87. _b5.map(function (x){
  88. x.style.cssText+=";z-index:-1;display:none";
  89. });
  90.  
  91. __clearhistory.push(_z);
  92. console.log(_z,_b5,_b5.length);
  93. }else{
  94. console.log(_z,"nothing to clear");
  95. }
  96. }
  97.  
  98. div.appendChild(b5);
  99. top.document.body.insertBefore(div, top.document.body.firstElementChild);
  100. clearzindex(1000);
  101.  
  102. }
  103. addbtn();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址