您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Display a red square if cameras or guards are down in Big Al's. 1 Api call 2 seconds after you open any page, and every 60 seconds.
当前为
// ==UserScript== // @name Shoplifting alert // @namespace http://torn.city.com.dot.com.com // @version 1.0 // @description Display a red square if cameras or guards are down in Big Al's. 1 Api call 2 seconds after you open any page, and every 60 seconds. // @author Adobi // @match *://*/* // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; // Function to create and display the red square with centered text and a line break function displayRedSquare(apiData) { // Get the values for "camera" and "guard" from the API data const camera = apiData.shoplifting.big_als[0].disabled; const guard = apiData.shoplifting.big_als[1].disabled; if (camera === true || guard === true) { const redSquare = document.createElement('div'); redSquare.style.position = 'fixed'; redSquare.style.left = '0'; redSquare.style.top = '0'; redSquare.style.width = '100px'; redSquare.style.height = '100px'; redSquare.style.backgroundColor = 'red'; redSquare.style.zIndex = '9999'; redSquare.style.display = 'flex'; // Use flexbox for centering // Create a container div for centered text const textContainer = document.createElement('div'); textContainer.style.margin = 'auto'; // Center horizontally textContainer.style.textAlign = 'center'; // Center text textContainer.style.display = 'flex'; textContainer.style.flexDirection = 'column'; // Center vertically // Create text nodes for "camera" and "guard" values const cameraTextNode = document.createTextNode(`Camera: ${camera}`); const lineBreak = document.createElement('br'); const guardTextNode = document.createTextNode(`Guard: ${guard}`); // Append the text nodes and line break to the text container textContainer.appendChild(cameraTextNode); textContainer.appendChild(lineBreak); textContainer.appendChild(guardTextNode); // Append the text container to the red square redSquare.appendChild(textContainer); document.body.appendChild(redSquare); } } // Function to fetch API data and display the red square function fetchAndDisplayData() { fetch('https://api.torn.com/torn/?selections=shoplifting&key=[Key here]') .then(response => response.json()) .then(data => displayRedSquare(data)) .catch(error => console.error('API Error:', error)); } // Initial run after 2 seconds setTimeout(fetchAndDisplayData, 2000); // Repeat every 60 seconds setInterval(fetchAndDisplayData, 60000); })();