Gimkit Modded File Copier

Adds a button to download and modify game files before saving

  1. // ==UserScript==
  2. // @name Gimkit Modded File Copier
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description Adds a button to download and modify game files before saving
  6. // @author You
  7. // @match *://*/*
  8. // @grant GM_download
  9. // @grant GM_info
  10. // @require https://cdnjs.cloudflare.com/ajax/libs/jszip/3.7.1/jszip.min.js
  11. // @require https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2.0.5/FileSaver.min.js
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. // Function to modify file contents (example for JSON files)
  18. function modifyFileContent(fileName, fileContent) {
  19. if (fileName.endsWith('.json')) {
  20. let json = JSON.parse(fileContent);
  21. // Example modification: add a new property
  22. json.modified = true;
  23. return JSON.stringify(json, null, 2);
  24. }
  25. return fileContent; // No modification for other file types
  26. }
  27.  
  28. // Function to download and modify files
  29. function downloadAndModifyFiles() {
  30. // List of file URLs (replace with actual URLs if needed)
  31. let files = [
  32. { url: 'https://example.com/game-file1.json', name: 'game-file1.json' },
  33. { url: 'https://example.com/game-file2.txt', name: 'game-file2.txt' }
  34. ];
  35.  
  36. const zip = new JSZip();
  37. let fetchPromises = [];
  38.  
  39. files.forEach(file => {
  40. let fetchPromise = fetch(file.url)
  41. .then(response => response.text()) // Use text() to handle JSON and text files
  42. .then(content => {
  43. let modifiedContent = modifyFileContent(file.name, content);
  44. zip.file(file.name, modifiedContent);
  45. });
  46. fetchPromises.push(fetchPromise);
  47. });
  48.  
  49. // Wait for all fetch requests to complete
  50. Promise.all(fetchPromises).then(() => {
  51. // Generate the ZIP file and save it
  52. zip.generateAsync({ type: "blob" })
  53. .then(content => {
  54. saveAs(content, "modded-files.zip");
  55. });
  56. });
  57. }
  58.  
  59. // Add a button to trigger file download and modification
  60. let button = document.createElement('button');
  61. button.textContent = 'Download and Modify Files';
  62. button.style.position = 'fixed';
  63. button.style.top = '10px';
  64. button.style.right = '10px';
  65. button.style.zIndex = '9999';
  66. button.style.padding = '10px';
  67. button.style.backgroundColor = '#007BFF';
  68. button.style.color = '#FFFFFF';
  69. button.style.border = 'none';
  70. button.style.borderRadius = '5px';
  71. button.style.cursor = 'pointer';
  72. document.body.appendChild(button);
  73.  
  74. button.addEventListener('click', downloadAndModifyFiles);
  75. })();

QingJ © 2025

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