VanishIt

通过快速 Alt+右键操作,让任何页面元素轻松消失。

  1. // ==UserScript==
  2. // @name VanishIt
  3. // @namespace https://greasyfork.org/en/users/1451802
  4. // @version 1.2
  5. // @description Make any page element disappear effortlessly using a quick Alt+Right-click.
  6. // @description:de Lassen Sie jedes Element der Seite mühelos verschwinden – mit einem schnellen Alt+Rechtsklick.
  7. // @description:es Haz desaparecer cualquier elemento de la página sin esfuerzo con un rápido Alt+Clic derecho.
  8. // @description:fr Faites disparaître n'importe quel élément de la page en un clin d'œil grâce à un rapide Alt+Clic droit.
  9. // @description:it Fai sparire qualsiasi elemento della pagina senza sforzo usando un rapido Alt+Clic destro.
  10. // @description:ru С легкостью заставьте любой элемент страницы исчезнуть с помощью быстрого Alt+правого клика.
  11. // @description:zh-CN 通过快速 Alt+右键操作,让任何页面元素轻松消失。
  12. // @description:zh-TW 透過快速 Alt+右鍵操作,輕鬆讓任何頁面元素消失。
  13. // @description:ja Alt+右クリックを使って、どんなページ要素も簡単に消し去ります。
  14. // @description:ko 빠른 Alt+우클릭으로 페이지의 모든 요소를 손쉽게 제거합니다.
  15. // @author NormalRandomPeople (https://github.com/NormalRandomPeople)
  16. // @match *://*/*
  17. // @grant none
  18. // @icon https://www.svgrepo.com/show/253495/erase-clean.svg
  19. // @compatible chrome
  20. // @compatible firefox
  21. // @compatible opera
  22. // @compatible edge
  23. // @compatible brave
  24. // @license MIT
  25. // ==/UserScript==
  26.  
  27. (function () {
  28. 'use strict';
  29.  
  30. const customMenu = document.createElement('div');
  31. customMenu.style.position = 'fixed';
  32. customMenu.style.zIndex = 2147483647;
  33. customMenu.style.pointerEvents = 'auto';
  34. customMenu.style.padding = '5px 10px';
  35. customMenu.style.boxShadow = '2px 2px 6px rgba(0,0,0,0.2)';
  36. customMenu.style.fontFamily = 'Arial, sans-serif';
  37. customMenu.style.fontSize = '14px';
  38. customMenu.style.cursor = 'pointer';
  39. customMenu.style.display = 'none';
  40. customMenu.textContent = 'Destroy';
  41.  
  42. function applyTheme() {
  43. const darkMode = window.matchMedia('(prefers-color-scheme: dark)').matches;
  44. if (darkMode) {
  45. customMenu.style.backgroundColor = '#222';
  46. customMenu.style.color = '#eee';
  47. customMenu.style.border = '1px solid #555';
  48. customMenu.addEventListener('mouseover', () => {
  49. customMenu.style.backgroundColor = '#333';
  50. });
  51. customMenu.addEventListener('mouseout', () => {
  52. customMenu.style.backgroundColor = '#222';
  53. });
  54. } else {
  55. customMenu.style.backgroundColor = '#fff';
  56. customMenu.style.color = '#000';
  57. customMenu.style.border = '1px solid #ccc';
  58. customMenu.addEventListener('mouseover', () => {
  59. customMenu.style.backgroundColor = '#eee';
  60. });
  61. customMenu.addEventListener('mouseout', () => {
  62. customMenu.style.backgroundColor = '#fff';
  63. });
  64. }
  65. }
  66.  
  67. applyTheme();
  68.  
  69. window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', applyTheme);
  70.  
  71. document.documentElement.appendChild(customMenu);
  72. let targetElement = null;
  73.  
  74. document.addEventListener('contextmenu', (e) => {
  75. if (e.altKey) {
  76. e.preventDefault();
  77. e.stopPropagation();
  78. targetElement = e.target;
  79. customMenu.style.top = `${e.clientY}px`;
  80. customMenu.style.left = `${e.clientX}px`;
  81. customMenu.style.display = 'block';
  82. } else {
  83. customMenu.style.display = 'none';
  84. }
  85. }, true);
  86.  
  87. document.addEventListener('click', () => {
  88. customMenu.style.display = 'none';
  89. }, true);
  90.  
  91. customMenu.addEventListener('click', (e) => {
  92. if (targetElement && targetElement.parentNode) {
  93. targetElement.parentNode.removeChild(targetElement);
  94. }
  95. customMenu.style.display = 'none';
  96. e.stopPropagation();
  97. });
  98.  
  99. document.addEventListener('keydown', (e) => {
  100. if (e.key === 'Escape') {
  101. customMenu.style.display = 'none';
  102. }
  103. }, true);
  104.  
  105. })();