您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Alerts you when you want to fly but an OC is about to start.
当前为
// ==UserScript== // @name Flying OC Alert // @namespace http://tampermonkey.net/ // @version 0.2 // @description Alerts you when you want to fly but an OC is about to start. // @author NichtGersti [3380912] // @license MIT // @match https://www.torn.com/page.php?sid=travel // @icon https://www.google.com/s2/favicons?sz=64&domain=torn.com // ==/UserScript== //TODO: Options (function() { 'use strict'; let apiKey = "" //Minimal access or above! let maxWarningHours = 10 let confirmMathQuestion = true let confirmPrompt = false let confirmMessage = "continue" let ocUrl = "https://api.torn.com/v2/user/?selections=organizedcrime&key={apiKey}".replace("{apiKey}", apiKey) fetch(ocUrl).then( response => { if (response.ok) { return response.json(); } throw new Error('Something went wrong'); }) .then( result => { if (result.error) { alert(`Error: ${result.error.code}\n${result.error.error}`) return } let infoOc = result.organizedCrime let totalSeconds = infoOc.ready_at - Math.floor(Date.now() / 1000) //if (totalSeconds / 3600 > 10) return let days = Math.floor(totalSeconds / 86400) % 24 let hours = Math.floor(totalSeconds / 3600) % 60 let minutes = Math.floor(totalSeconds / 60) % 60 let seconds = totalSeconds % 60 let timeString = "" if (totalSeconds > 86400) timeString += `${(days < 10) ? "0" : ""}${days}:` if (totalSeconds > 3600) timeString += `${(hours < 10) ? "0" : ""}${hours}:` if (totalSeconds > 60) timeString += `${(minutes < 10) ? "0" : ""}${minutes}:` timeString += `${(seconds < 10) ? "0" : ""}${seconds}` if (totalSeconds < 60) timeString = `${(seconds < 10) ? "0" : ""}${seconds} seconds` if (confirmMathQuestion) { let randomNumber1 = Math.ceil((Math.random() * 50)) let randomNumber2 = Math.ceil((Math.random() * 50)) let correctAnswer = (randomNumber1 + randomNumber2).toString() let message while (message != correctAnswer) message = prompt(`Your Organzied Crime is about to start:\n${timeString}\nSolve "${randomNumber1} + ${randomNumber2}" to continue.`) } else if(confirmPrompt) { let message while (message != confirmMessage) message = prompt(`Your Organzied Crime is about to start:\n${timeString}\nWrite "${confirmMessage}" to continue.`) } else alert(`Your Organzied Crime is about to start:\n${timeString}`) }) .catch(error => console.log(error)) })();