Iframe Spawner-territorial.io

Spawns multiple iframes when Shift + Left Click is pressed. Works in private/incognito mode and allows multi-account usage with separate iframe storage.

  1. // ==UserScript==
  2. // @name Iframe Spawner-territorial.io
  3. // @namespace Violentmonkey Scripts
  4. // @version 2.0
  5. // @description Spawns multiple iframes when Shift + Left Click is pressed. Works in private/incognito mode and allows multi-account usage with separate iframe storage.
  6. // @author maanimis
  7. // @match https://territorial.io/*
  8. // @grant none
  9. // @run-at document-end
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function () {
  14. "use strict";
  15.  
  16. document.addEventListener("click", function (event) {
  17. if (event.shiftKey && event.button === 0) { // Shift + Left Click
  18. event.preventDefault();
  19. runScript();
  20. }
  21. });
  22.  
  23. function runScript() {
  24. const MULTIPLIER = +prompt("MULTIPLIER", "2");
  25. const URL = "https://territorial.io/";
  26.  
  27. function createIframes(count) {
  28. let container = document.getElementById("iframeContainer");
  29. if (!container) {
  30. container = document.createElement("div");
  31. container.id = "iframeContainer";
  32. document.body.innerHTML = "";
  33. document.body.appendChild(container);
  34. applyStyles();
  35. }
  36.  
  37. const gridSize = Math.ceil(Math.sqrt(count));
  38. container.style.display = "grid";
  39. container.style.gap = "10px";
  40. container.style.width = "100%";
  41. container.style.height = "100vh";
  42. container.style.padding = "10px";
  43. container.style.gridTemplateColumns = `repeat(${gridSize}, 1fr)`;
  44. container.style.gridTemplateRows = `repeat(${Math.ceil(count / gridSize)}, 1fr)`;
  45.  
  46. for (let i = 0; i < count; i++) {
  47. const iframeWrapper = createIframeWrapper(i + 1);
  48. container.appendChild(iframeWrapper);
  49. }
  50. }
  51.  
  52. function createIframeWrapper(index) {
  53. const wrapper = document.createElement("div");
  54. wrapper.className = "iframe-wrapper";
  55. wrapper.style.position = "relative";
  56. wrapper.style.width = "100%";
  57. wrapper.style.height = "100%";
  58.  
  59. const controls = createControls(wrapper, index);
  60. const iframe = createIframe(index);
  61.  
  62. wrapper.appendChild(controls);
  63. wrapper.appendChild(iframe);
  64.  
  65. return wrapper;
  66. }
  67.  
  68. function createIframe(index) {
  69. const iframe = document.createElement("iframe");
  70. iframe.id = `frame${index}`;
  71. iframe.src = URL;
  72. iframe.style.width = "100%";
  73. iframe.style.height = "100%";
  74. iframe.style.border = "2px solid white";
  75. iframe.style.borderRadius = "10px";
  76. iframe.style.background = "#000";
  77. iframe.style.transition = "transform 0.2s ease-in-out";
  78. iframe.onmouseover = () => (iframe.style.transform = "scale(1.02)");
  79. iframe.onmouseout = () => (iframe.style.transform = "scale(1)");
  80. iframe.onload = () => overrideStorage(iframe, index);
  81. return iframe;
  82. }
  83.  
  84. function createControls(wrapper, index) {
  85. const controls = document.createElement("div");
  86. controls.className = "controls";
  87. controls.style.position = "absolute";
  88. controls.style.top = "5px";
  89. controls.style.right = "5px";
  90. controls.style.zIndex = "10";
  91. controls.style.display = "flex";
  92. controls.style.gap = "5px";
  93.  
  94. function createButton(text, onClick, color) {
  95. const button = document.createElement("button");
  96. button.innerText = text;
  97. button.style.background = color;
  98. button.style.border = "none";
  99. button.style.padding = "5px";
  100. button.style.cursor = "pointer";
  101. button.style.color = "white";
  102. button.style.borderRadius = "5px";
  103. button.onclick = onClick;
  104. return button;
  105. }
  106.  
  107. const closeButton = createButton("✖", () => wrapper.remove(), "red");
  108. const maxButton = createButton("⛶", () => toggleMaximize(wrapper, maxButton), "green");
  109.  
  110. controls.appendChild(closeButton);
  111. controls.appendChild(maxButton);
  112.  
  113. return controls;
  114. }
  115.  
  116. function toggleMaximize(wrapper, button) {
  117. const isMaximized = wrapper.style.position === "fixed";
  118.  
  119. if (isMaximized) {
  120. wrapper.style.position = "relative";
  121. wrapper.style.width = "100%";
  122. wrapper.style.height = "100%";
  123. wrapper.style.zIndex = "1";
  124. button.innerText = "⛶";
  125. } else {
  126. wrapper.style.position = "fixed";
  127. wrapper.style.top = "0";
  128. wrapper.style.left = "0";
  129. wrapper.style.width = "100vw";
  130. wrapper.style.height = "100vh";
  131. wrapper.style.zIndex = "999";
  132. button.innerText = "🗗";
  133. }
  134. }
  135.  
  136. function overrideStorage(iframe, index) {
  137. iframe.contentWindow.localStorage = (() => {
  138. let storage = {};
  139. return {
  140. setItem: (key, value) => (storage[key] = value),
  141. getItem: (key) => storage[key] || null,
  142. removeItem: (key) => delete storage[key],
  143. clear: () => (storage = {}),
  144. };
  145. })();
  146. }
  147.  
  148. function applyStyles() {
  149. document.documentElement.style.setProperty("--gap", "10px");
  150. document.documentElement.style.setProperty("--border-color", "#fff");
  151. document.documentElement.style.setProperty("--background-color", "#222");
  152.  
  153. document.body.style.display = "flex";
  154. document.body.style.justifyContent = "center";
  155. document.body.style.alignItems = "center";
  156. document.body.style.height = "100vh";
  157. document.body.style.backgroundColor = "var(--background-color)";
  158. document.body.style.overflow = "hidden";
  159. }
  160.  
  161. createIframes(MULTIPLIER);
  162. }
  163. })();
  164.  

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址