BlockadeFarm

Simplifies the process of extracting images from Blockadelabs skybox generator.

  1. // ==UserScript==
  2. // @name BlockadeFarm
  3. // @namespace https://github.com/onlypuppy7/
  4. // @version 1.0
  5. // @description Simplifies the process of extracting images from Blockadelabs skybox generator.
  6. // @author onlypuppy7
  7. // @match https://skybox.blockadelabs.com/*
  8. // @license GPL-3.0
  9. // @grant none
  10. // @run-at document-body
  11. // ==/UserScript==
  12.  
  13. (function () {
  14. 'use strict';
  15.  
  16. const originalCreateObjectURL = URL.createObjectURL;
  17. const blobItems = [];
  18. const pendingBlobItems = [];
  19. let menuCreated = false;
  20.  
  21. URL.createObjectURL = function (blob) {
  22. const blobUrl = originalCreateObjectURL.call(this, blob);
  23. console.log(`[Blob] Created blob URL: ${blobUrl}`, blob);
  24.  
  25. if (!menuCreated) {
  26. pendingBlobItems.push({ blob, blobUrl });
  27. } else {
  28. addBlobToMenu(blob, blobUrl);
  29. }
  30.  
  31. return blobUrl;
  32. };
  33.  
  34. function createMenu() {
  35. const menu = document.createElement('div');
  36. menu.id = 'blobMenu';
  37. menu.style.position = 'fixed';
  38. menu.style.top = '10%';
  39. menu.style.right = '10px';
  40. menu.style.zIndex = '10000';
  41. menu.style.backgroundColor = '#FFF';
  42. menu.style.border = '1px solid #CCC';
  43. menu.style.borderRadius = '8px';
  44. menu.style.padding = '10px';
  45. menu.style.width = '300px';
  46. menu.style.boxShadow = '0 4px 6px rgba(0, 0, 0, 0.1)';
  47. menu.style.maxHeight = '80%';
  48. menu.style.overflowY = 'auto';
  49.  
  50. const title = document.createElement('h3');
  51. title.textContent = 'BlockadeFarm by onlypuppy7';
  52. title.style.margin = '0 0 10px 0';
  53. title.style.fontSize = '16px';
  54. title.style.color = '#333';
  55. title.style.textAlign = 'center';
  56.  
  57. menu.appendChild(title);
  58.  
  59. const toolsLabel = document.createElement('h3');
  60. toolsLabel.textContent = 'Tools:';
  61. toolsLabel.style.margin = '0 0 10px 0';
  62. toolsLabel.style.fontSize = '16px';
  63. toolsLabel.style.color = '#333';
  64. toolsLabel.style.textAlign = 'center';
  65.  
  66. menu.appendChild(toolsLabel);
  67.  
  68. const resetButtonContainer = document.createElement('div');
  69. resetButtonContainer.style.marginBottom = '5px';
  70. resetButtonContainer.style.display = 'flex';
  71. resetButtonContainer.style.justifyContent = 'center';
  72.  
  73. const resetButton = document.createElement('button');
  74. resetButton.textContent = 'Reset Available Generations';
  75. resetButton.style.backgroundColor = '#FF5733';
  76. resetButton.style.color = '#FFF';
  77. resetButton.style.border = 'none';
  78. resetButton.style.padding = '2px 2px';
  79. resetButton.style.borderRadius = '5px';
  80. resetButton.style.cursor = 'pointer';
  81. resetButton.style.width = '90%';
  82.  
  83. resetButton.onclick = () => {
  84. delete localStorage["available-generations"];
  85. location.reload(true);
  86. };
  87.  
  88. resetButtonContainer.appendChild(resetButton);
  89. menu.appendChild(resetButtonContainer);
  90.  
  91. const linksContainer = document.createElement('div');
  92. linksContainer.id = 'linksContainer';
  93. menu.appendChild(linksContainer);
  94.  
  95. createMenuLink(linksContainer, "Convert To Cubemap", "https://jaxry.github.io/panorama-to-cubemap/");
  96.  
  97. const blobsLabel = document.createElement('h3');
  98. blobsLabel.textContent = 'Detected Skyboxes:';
  99. blobsLabel.style.margin = '0 0 10px 0';
  100. blobsLabel.style.fontSize = '16px';
  101. blobsLabel.style.color = '#333';
  102. blobsLabel.style.textAlign = 'center';
  103.  
  104. menu.appendChild(blobsLabel);
  105.  
  106. const container = document.createElement('div');
  107. container.id = 'blobContainer';
  108. menu.appendChild(container);
  109.  
  110. document.body.appendChild(menu);
  111.  
  112. menuCreated = true;
  113.  
  114. processPendingBlobs();
  115.  
  116. const infoLabel = document.createElement('h3');
  117. infoLabel.textContent = 'Enjoy!';
  118. infoLabel.style.margin = '0 0 10px 0';
  119. infoLabel.style.fontSize = '16px';
  120. infoLabel.style.color = '#333';
  121. infoLabel.style.textAlign = 'center';
  122.  
  123. menu.appendChild(infoLabel);
  124. };
  125.  
  126. function addBlobToMenu(blob, blobUrl) {
  127. const extension = blob.type.split('/')[2] || 'bin';
  128. const fileName = `panorama.${extension}`;
  129.  
  130. if (blobItems.find((item) => item.blobUrl === blobUrl)) return;
  131.  
  132. blobItems.push({ blob, blobUrl });
  133.  
  134. createMenuLink(document.getElementById('blobContainer'), fileName, blobUrl);
  135. }
  136.  
  137. function createMenuLink(container, labelName, url) {
  138. const linkEntry = document.createElement('div');
  139. linkEntry.style.display = 'flex';
  140. linkEntry.style.justifyContent = 'space-between';
  141. linkEntry.style.alignItems = 'center';
  142. linkEntry.style.marginBottom = '8px';
  143. linkEntry.style.borderBottom = '1px solid #EEE';
  144. linkEntry.style.paddingBottom = '5px';
  145.  
  146. const link = document.createElement('a');
  147. link.textContent = labelName;
  148. link.href = url;
  149. link.download = labelName;
  150. link.style.color = '#007BFF';
  151. link.style.textDecoration = 'none';
  152. link.style.overflow = 'hidden';
  153. link.style.textOverflow = 'ellipsis';
  154. link.style.whiteSpace = 'nowrap';
  155. link.target = '_blank';
  156.  
  157. linkEntry.appendChild(link);
  158. container.appendChild(linkEntry);
  159. };
  160.  
  161. function processPendingBlobs() {
  162. while (pendingBlobItems.length > 0) {
  163. const { blob, blobUrl } = pendingBlobItems.shift();
  164. addBlobToMenu(blob, blobUrl);
  165. }
  166. }
  167.  
  168. const observer = new MutationObserver(() => {
  169. if (!document.getElementById('blobMenu')) {
  170. menuCreated = false;
  171. createMenu();
  172. }
  173. });
  174.  
  175. observer.observe(document.body, { childList: true, subtree: true });
  176.  
  177. createMenu();
  178.  
  179. console.log("Userscript to intercept blob requests and add a download menu is running...");
  180. })();

QingJ © 2025

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