您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Spawns multiple iframes on Shift+Click and auto-clicks "Multiplayer" in each. Works in private/incognito mode with separate iframe storage.
当前为
// ==UserScript== // @name Iframe Spawner for territorial.io (Auto-Click) // @namespace Violentmonkey Scripts // @version 3.0 // @description Spawns multiple iframes on Shift+Click and auto-clicks "Multiplayer" in each. Works in private/incognito mode with separate iframe storage. // @author maanimis & Assistant // @match https://territorial.io/* // @grant none // @run-at document-end // @license MIT // ==/UserScript== (function () { "use strict"; document.addEventListener("click", function (event) { if (event.shiftKey && event.button === 0) { // Shift + Left Click event.preventDefault(); runScript(); } }); function runScript() { const MULTIPLIER = +prompt("MULTIPLIER", "2"); if (isNaN(MULTIPLIER) || MULTIPLIER <= 0) return; createIframes(MULTIPLIER); } function createIframes(count) { let container = document.getElementById("iframeContainer"); if (!container) { container = document.createElement("div"); container.id = "iframeContainer"; document.body.innerHTML = ""; // Clear the body for a clean grid document.body.appendChild(container); applyStyles(); } const gridSize = Math.ceil(Math.sqrt(count)); container.style.display = "grid"; container.style.gap = "10px"; container.style.width = "100%"; container.style.height = "100vh"; container.style.padding = "10px"; container.style.boxSizing = "border-box"; container.style.gridTemplateColumns = `repeat(${gridSize}, 1fr)`; container.style.gridTemplateRows = `repeat(${Math.ceil(count / gridSize)}, 1fr)`; for (let i = 0; i < count; i++) { const iframeWrapper = createIframeWrapper(i + 1); container.appendChild(iframeWrapper); } } function createIframeWrapper(index) { const wrapper = document.createElement("div"); wrapper.className = "iframe-wrapper"; wrapper.style.position = "relative"; wrapper.style.width = "100%"; wrapper.style.height = "100%"; const controls = createControls(wrapper); const iframe = createIframe(index); wrapper.appendChild(controls); wrapper.appendChild(iframe); return wrapper; } function createIframe(index) { const iframe = document.createElement("iframe"); iframe.id = `frame${index}`; iframe.src = "https://territorial.io/"; iframe.style.width = "100%"; iframe.style.height = "100%"; iframe.style.border = "2px solid white"; iframe.style.borderRadius = "10px"; iframe.style.background = "#000"; iframe.style.transition = "transform 0.2s ease-in-out"; iframe.onmouseover = () => (iframe.style.transform = "scale(1.02)"); iframe.onmouseout = () => (iframe.style.transform = "scale(1)"); iframe.onload = () => { overrideStorage(iframe, index); autoClickMultiplayer(iframe, index); // Auto-click the button }; return iframe; } function autoClickMultiplayer(iframe, index) { let attempts = 0; const maxAttempts = 50; // Try for 10 seconds (50 * 200ms) const intervalId = setInterval(() => { if (attempts >= maxAttempts) { console.error(`[Iframe Spawner] Timed out waiting for Multiplayer button in iframe ${index}.`); clearInterval(intervalId); return; } const iframeDoc = iframe.contentDocument || iframe.contentWindow.document; if (iframeDoc) { // Find the button by its text content, which is more reliable than styles const buttons = iframeDoc.querySelectorAll('button'); const multiplayerButton = Array.from(buttons).find(btn => btn.innerText.includes('Multiplayer')); if (multiplayerButton) { console.log(`[Iframe Spawner] Multiplayer button found in iframe ${index}. Clicking...`); multiplayerButton.click(); clearInterval(intervalId); // Stop checking once clicked } } attempts++; }, 200); // Check every 200ms } function createControls(wrapper) { const controls = document.createElement("div"); controls.className = "controls"; controls.style.position = "absolute"; controls.style.top = "5px"; controls.style.right = "5px"; controls.style.zIndex = "10"; controls.style.display = "flex"; controls.style.gap = "5px"; function createButton(text, onClick, color) { const button = document.createElement("button"); button.innerText = text; button.style.background = color; button.style.border = "none"; button.style.padding = "5px"; button.style.cursor = "pointer"; button.style.color = "white"; button.style.borderRadius = "5px"; button.onclick = onClick; return button; } const closeButton = createButton("✖", () => wrapper.remove(), "red"); const maxButton = createButton("⛶", () => toggleMaximize(wrapper, maxButton), "green"); controls.appendChild(closeButton); controls.appendChild(maxButton); return controls; } function toggleMaximize(wrapper, button) { const isMaximized = wrapper.style.position === "fixed"; if (isMaximized) { wrapper.style.position = "relative"; wrapper.style.width = "100%"; wrapper.style.height = "100%"; wrapper.style.zIndex = "1"; button.innerText = "⛶"; } else { wrapper.style.position = "fixed"; wrapper.style.top = "0"; wrapper.style.left = "0"; wrapper.style.width = "100vw"; wrapper.style.height = "100vh"; wrapper.style.zIndex = "999"; button.innerText = "🗗"; } } function overrideStorage(iframe, index) { try { if (iframe.contentWindow) { iframe.contentWindow.localStorage = (() => { let storage = {}; return { setItem: (key, value) => (storage[key] = value), getItem: (key) => storage[key] || null, removeItem: (key) => delete storage[key], clear: () => (storage = {}), key: (i) => Object.keys(storage)[i] || null, get length() { return Object.keys(storage).length; } }; })(); } } catch (e) { console.error(`[Iframe Spawner] Could not override storage for iframe ${index}:`, e); } } function applyStyles() { document.body.style.margin = "0"; document.body.style.backgroundColor = "#222"; document.body.style.overflow = "hidden"; } })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址