隐藏/显示页面图片

在网页右下角添加一个按钮,可以隐藏和显示页面上的所有img标签

  1. // ==UserScript==
  2. // @name 隐藏/显示页面图片
  3. // @name:en hide/display image
  4. // @namespace None
  5. // @version 1.2
  6. // @description 在网页右下角添加一个按钮,可以隐藏和显示页面上的所有img标签
  7. // @description:en Add a button for all websites which can back to the top and go to the bottom,and there is a sliding effecct.
  8. // @author mofiter
  9. // @create 2023-06-06
  10. // @lastmodified 2023-06-06
  11. // @include http*://*/*
  12. // @license MIT
  13. // ==/UserScript==
  14. function creatIcon(){
  15. const img = document.createElement("img");
  16. img.src = "https://i.niupic.com/images/2023/06/19/bqao.png";
  17. img.style.position = "fixed";
  18. img.style.width = "45px";
  19. img.style.height = "45px";
  20. img.style.bottom = "60px";
  21. img.style.right = "6vw";
  22. img.style.opacity = "0.5";
  23. img.id="baojin_ovo";
  24. img.title="crtl+alt";
  25. img.addEventListener("click", () => {
  26. const images = document.querySelectorAll("img");
  27. const elementToRemove = document.getElementById("baojin_ovo");
  28. images.forEach(image => {
  29. image.style.display = "inline";
  30. });
  31. elementToRemove.parentNode.removeChild(elementToRemove);
  32. });
  33. document.body.appendChild(img);
  34. }
  35. const img = document.createElement("img");
  36. img.src = "https://i.niupic.com/images/2023/06/19/bqad.png";
  37. img.style.position = "fixed";
  38. img.style.width = "45px";
  39. img.style.height = "45px";
  40. img.style.bottom = "-60px";
  41. img.style.right = "6vw";
  42. img.style.opacity = "0.5";
  43. img.id="baojin_owo";
  44. img.title="crtl+alt";
  45. img.addEventListener("click", () => {
  46. const images = document.querySelectorAll("img");
  47. images.forEach(image => {
  48. image.style.display = "none";
  49. });
  50. creatIcon();
  51. });
  52. document.body.appendChild(img);
  53. const placeholder = document.getElementById("img-placeholder");
  54. setTimeout(() => {
  55. img.style.transition = "transform 1.2s";
  56. img.style.transform = "translateY(-120px)";
  57. // placeholder.remove();
  58. }, 1000);
  59.  
  60. var i = 1;
  61.  
  62. var A = (function() {
  63. return function() {
  64. if (i%2===0){
  65. const images = document.querySelectorAll("img");
  66. const elementToRemove = document.getElementById("baojin_ovo");
  67. images.forEach(image => {
  68. image.style.display = "inline";
  69. });
  70. elementToRemove.parentNode.removeChild(elementToRemove);
  71. console.log("on")
  72. }else{
  73. const images = document.querySelectorAll("img");
  74. images.forEach(image => {
  75. image.style.display = "none";
  76. });
  77. creatIcon();
  78. console.log("off");
  79. }
  80. i++;
  81. console.log(i)
  82. }
  83. })();
  84.  
  85. document.addEventListener('keydown', function(event) {
  86. if (event.ctrlKey && event.altKey) { // 判断是否按下ctrl+A
  87. A(); // 执行function A()
  88. }
  89. });

QingJ © 2025

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