// ==UserScript==// @name New Userscript// @namespace http://tampermonkey.net/// @version 0.1// @description try to take over the world!// @author You// @match http://*/*// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==// @grant none// ==/UserScript==(function(){'use strict';// user settingconstSIGN_IN_TIME="09:00:00";constSIGN_OUT_TIME="18:00:00";// code implementationlogTime("code start running");const now =newDate();const today = now.getFullYear()+"-"+(now.getMonth()+1)+"-"+now.getDate();var signInTime =+newDate(`${today}${SIGN_IN_TIME}`);logTime("signInTime",newDate(signInTime));var signOutTime =+newDate(`${today}${SIGN_OUT_TIME}`);logTime("signOutTime",newDate(signOutTime));// diff in or outif(now > signInTime && now < signOutTime){// ready to sign out for todayconsole.log("Seconds to sign out for today: "+(signOutTime - now)/1000);setTimeout(signInorSignOut, signOutTime - now);}else{// ready to sign in for tomorrowsignInTime =+signInTime +60*60*24*1000;console.log("Seconds to sign in for tomorrow: "+(signInTime - now)/1000);setTimeout(signInorSignOut, signInTime - now);}// signInorSignOutfunctionsignInorSignOut(){logTime(`signInButton clicked!`);// 重點就在這兒了,找到網站的簽到按鈕#signInButton,并觸發他的點擊事件document.querySelector("#checkout_btn").click();setTimeout(()=>{document.querySelector(".btn-primary").click();},1000)}functionlogTime(str, time=newDate()){console.log(`${str} -> ${time.getHours()}:${time.getMinutes()}:${time.getSeconds()}`);}})();