您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Disables Declare War button for protected NAP alliances on World-of-states.net
// ==UserScript== // @name World of States - Fast Protect NaP Members // @namespace http://tampermonkey.net/ // @version 1.7 // @description Disables Declare War button for protected NAP alliances on World-of-states.net // @match https://www.world-of-states.net/* // @grant none // @license MIT // ==/UserScript== (function () { 'use strict'; // List of image filenames used by protected alliances const protectedAllianceImages = [ 'Untitled_design_2.jpg', // GWC 'GB2.JPG', // Golden Balance 'UNSO.png', // UNSO 'tieditagainagain.png' // Immortals (used by 3 different alliances) ]; let currentUrl = location.href; let lastRun = 0; const checkAllianceMatch = () => { const img = document.querySelector('img[src*="alliance"]'); if (!img) return false; const src = img.getAttribute('src'); return protectedAllianceImages.some(filename => src.includes(filename)); }; const modifyDeclareWarButton = () => { const button = [...document.querySelectorAll('a')] .find(link => link.textContent.trim().toLowerCase() === 'declare war'); if (button && !button.classList.contains('modified-by-script')) { button.textContent = "Don't Do It (NAP Member)"; button.style.color = 'red'; button.style.fontWeight = 'bold'; button.style.pointerEvents = 'none'; button.style.opacity = '0.6'; button.classList.add('modified-by-script'); console.log("Declare War button modified."); } }; const triggerUpdate = () => { const now = Date.now(); if (now - lastRun < 200) return; lastRun = now; if (checkAllianceMatch()) { modifyDeclareWarButton(); } }; const observeChanges = () => { const observer = new MutationObserver(triggerUpdate); observer.observe(document.body, { childList: true, subtree: true, }); }; const watchUrlChanges = () => { const check = () => { if (location.href !== currentUrl) { currentUrl = location.href; console.log("URL changed, checking..."); setTimeout(triggerUpdate, 200); } requestAnimationFrame(check); }; requestAnimationFrame(check); }; // Initialize script observeChanges(); watchUrlChanges(); })();