// ==UserScript== // @name TicketLink自动刷新预订 // @namespace http://tampermonkey.net/ // @version 1.0 // @description 在指定时间自动刷新页面并点击预订按钮 // @author yoki // @match *://www.ticketlink.co.kr/global/zh/product/* // @grant unsafeWindow // @run-at document-end // ==/UserScript== (()=>{"use strict";function t(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,o=Array(e);nTicketLink 自动预订\n ').concat((f=new Date,y=f.getFullYear(),g=String(f.getMonth()+1).padStart(2,"0"),x=String(f.getDate()).padStart(2,"0"),v=String(f.getHours()).padStart(2,"0"),b=String(f.getMinutes()).padStart(2,"0"),h=String(f.getSeconds()).padStart(2,"0"),w=String(f.getMilliseconds()).padStart(3,"0"),'\n
\n \n
\n \x3c!-- 所有输入框使用相同的样式基础 --\x3e\n
\n \n
\n
\n \n
\n
\n \n
\n
\n
\n ')),'\n
\n \n \n
\n
\n
\n '),document.body.appendChild(t),document.getElementById("start-refresh").addEventListener("click",S),document.getElementById("cancel-refresh").addEventListener("click",I);var f,y,g,x,v,b,h,w}():y&&!x&&(console.log("找到预订按钮,准备点击一次...",y),x=!0,setTimeout((function(){g.showMessage("即将点击预订按钮..."),y.click(),b&&b.disconnect(),g.showMessage("预订按钮已点击")}),3e3))}var b,h=null,w=null;function S(){var t=document.getElementById("refresh-date").value,n=document.getElementById("refresh-time").value,o=document.getElementById("refresh-milliseconds").value,r=document.getElementById("status-message"),i=document.getElementById("countdown");if(!t||!n)return r.textContent="请设置有效的刷新时间",void(r.style.color="red");var a=n.split(":").map(Number),c=a[0]||0,l=a[1]||0,d=a[2]||0,s=parseInt(o)||0,u=e(t.split("-").map(Number),3),p=u[0],m=u[1],f=u[2],y=new Date(p,m-1,f,c,l,d,s),g=new Date;if(y<=g||isNaN(y.getTime()))return r.textContent="请设置一个将来的有效时间",void(r.style.color="red");var x=y.getTime()-g.getTime();r.textContent="将在 ".concat(p,"/").concat(m,"/").concat(f," ").concat(c,":").concat(l,":").concat(d,".").concat(s," 刷新页面"),r.style.color="#008800",h&&clearTimeout(h),w&&clearInterval(w),h=setTimeout((function(){location.reload()}),x),w=setInterval((function(){var t=new Date,e=y.getTime()-t.getTime();if(e<=0)return i.textContent="刷新中...",void clearInterval(w);var n=Math.floor(e/36e5),o=Math.floor(e%36e5/6e4),r=Math.floor(e%6e4/1e3),a=e%1e3;i.textContent="倒计时: ".concat(n,"时 ").concat(o,"分 ").concat(r,"秒 ").concat(a,"毫秒")}),10)}function I(){h&&(clearTimeout(h),h=null),w&&(clearInterval(w),w=null);var t=document.getElementById("status-message"),e=document.getElementById("countdown");t.textContent="自动刷新已取消",t.style.color="#666",e.textContent=""}window.addEventListener("load",v),(b=new MutationObserver(v)).observe(document.body,{childList:!0,subtree:!0})}()})();