// ==UserScript== // @name Dahlia 12:00:100 // @namespace http://tampermonkey.net/ // @version 0.3 // @description Automatically refresh the page and click a specified button, starting at 12:00:100 PM // @match https://www.cotaiticketing.com/shows/hinscheung2024.html // @grant none // ==/UserScript== (function() { 'use strict'; const buttonTexts = ["Buy Now", "立即购票", "立即購票"]; let refreshCount = 0; // 检查当前时间是否达到12:00:100 function shouldStart() { const now = new Date(); const startHour = 12; const startMinute = 0; const startSecond = 0; const startMillisecond = 100; return now.getHours() === startHour && now.getMinutes() === startMinute && now.getSeconds() === startSecond && now.getMilliseconds() >= startMillisecond; } function checkForButton() { for (let text of buttonTexts) { let button = Array.from(document.querySelectorAll('button, a')).find(el => el.textContent.includes(text)); if (button) { button.click(); console.log(`Clicked button with text: "${text}"`); return true; } } return false; } function startPolling() { const intervalId = setInterval(() => { refreshCount++; // 每10秒更新一次控制台中的刷新次数 if (refreshCount % 1000 === 0) { console.log(`Page refreshed ${refreshCount} times`); } if (checkForButton()) { clearInterval(intervalId); console.log('Button found and clicked. Stopping polling.'); } else { // 自动刷新页面 location.reload(); } }, 10); // 每隔10毫秒检查一次 } // 定时检查是否到达12:00:100 const checkTimeInterval = setInterval(() => { if (shouldStart()) { clearInterval(checkTimeInterval); // 到达时间后停止时间检查 startPolling(); // 开始执行轮询操作 console.log('Starting the refresh and click process.'); } else { console.log('Waiting for 12:00:100 PM...'); } }, 1); // 每毫秒检查一次时间 })();