Barclay's Library

Import whatever model URLs you need - library that does the heavy lifting

Script này sẽ không được không được cài đặt trực tiếp. Nó là một thư viện cho các script khác để bao gồm các chỉ thị meta // @require https://update.greatest.deepsurf.us/scripts/526336/1588332/Barclay%27s%20Library.js

  1. // ==UserScript==
  2. // @name Barclay's Library
  3. // @namespace https://github.com/onlypuppy7/BarclaysShellShockers/
  4. // @grant none
  5. // @version 1.1.4
  6. // @author onlypuppy7
  7. // @description Import whatever model URLs you need - library that does the heavy lifting
  8. // @match *://*/*
  9. // ==/UserScript==
  10.  
  11. //this library is based off LibertyMutual by onlypuppy7
  12.  
  13. const BARCLAYS = {
  14. modelURLs: [],
  15. ss: null,
  16. H: {},
  17. log: function (...args) { //yeah, i got inspired. what about it?
  18. console.log(
  19. "%c%s",
  20. `color: white; font-weight: bold; background:rgb(0, 85, 128); padding: 2px 6px; border-radius: 5px; margin-right: 5px;`,
  21. `Barclay's`,
  22. ...args
  23. );
  24. },
  25. init: function () { //setup the script injection. separated out to enable users to put the injection code into their own scripts with different loading mechanisms.
  26. let originalReplace = String.prototype.replace;
  27. String.prototype.originalReplace = function() {
  28. return originalReplace.apply(this, arguments);
  29. };
  30.  
  31. let method = "apc"; //options: "Function", "XHR"
  32.  
  33. if (method === "XHR") {
  34. const originalXHROpen = XMLHttpRequest.prototype.open;
  35. const originalXHRGetResponse = Object.getOwnPropertyDescriptor(XMLHttpRequest.prototype, 'response');
  36. let shellshockjs
  37. XMLHttpRequest.prototype.open = function(...args) {
  38. const url = args[1];
  39. if (url && url.includes("js/shellshock.js")) {
  40. shellshockjs = this;
  41. };
  42. originalXHROpen.apply(this, args);
  43. };
  44. Object.defineProperty(XMLHttpRequest.prototype, 'response', {
  45. get: function() {
  46. if (this===shellshockjs) {
  47. BARCLAYS.log("shellshock.js intercepted");
  48. return BARCLAYS.applyBarclays(originalXHRGetResponse.get.call(this));
  49. };
  50. return originalXHRGetResponse.get.call(this);
  51. }
  52. });
  53. } else if (method === "Function") {
  54. const originalFunction = Function.prototype.constructor;
  55. Function.prototype.constructor = function(...args) {
  56. const jsCode = args[0];
  57. if (jsCode && jsCode.includes("(()=>{var ")) {
  58. BARCLAYS.log("shellshock.js intercepted");
  59. return BARCLAYS.applyBarclays(jsCode);
  60. };
  61. return originalFunction.apply(this, args);
  62. };
  63. } else if (method === "apc") {
  64. let _apc = HTMLElement.prototype.appendChild;
  65.  
  66. HTMLElement.prototype.appendChild = function(node) {
  67. if (node.tagName === 'SCRIPT' && node.innerHTML && node.innerHTML.startsWith('(()=>{')) {
  68. node.innerHTML = BARCLAYS.applyBarclays(node.innerHTML);
  69. };
  70. return _apc.call(this, node);
  71. };
  72. };
  73. },
  74. applyBarclays: function (js) {
  75. try {
  76. //VAR STUFF
  77. let F=[];
  78. let functionNames=[];
  79. //scrambled... geddit????
  80. const getScrambled=function(){return Array.from({length: 10}, () => String.fromCharCode(97 + Math.floor(Math.random() * 26))).join('')}
  81. const createAnonFunction=function(name,func){
  82. const funcName=getScrambled();
  83. window[funcName]=func;
  84. F[name]=window[funcName];
  85. functionNames[name]=funcName
  86. };
  87. const fetchTextContent = function(url) {
  88. var xhr = new XMLHttpRequest();
  89. xhr.open('GET', url, false); // make the request synchronous
  90. xhr.send();
  91. if (xhr.status === 200) {
  92. return xhr.responseText;
  93. } else {
  94. console.error("Error fetching text content. Status:", xhr.status);
  95. return null;
  96. };
  97. };
  98. createAnonFunction("BARCLAYS", function(ss) {
  99. BARCLAYS.log("BARCLAYS ACTIVE!");
  100. BARCLAYS.ss = ss;
  101. // window.globalBarclays = ss;
  102. BARCLAYS.replaceModels();
  103. });
  104. let clientKeys;
  105. onlineClientKeys = fetchTextContent("https://raw.githubusercontent.com/StateFarmNetwork/client-keys/main/barclays_latest.json"); //credit: me :D
  106. if (onlineClientKeys == "value_undefined" || onlineClientKeys == null) {
  107. let userInput = prompt('Valid keys could not be retrieved online. Enter keys if you have them. Join the SFNetwork Discord server to generate keys! https://discord.gg/HYJG3jXVJF', '');
  108. if (userInput !== null && userInput !== '') {
  109. alert('Aight, let\'s try this. If it is invalid, it will just crash.');
  110. clientKeys = JSON.parse(userInput);
  111. } else {
  112. alert('You did not enter anything, this is gonna crash lmao.');
  113. };
  114. } else {
  115. clientKeys = JSON.parse(onlineClientKeys);
  116. };
  117. BARCLAYS.H = clientKeys.vars;
  118. BARCLAYS.log(BARCLAYS.H);
  119. let injectionString="";
  120. const modifyJS = function(find,replace) {
  121. let oldJS = js;
  122. js = js.originalReplace(find,replace);
  123. if (oldJS !== js) {
  124. console.log("%c[BARCLAYS] Replacement successful! Injected code: "+replace, 'color: green; font-weight: bold; font-size: 0.6em; text-decoration: italic;');
  125. } else {
  126. console.log("%c[BARCLAYS] Replacement failed! Attempted to replace "+find+" with: "+replace, 'color: red; font-weight: bold; font-size: 0.6em; text-decoration: italic;');
  127. };
  128. };
  129. BARCLAYS.log('%c[BARCLAYS] ATTEMPTING TO START BARCLAYS', 'color: magenta; font-weight: bold; font-size: 1.5em; text-decoration: underline;');
  130. const variableNameRegex = /^[a-zA-Z0-9_$,"]*$/; //prevent adding spooky code
  131. for (let name in BARCLAYS.H) {
  132. deobf = BARCLAYS.H[name];
  133. if (variableNameRegex.test(deobf)) {
  134. injectionString = `${injectionString}${name}: (() => { try { return ${deobf}; } catch (error) { return "value_undefined"; } })(),`;
  135. } else {
  136. alert("Message from the Barclays Devs: WARNING! The keys inputted contain non-variable characters! There is a possibility that this could run code unintended by the Barclays team, although possibly there is also a mistake. Do NOT proceed with using this, and report to the Barclays developers what is printed in the console.");
  137. BARCLAYS.log("REPORT THIS IN THE DISCORD SERVER:", clientKeys);
  138. const crashplease = "balls";
  139. crashplease = "balls2";
  140. };
  141. };
  142. BARCLAYS.log("Barclay's injectionString:", injectionString);
  143. modifyJS(`"Object meshes loaded"),`, `"Object meshes loaded"),window["${functionNames.BARCLAYS}"]({${injectionString}}),`);
  144. // BARCLAYS.log(js);
  145. return js;
  146. } catch (error) {
  147. console.error("Error applying Barclay's:", error);
  148. return js;
  149. };
  150. },
  151. replaceModels: function (modelURLs = BARCLAYS.modelURLs, noLog = false) {
  152. //you can call this function later if you want to replace models again
  153. //if you need to reinstate the original models, you will need to pass in the original mesh URLs
  154. //eg: /models/full/egg.glb
  155.  
  156. function replaceMesh(sourceMesh, targetMesh) {
  157. if (sourceMesh && targetMesh) {
  158. const vertexData = BARCLAYS.ss.VertexData.ExtractFromMesh(sourceMesh);
  159. vertexData.applyToMesh(targetMesh);
  160. if (!noLog) BARCLAYS.log("Mesh geometry replaced successfully!", sourceMesh.id);
  161. } else {
  162. console.error("One of the meshes was not found!");
  163. };
  164. };
  165.  
  166. BARCLAYS.log("Preparing to replace models...", modelURLs);
  167. modelURLs.forEach(function(url) {
  168. BARCLAYS.log("Loading model from URL:", url);
  169. BARCLAYS.ss.SceneLoader.ImportMesh(
  170. "", // Empty string imports all meshes
  171. "", // Empty root URL uses the path provided
  172. url, // Path to GLB file
  173. undefined, // Scene to import into
  174. function (meshes, particleSystems, skeletons, animationGroups) {
  175. BARCLAYS.log(
  176. "meshes loaded:",
  177. meshes
  178. .filter(mesh => mesh.id !== "__root__")
  179. .map(mesh => mesh.id)
  180. );
  181. console.log("particleSystems loaded:", particleSystems);
  182. console.log("skeletons loaded:", skeletons);
  183. console.log("animationGroups loaded:", animationGroups);
  184.  
  185. for (var m = 0; m < meshes.length; m++) {
  186. var mesh2 = meshes[m];
  187. if (mesh2.id !== "__root__") {
  188. mesh2.setEnabled(false);
  189. mesh2.isPickable = false;
  190. mesh2.animations = animationGroups;
  191. let meshInGlobalScene = BARCLAYS.ss.globalScene.getMeshByID(mesh2.id);
  192. if (meshInGlobalScene) {
  193. replaceMesh(mesh2, meshInGlobalScene);
  194. mesh2.animations.forEach((anim, index) => {
  195. let animName = anim.name;
  196. let animInGlobalScene = meshInGlobalScene.getAnimationByName(animName);
  197. if (animInGlobalScene) {
  198. let tempTargeted = anim._targetedAnimations;
  199. tempTargeted.forEach((targeted, index) => {
  200. tempTargeted[index].target = targeted.target;
  201. });
  202. animInGlobalScene._targetedAnimations = tempTargeted;
  203. BARCLAYS.log(`Animation ${index + 1} (${animName}) replaced successfully!`);
  204. };
  205. });
  206. };
  207.  
  208. mesh2.dispose(false, true);
  209. };
  210. };
  211.  
  212. BARCLAYS.log("Meshes replaced successfully!");
  213. },
  214. );
  215. });
  216. },
  217. restoreModels: function () {
  218. BARCLAYS.log("Restoring models...");
  219.  
  220. const models = BARCLAYS.H.meshesToLoad.split(",");
  221.  
  222. //add /models/full/ to the start of each model
  223. const modelURLs = models.map(model => `/models/full/${model.replaceAll('"','')}.glb`);
  224.  
  225. modelURLs.push("/models/map.glb"); //add the map back in, as it's not in full
  226.  
  227. BARCLAYS.replaceModels(modelURLs, true);
  228. },
  229. };
  230.  
  231. BARCLAYS.log("Barclay's Library loaded. Built by onlypuppy7 :>");