您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
有了眨眼模式,可以随意控制眨眼时间
当前为
// ==UserScript== // @name 图寻眨眼模式 // @namespace http://tampermonkey.net/ // @version 1.62 // @description 有了眨眼模式,可以随意控制眨眼时间 // @author 宇宙百科君 // @match https://tuxun.fun/* // @run-at document-start // @grant none // ==/UserScript== (function() { var rectangle; // 这会在后面的代码中被赋值 'use strict'; var customDelay = 200; // 默认值是200ms if(localStorage.getItem('customDelay')) { customDelay = parseInt(localStorage.getItem('customDelay'), 10); } // 从localStorage初始化眨眼模式状态 var blinkMode = localStorage.getItem('blinkMode') !== 'false'; // 初始化刷新状态 let refreshEnabled = false; // 第1部分:进入游戏后1秒自动隐藏全景图像 let isObserverActive = true; // 添加一个标志来跟踪观察者的状态 let observer = new MutationObserver((mutations) => { if (blinkMode && isObserverActive) { let mapRoot = document.querySelector('.widget-scene-canvas'); if (mapRoot && getComputedStyle(mapRoot).display !== 'none' && getComputedStyle(mapRoot).opacity !== '0') { mapRoot.style.opacity = '0'; isObserverActive = false; // 设置观察者标志为false setTimeout(() => { mapRoot.style.opacity = '1'; // 3秒后显示全景图 setTimeout(() => { mapRoot.style.opacity = '0'; // 再经过3秒隐藏全景图 }, customDelay); }, 2000); } } }); observer.observe(document.body, { attributes: true, attributeFilter: ['style', 'width', 'height'], subtree: true }); // 第2部分:按空格键刷新页面 async function handleKeyPressForRefresh(e) { // 检查是否按下的是空格键(键码32) if (e.keyCode === 32 && blinkMode) { // 刷新页面前等待0.5秒 await new Promise(resolve => setTimeout(resolve, 500)); // 检查特定DOM元素是否存在 var specificDomElement = document.querySelector('.round_result_center'); if (!specificDomElement && refreshEnabled) { // 如果特定DOM元素不存在且已启用刷新,则刷新页面 location.reload(); } else if (specificDomElement) { // 如果特定DOM元素存在,启用刷新 refreshEnabled = true; } } } // 更改父级容器的高度 let urlPattern = /^https:\/\/tuxun\.fun\/maps-start\?mapsId=\d+$/; if (urlPattern.test(window.location.href)) { // 创建眨眼模式切换按钮 document.addEventListener("DOMContentLoaded", function() { // 创建开关容器元素 var switchContainer = document.createElement('div'); switchContainer.style.position = "relative"; // 设置绝对定位 switchContainer.style.top = "39.5%"; // 设置顶部距离 switchContainer.style.left = "50%"; // 设置左侧距离 switchContainer.style.transform = "translate(-50%, -50%)"; // 将元素居中 switchContainer.style.zIndex = "9999"; // 设置 z-index 层级 switchContainer.style.width = "40px"; // 设置宽度 switchContainer.style.height = "20px"; // 设置高度 switchContainer.style.border = "0px solid rgb(19, 206, 102)"; // 设置边框 switchContainer.style.borderRadius = "25px"; // 设置圆角 switchContainer.style.overflow = ""; // 隐藏溢出内容 switchContainer.style.cursor = "pointer"; // 添加点击指针样式 // 创建一个包含“眨眼模式”文字的元素 var switchLabel = document.createElement('div'); switchLabel.innerText = "眨眼模式"; // 设置文本内容 switchLabel.style.color = "#fff"; // 设置字体颜色为白色 switchLabel.style.backgroundColor = "rgba(0, 0, 0, 0)"; // 添加半透明的黑色背景 switchLabel.style.padding = "0"; // 添加一些内边距 switchLabel.style.borderRadius = "4px"; // 圆角 switchLabel.style.position = "absolute"; // 定位 switchLabel.style.bottom = "100%"; // 放置在开关容器的上方 switchLabel.style.left = "50%"; // 水平居中 switchLabel.style.transform = "translateX(-50%)"; // 调整为从中心点向左偏移,使其完全居中 switchLabel.style.fontFamily = "Arial, sans-serif"; // 字体样式 switchLabel.style.fontSize = "18px"; // 字体大小 switchLabel.style.writingMode = "horizontal-tb"; switchLabel.style.width = "120px"; // 显式设置宽度 switchLabel.style.whiteSpace = "nowrap"; // 防止文本换行 switchLabel.style.textAlign = "center"; // 添加文本居中属性 switchLabel.style.marginBottom = "0"; // 与开关之间的距离 switchContainer.appendChild(switchLabel); // 将标签添加到开关容器中 switchLabel.style.cursor = "text"; // 创建开关背景元素 var switchBackground = document.createElement('div'); switchBackground.style.width = "100%"; // 设置宽度为 100% switchBackground.style.height = "100%"; // 设置高度为 100% switchBackground.style.backgroundColor = blinkMode ? "rgb(19, 206, 102)" : "red"; // 初始状态为反转颜色 switchBackground.style.transition = "background-color 0.2s"; // 减小背景颜色过渡时间 switchContainer.appendChild(switchBackground); switchBackground.style.borderRadius = "25px"; // 设置圆角 // 创建白色按钮元素 var switchButton = document.createElement('div'); switchButton.style.width = "16px"; // 设置宽度 switchButton.style.height = "16px"; // 设置高度 switchButton.style.top = "12%"; // 设置垂直居中 switchButton.style.backgroundColor = "#fff"; // 设置背景颜色为白色 switchButton.style.borderRadius = "50%"; // 设置圆角 switchButton.style.position = "absolute"; // 设置绝对定位 switchButton.style.transition = "left 0.3s"; // 减小按钮平滑移动的过渡时间 switchButton.style.left = blinkMode ? "20px" : "0"; // 初始位置为反转按钮位置 switchBackground.appendChild(switchButton); switchButton.style.borderRadius = "50%"; // 设置圆角 let targetLeft = blinkMode ? 0 : 20; // 初始位置目标值为反转位置 let isAnimating = false; // 添加点击事件监听器 switchContainer.addEventListener("click", function() { if (!isAnimating) // 如果按钮仍在动画中,立即返回 isAnimating = true; blinkMode = !blinkMode; // 保存新的blinkMode状态到localStorage localStorage.setItem('blinkMode', blinkMode); switchBackground.style.backgroundColor = blinkMode ? "rgb(19, 206, 102)" : "red"; // 反转颜色 targetLeft = blinkMode ? 20 : 0; animateButton(); // 在这里检查rectangle的display属性,并进行切换 if (rectangle.style.display === 'inline-block') { rectangle.style.display = 'none'; } else { rectangle.style.display = blinkMode ? 'inline-block' : 'none'; } }); // 创建按钮动画函数 function animateButton() { const currentLeft = parseFloat(getComputedStyle(switchButton).left); const step = (targetLeft - currentLeft); if (Math.abs(targetLeft - currentLeft) > 0.5) { switchButton.style.left = currentLeft + step + "px"; requestAnimationFrame(animateButton); } else { switchButton.style.left = targetLeft + "px"; isAnimating = false; } } switchLabel.addEventListener("click", function(event) { event.stopPropagation(); // 阻止事件冒泡 }); // 将状态保存到loclStorage localStorage.setItem('blinkMode', blinkMode); // 尝试将按钮插入到指定位置 setTimeout(function() { let targetElement = document.querySelector('div[data-v-515b103e][style="padding-top: 2rem;"]'); if(targetElement) { targetElement.appendChild(switchContainer); targetElement.style.height = "80px"; // 这里更改目标元素的高度 // 创建与给定元素完全相同的元素 rectangle = document.createElement('div'); rectangle.setAttribute('data-v-515b103e', ''); rectangle.className = 'el-input-number el-input-number--medium'; rectangle.style.display = 'inline-block'; rectangle.style.display = blinkMode ? 'inline-block' : 'none'; // 添加子元素 var decreaseSpan = document.createElement('span'); decreaseSpan.role = 'button'; decreaseSpan.className = 'el-input-number__decrease'; var decreaseIcon = document.createElement('i'); decreaseIcon.className = 'el-icon-minus'; decreaseSpan.appendChild(decreaseIcon); var increaseSpan = document.createElement('span'); increaseSpan.role = 'button'; increaseSpan.className = 'el-input-number__increase'; var increaseIcon = document.createElement('i'); increaseIcon.className = 'el-icon-plus'; increaseSpan.appendChild(increaseIcon); var inputDiv = document.createElement('div'); inputDiv.className = 'el-input el-input--medium'; var inputElement = document.createElement('input'); var lastValidValue = inputElement.value; // 初始化为inputElement的初始值 inputElement.type = 'number'; inputElement.style.top = "40px"; // 设置顶部距离 inputElement.autocomplete = 'off'; inputElement.max = '60'; inputElement.min = '0'; inputElement.className = 'el-input__inner'; inputElement.role = 'spinbutton'; inputElement.setAttribute('aria-valuemax', '60'); inputElement.setAttribute('aria-valuemin', '0'); inputElement.setAttribute('aria-valuenow', '60'); inputElement.setAttribute('aria-disabled', 'false'); inputElement.value = "0";// 这里设置初始值为 "1" if(localStorage.getItem('customDelay')) { inputElement.value = parseFloat(localStorage.getItem('customDelay')) / 1000; // 将毫秒转换为秒 } inputElement.addEventListener('input', function() { var inputValue = inputElement.value; var decimalPattern = /^\d+(\.\d)?$/; // 正则表达式匹配整数或只有小数点后一位的数 if (inputValue > 60) { inputElement.value = 60; lastValidValue = 60; } else if (inputValue < 0) { inputElement.value = 0; lastValidValue = 0; } else if (!decimalPattern.test(inputValue)) { inputElement.value = lastValidValue; } else { lastValidValue = inputValue; } }); inputDiv.appendChild(inputElement); // 将子元素添加到主元素 rectangle.appendChild(decreaseSpan); rectangle.appendChild(increaseSpan); rectangle.appendChild(inputDiv); // 在rectangle元素内部添加文本"(秒)" var textDiv = document.createElement('div'); textDiv.setAttribute('data-v-515b103e', ''); textDiv.innerText = ' (秒) '; textDiv.style.height = "40px"; // 设置元素的高度 textDiv.style.lineHeight = "30px"; // 设置文本的行高来实现垂直居中 textDiv.style.color = "#fff"; // 设置字体颜色为白色 textDiv.style.fontSize = "16px"; // 字体大小 textDiv.style.top = "150%"; // 放置在开关容器的上方 rectangle.appendChild(textDiv); // 这里将 textDiv 添加到 rectangle // 获取button元素 var buttonElement = document.querySelector('button.el-button.el-button--primary.el-button--medium.is-round'); // 插入rectangle到页面上 buttonElement.parentNode.insertBefore(rectangle, buttonElement); // 调整样式以确保rectangle和buttonElement正确排列 var clearDiv = document.createElement('div'); clearDiv.style.clear = 'both'; buttonElement.parentNode.insertBefore(clearDiv, buttonElement); } else { document.body.appendChild(switchContainer); } inputElement.addEventListener('input', function() { var inputValue = parseFloat(inputElement.value); if (!isNaN(inputValue)) { customDelay = inputValue * 1000; // 将秒转换为毫秒 localStorage.setItem('customDelay', customDelay); // 保存到localStorage } }); }, 600); // 延迟2秒 let elementToChange = document.querySelector('div[data-v-515b103e][style="padding-top: 2rem;"]'); if (elementToChange) { elementToChange.style.height = "500px"; } }); } // 第3部分:按空格键翻页 function handleKeyPressForNextPage(e) { // 检查是否按下的是空格键(键码32) if (e.keyCode === 32) { // 查找“下一页”按钮并点击它 var nextPageButton = document.querySelector('.confirm .el-button.el-button--default.el-button--medium.is-round'); if (nextPageButton) { nextPageButton.click(); } } } // 第4部分:按空格键触发另一个选择器 function handleKeyPressForAnotherSelector(e) { // 检查是否按下的是空格键(键码32) if (e.keyCode === 32) { // 查找另一个选择器并执行相应操作 var buttons = document.querySelectorAll('button'); var startButton; var replayButton; var preserveButton; for (var i = 0; i < buttons.length; i++) { if (buttons[i].textContent == '开始') { startButton = buttons[i]; } if (buttons[i].textContent == '再来一局') { replayButton = buttons[i]; } if (buttons[i].textContent == '保留') { preserveButton = buttons[i]; } } if (startButton) { startButton.click(); } if (replayButton) { replayButton.click(); } if (preserveButton) { preserveButton.click(); } } } // 每隔500ms检查"下一题"按钮是否已经出现 var checkExist = setInterval(function() { var nextPageButton = document.querySelector('.confirm .el-button.el-button--default.el-button--medium.is-round'); if (nextPageButton) { // 如果"下一题"按钮已经出现,添加键盘按键事件监听器,并停止定时器 document.addEventListener('keydown', handleKeyPressForNextPage); clearInterval(checkExist); } }, 500); // 监听DOM变化的函数看是否或出现比赛 function observeDOMChanges() { // 配置observer的选项: 添加或删除的子节点 var config = { childList: true, subtree: true }; // 当DOM发生变化时调用的回调函数 var callback = function(mutationsList, observer) { for(var mutation of mutationsList) { // 如果有子节点被添加 if(mutation.addedNodes.length) { mutation.addedNodes.forEach(function(node) { // 检查该节点是否是你想要的元素 if(node.nodeType === Node.ELEMENT_NODE && node.classList.contains("van-toast") && node.classList.contains("van-toast--middle") && node.classList.contains("van-toast--text")) { var innerDiv = node.querySelector('.van-toast__text'); if(innerDiv && innerDiv.textContent === "比赛已经开始或者这一轮游戏还未结束") { node.style.transition = 'none'; node.style.animation = 'none'; node.style.opacity = '0'; } } }); } } }; // 创建一个observer实例与回调函数关联 var observer = new MutationObserver(callback); // 在整个document上开始观察DOM的变化 observer.observe(document, config); } // 调用上面的函数以开始监听DOM变化 observeDOMChanges(); let elementToChange = document.querySelector('div[data-v-515b103e][style="padding-top: 2rem;"]'); if (elementToChange) { elementToChange.style.height = "500px"; } // 监听按键事件 document.addEventListener('keydown', handleKeyPressForRefresh); document.addEventListener('keydown', handleKeyPressForAnotherSelector); })();