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.1
// @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==
(async function() {
'use strict';
let apiKey = ""
let maxWarningHours = 10
let confirmPrompt = true
let confirmMessage = "continue"
let ocUrl = "https://api.torn.com/v2/user/?selections=organizedcrime&key={apiKey}".replace("{apiKey}", apiKey)
let infoOc = (await fetch(ocUrl).then(res => res.json())).organizedCrime
if (infoOc.status == "Planning") {
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
if (confirmPrompt) {
let message
while (message != confirmMessage) message = prompt(`Your Organzied Crime is about to be initiated:\n${days}:${hours}:${minutes}:${seconds}\nWrite "${confirmMessage}" to continue.`)
} else alert(`Your Organzied Crime is about to be initiated:\n${days}:${hours}:${minutes}:${seconds}`)
}
})();