Utilify Webpack

Gentle Webpack for Utilify development.

当前为 2024-08-28 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Utilify Webpack
  3. // @namespace discord.gg/C2ZJCZXKTu
  4. // @version 1.1
  5. // @description Gentle Webpack for Utilify development.
  6. // @author Vin
  7. // @match *://www.kogama.com/*
  8. // @grant none
  9. // ==/UserScript==
  10. (function() {
  11. 'use strict';
  12.  
  13. function formatTimestamp(timestamp) {
  14. const date = new Date(timestamp);
  15. const options = {
  16. day: '2-digit',
  17. month: '2-digit',
  18. year: 'numeric',
  19. hour: '2-digit',
  20. minute: '2-digit',
  21. timeZoneName: 'short'
  22. };
  23. return date.toLocaleString('en-GB', options);
  24. }
  25.  
  26. function webpackInjected() {
  27. console.log("%cWebpack Injected Successfully! 🎉", "color: #FF69B4; font-weight: bold; font-size: 16px;");
  28. }
  29.  
  30. function getSelfCSS() {
  31. const styles = Array.from(document.styleSheets)
  32. .filter(sheet => !sheet.href || sheet.href.startsWith(window.location.origin))
  33. .reduce((acc, sheet) => {
  34. try {
  35. const rules = Array.from(sheet.cssRules);
  36. rules.forEach(rule => {
  37. if (rule instanceof CSSStyleRule) {
  38. acc.push(rule.cssText);
  39. }
  40. });
  41. } catch (e) {
  42. console.warn('Could not access CSS rules from stylesheet:', e);
  43. }
  44. return acc;
  45. }, []);
  46.  
  47. return styles;
  48. }
  49.  
  50. function displaySelfCSS(styles) {
  51. console.groupCollapsed("%cCustom CSS Styles", "color: #FFB6C1; font-weight: bold; font-size: 14px;");
  52. styles.forEach((cssText, index) => {
  53. console.groupCollapsed(`%cStyle ${index + 1}`, "color: #FF69B4; font-weight: bold; font-size: 12px;");
  54. console.log(`%c${cssText}`, "color: #FFF;");
  55. console.groupEnd();
  56. });
  57. console.groupEnd();
  58. }
  59.  
  60. function reloadUtilify() {
  61. console.clear();
  62. webpackInjected();
  63. Object.keys(window.utilify).forEach(command => {
  64. if (typeof window.utilify[command] === 'function') {
  65. console.log(`%cModule ${command} has been reloaded & injected`, "color: #32CD32; font-weight: bold;");
  66. }
  67. });
  68. }
  69.  
  70. window.utilify = {
  71. finduser: function(UID) {
  72. const url = `https://www.kogama.com/profile/${UID}`;
  73. fetch(url, { method: 'GET' })
  74. .then(response => response.text())
  75. .then(html => {
  76. const parser = new DOMParser();
  77. const doc = parser.parseFromString(html, 'text/html');
  78. const scripts = Array.from(doc.getElementsByTagName('script'));
  79. let userData = null;
  80.  
  81. scripts.forEach(script => {
  82. const content = script.innerHTML;
  83. if (content.includes('options.bootstrap')) {
  84. const match = content.match(/options\.bootstrap\s*=\s*(\{[\s\S]*?\});/);
  85. if (match && match[1]) {
  86. try {
  87. userData = JSON.parse(match[1]);
  88. } catch (e) {
  89. console.error('Error parsing user data:', e);
  90. }
  91. }
  92. }
  93. });
  94.  
  95. if (userData && userData.object) {
  96. const obj = userData.object;
  97. console.groupCollapsed(`%cUser Data for UID: ${UID}`, "color: #D8BFD8; font-weight: bold; font-size: 14px;");
  98. console.log("%cUsername: %c" + obj.username, "color: #FFB6C1; font-weight: bold;", "color: #E6E6FA;");
  99. console.log("%cDescription: %c" + obj.description, "color: #FFB6C1; font-weight: bold;", "color: #E6E6FA;");
  100. console.log("%cLevel: %c" + obj.level, "color: #FFB6C1; font-weight: bold;", "color: #E6E6FA;");
  101. console.log("%cXP: %c" + obj.xp, "color: #FFB6C1; font-weight: bold;", "color: #E6E6FA;");
  102. console.log("%cLevel Progress: %c" + obj.level_progress + "%", "color: #FFB6C1; font-weight: bold;", "color: #E6E6FA;");
  103. console.log("%cGold: %c" + obj.gold, "color: #FFB6C1; font-weight: bold;", "color: #E6E6FA;");
  104. console.log("%cSilver: %c" + obj.silver, "color: #FFB6C1; font-weight: bold;", "color: #E6E6FA;");
  105. console.log("%cRanking: %c" + obj.leaderboard_rank, "color: #FFB6C1; font-weight: bold;", "color: #E6E6FA;");
  106. console.log("%cFriends: %c" + (obj.friend_count > 0 ? obj.friend_count : "Anti-social :("), "color: #FFB6C1; font-weight: bold;", "color: #E6E6FA;");
  107. console.log("%cLast Online: %c" + formatTimestamp(obj.last_ping), "color: #FFB6C1; font-weight: bold;", "color: #E6E6FA;");
  108. console.log("%cAccount Created: %c" + formatTimestamp(obj.created), "color: #FFB6C1; font-weight: bold;", "color: #E6E6FA;");
  109. console.groupEnd();
  110. } else {
  111. console.log("%cNo user object data found for UID:", "color: #F44336; font-weight: bold;", UID);
  112. }
  113. })
  114. .catch(error => {
  115. console.error("Failed to fetch user data:", error);
  116. });
  117. },
  118. credits: function() {
  119. console.groupCollapsed("%cUtilify Credits", "color: #D8BFD8; font-weight: bold; font-size: 14px;");
  120. console.log("%cMain Developer: %cSimon", "color: #FFB6C1; font-weight: bold;", "color: #E6E6FA;");
  121. console.log("%cLogistics: %cAwoi, v7xp", "color: #FFB6C1; font-weight: bold;", "color: #E6E6FA;");
  122. console.log("%cBug Hunters: %cUXNU, TUNA, RAPTOR, FLAVIUS", "color: #FFB6C1; font-weight: bold;", "color: #E6E6FA;");
  123. console.log("%cAdditional Credits: %cSNOWY, IDEALISM", "color: #FFB6C1; font-weight: bold;", "color: #E6E6FA;");
  124. console.log("%cWebpackVersion: %c1.1", "color: #FFB6C1; font-weight: bold;", "color: #E6E6FA;");
  125. console.log("%cDate: %cAugust 2024", "color: #FFB6C1; font-weight: bold;", "color: #E6E6FA;");
  126. console.groupEnd();
  127. },
  128. discord: function() {
  129. console.groupCollapsed("%cJoin Us on Discord", "color: #D8BFD8; font-weight: bold; font-size: 14px;");
  130. console.log("%cDiscord Invite: %cAVAILABLE_SOON", "color: #FFB6C1; font-weight: bold;", "color: #E6E6FA;");
  131. console.groupEnd();
  132. },
  133. webpack: function() {
  134. console.groupCollapsed("%cWebpack Status", "color: #D8BFD8; font-weight: bold; font-size: 14px;");
  135. console.log("%cWebpack Status: %cReady", "color: #FFB6C1; font-weight: bold;", "color: #E6E6FA;");
  136. console.groupCollapsed("%cAvailable Commands", "color: #D8BFD8; font-weight: bold; font-size: 12px;");
  137. console.log("%cutilify.finduser(UID): %cFetches and displays user data for the given UID", "color: #FFB6C1; font-weight: bold;", "color: #E6E6FA;");
  138. console.log("%cutilify.credits(): %cDisplays credits and acknowledgments", "color: #FFB6C1; font-weight: bold;", "color: #E6E6FA;");
  139. console.log("%cutilify.discord(): %cShows the Discord invite link", "color: #FFB6C1; font-weight: bold;", "color: #E6E6FA;");
  140. console.groupEnd();
  141. console.groupEnd();
  142. },
  143. wemetinseptember: function() {
  144. console.groupCollapsed("%cSpecial Message", "color: #D8BFD8; font-weight: bold; font-size: 14px;");
  145. console.log("%cThis command is meant for somebody awesome. If you found it, you are either the one I aim for or someone that just knows a lot. Either way, I hope you're okay. I will always be willing to help you out! You will always matter even if you hate the fact I breathe.", "color: #FFB6C1; font-weight: bold;");
  146. console.groupEnd();
  147. },
  148. selfCSS: function() {
  149. const styles = getSelfCSS();
  150. displaySelfCSS(styles);
  151. },
  152. reload: reloadUtilify // New reload command
  153. };
  154.  
  155. setTimeout(() => {
  156. console.clear();
  157. }, 2500);
  158. setTimeout(() => {
  159. webpackInjected();
  160. }, 4100);
  161.  
  162. })();