防窥屏启动

Always hide specific element on tuxun.fun

  1. // ==UserScript==
  2. // @name 防窥屏启动
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.2
  5. // @description Always hide specific element on tuxun.fun
  6. // @author You
  7. // @match https://tuxun.fun/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // 选择器数组,用于匹配要隐藏或显示的元素
  15. const selectors = [
  16. 'img.leaflet-marker-icon[alt="Marker"][role="button"]',
  17. '#map > div.leaflet-pane.leaflet-map-pane > div.leaflet-pane.leaflet-shadow-pane > img',
  18. 'div[id^="leaflet-tooltip-"]',
  19. '#tuxun > div > div > div.confirm'
  20. ];
  21.  
  22. // 隐藏匹配的元素
  23. function hideElements() {
  24. for (const selector of selectors) {
  25. const elements = document.querySelectorAll(selector);
  26. elements.forEach(element => {
  27. if (element) {
  28. element.style.display = 'none';
  29. }
  30. });
  31. }
  32. }
  33.  
  34. // 显示匹配的元素
  35. function showElements() {
  36. for (const selector of selectors) {
  37. const elements = document.querySelectorAll(selector);
  38. elements.forEach(element => {
  39. if (element) {
  40. element.style.display = 'block';
  41. }
  42. });
  43. }
  44. }
  45.  
  46. // 根据特定的元素存在与否,决定是否显示或隐藏元素
  47. function checkForTargetSelectorAndToggleElements() {
  48. const targetElement = document.querySelector('#tuxun > div > div > div.im-view > div.round_result > div.round_result_round_info > div');
  49.  
  50. if (targetElement) {
  51. showElements();
  52. } else {
  53. hideElements();
  54. }
  55. }
  56.  
  57. // 如果有保存的状态,根据保存的状态决定显示或隐藏元素
  58. if (localStorage.getItem('elementsVisibility') === 'hidden') {
  59. hideElements();
  60. } else {
  61. showElements();
  62. }
  63.  
  64. // 防窥屏动画效果
  65.  
  66. // 防窥屏按钮的选择器
  67. const buttonSelector = '#viewer > div > div:nth-child(14) > div.gmnoprint.gm-bundled-control.gm-bundled-control-on-bottom > div > div';
  68.  
  69. const elts = {
  70. text1: document.createElement("div"),
  71. text2: document.createElement("div")
  72. };
  73.  
  74. const texts = ["防窥屏启动!"];
  75. const morphTime = 1;
  76. const cooldownTime = 0.25;
  77. let animationDuration = texts.length * (morphTime + cooldownTime);
  78.  
  79. let textIndex = texts.length - 1;
  80. let time = new Date();
  81. let morph = 0;
  82. let cooldown = cooldownTime;
  83.  
  84. // 防窥屏动画逻辑
  85. function startPrivacyScreenAnimation() {
  86. elts.text1.textContent = texts[textIndex % texts.length];
  87. elts.text2.textContent = texts[(textIndex + 1) % texts.length];
  88.  
  89. function doMorph() {
  90. morph -= cooldown;
  91. cooldown = 0;
  92.  
  93. let fraction = morph / morphTime;
  94.  
  95. if (fraction > 1) {
  96. cooldown = cooldownTime;
  97. fraction = 1;
  98. }
  99.  
  100. setMorph(fraction);
  101. }
  102.  
  103. function setMorph(fraction) {
  104. elts.text2.style.filter = `blur(${Math.min(8 / fraction - 8, 100)}px)`;
  105. elts.text2.style.opacity = `${Math.pow(fraction, 0.4) * 100}%`;
  106.  
  107. fraction = 1 - fraction;
  108. elts.text1.style.filter = `blur(${Math.min(8 / fraction - 8, 100)}px)`;
  109. elts.text1.style.opacity = `${Math.pow(fraction, 0.4) * 100}%`;
  110.  
  111. elts.text1.textContent = texts[textIndex % texts.length];
  112. elts.text2.textContent = texts[(textIndex + 1) % texts.length];
  113. }
  114.  
  115. function doCooldown() {
  116. morph = 0;
  117.  
  118. elts.text2.style.filter = "";
  119. elts.text2.style.opacity = "100%";
  120.  
  121. elts.text1.style.filter = "";
  122. elts.text1.style.opacity = "0%";
  123. }
  124.  
  125. function animate() {
  126. // 添加这个条件来检查opacity是否为0
  127. if (parseFloat(elts.text1.style.opacity) <= 0) {
  128. return;
  129. }
  130.  
  131. requestAnimationFrame(animate);
  132.  
  133. let newTime = new Date();
  134. let shouldIncrementIndex = cooldown > 0;
  135. let dt = (newTime - time) / 1000;
  136. time = newTime;
  137.  
  138. cooldown -= dt;
  139.  
  140. if (cooldown <= 0) {
  141. if (shouldIncrementIndex) {
  142. textIndex++;
  143. }
  144.  
  145. doMorph();
  146. } else {
  147. doCooldown();
  148. }
  149. }
  150.  
  151. animate();
  152. }
  153.  
  154. // 添加样式到动画元素
  155. Object.values(elts).forEach(elt => {
  156. elt.style.position = 'fixed';
  157. elt.style.top = '50%';
  158. elt.style.left = '50%';
  159. elt.style.transform = 'translate(-50%, -50%)';
  160. elt.style.fontSize = '8em';
  161. elt.style.fontWeight = 'bold';
  162. elt.style.color = 'white';
  163. elt.style.textAlign = 'center';
  164. elt.style.fontFamily = 'fantasy';
  165. elt.style.zIndex = '9999';
  166. elt.style.display = 'none'; // 初始状态为隐藏
  167. });
  168. elts.text1.style.opacity = '0%';
  169.  
  170. document.body.appendChild(elts.text1);
  171. document.body.appendChild(elts.text2);
  172.  
  173. // 设置按钮监听器
  174. function setupButtonListener() {
  175. const buttonElement = document.querySelector(buttonSelector);
  176. if (buttonElement) {
  177. buttonElement.addEventListener('click', () => {
  178. startPrivacyScreenAnimation();
  179. elts.text1.style.display = 'block';
  180. elts.text2.style.display = 'block';
  181.  
  182. setTimeout(() => {
  183. elts.text1.style.display = 'none';
  184. elts.text2.style.display = 'none';
  185. }, animationDuration * 1000);
  186. });
  187. }
  188. }
  189.  
  190. setupButtonListener();
  191.  
  192. // 使用MutationObserver检查按钮是否后续被添加
  193. const observer = new MutationObserver(function(mutations) {
  194. mutations.forEach(function() {
  195. setupButtonListener();
  196. checkForTargetSelectorAndToggleElements();
  197. });
  198. });
  199.  
  200. // 开始观察整个文档
  201. observer.observe(document.body, { childList: true, subtree: true });
  202. })();

QingJ © 2025

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