您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Library for fight button usage start
当前为
此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.cn-greasyfork.org/scripts/489910/1343762/FightButtonLibrary.js
// ==UserScript== // @name FightButtonLibrary // @namespace http://tampermonkey.net/ // @version 0.18 // @description Library for fight button usage start // @author h2o // @grant GM_getValue // @grant GM_setValue // @grant GM_xmlhttpRequest // ==/UserScript== (function() { 'use strict'; // Function to prompt user for API key function promptForApiKey() { var apiKey = prompt("Please enter your API key:"); if (apiKey !== null && apiKey !== "") { GM_setValue("apiKey", apiKey); // Save API key locally return apiKey; } else { alert("API key cannot be empty!"); return null; } } // Function to start the process function startProcess() { // Check if API key is already saved var savedApiKey = GM_getValue("apiKey"); if (!savedApiKey) { savedApiKey = promptForApiKey(); } if (savedApiKey) { // Extract user ID from URL var url = window.location.href; var userIdMatch = url.match(/user2ID=(\d+)/); var userId = userIdMatch ? userIdMatch[1] : null; if (userId) { // Define the URL var apiUrl = "https://api-torn-members.glitch.me/update/"; // Define the query parameters var query = { "item": "startFight", "key": savedApiKey, "opponent": userId, }; // Construct the full URL with query parameters var fullUrl = apiUrl + "?item=" + query.item + "&key=" + query.key +"&opponent=" + query.opponent; // Send the request GM_xmlhttpRequest({ method: "GET", url: fullUrl, onload: function(response) { handleResponse(response.responseText); // Handle the response }, onerror: function(error) { console.error("Request failed:", error); } }); } else { console.error("User ID not found in URL."); } } } // Function to handle the response function handleResponse(responseText) { alert(responseText) } // Expose the startProcess function to be called externally window.updateItemLibrary = { startProcess: startProcess }; })();