Sleazy Fork is available in English.

圖片縮放腳本

點擊圖片進行縮放和還原

  1. // ==UserScript==
  2. // @name 圖片縮放腳本
  3. // @namespace http://your-namespace.com
  4. // @version 1.1
  5. // @description 點擊圖片進行縮放和還原
  6. // @author Your Name
  7. // @match https://www.wnacg.com/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. var isZoomed = false; // 記錄是否已經縮小
  16.  
  17. // 監聽滑鼠左鍵點擊事件
  18. document.addEventListener('click', function(event) {
  19. // 檢查是否點擊的是圖片
  20. if (event.target.tagName === 'IMG') {
  21. if (!isZoomed) {
  22. // 縮小整個頁面的所有圖片到50%
  23. var images = document.querySelectorAll('img');
  24. images.forEach(function(img) {
  25. img.style.width = '50%';
  26. img.style.height = 'auto';
  27. });
  28. isZoomed = true; // 設置為已縮小
  29. } else {
  30. // 還原所有圖片到原始大小
  31. var images = document.querySelectorAll('img');
  32. images.forEach(function(img) {
  33. img.style.width = '';
  34. img.style.height = '';
  35. });
  36. isZoomed = false; // 設置為未縮小
  37. }
  38. }
  39. });
  40. })();