Discord UID Extractor with Format Toggle

Extract UIDs from Discord avatars and display them with format toggle

  1. // ==UserScript==
  2. // @name Discord UID Extractor with Format Toggle
  3. // @namespace http://tampermonkey.net/
  4. // @version 2.8
  5. // @description Extract UIDs from Discord avatars and display them with format toggle
  6. // @author AARR
  7. // @match https://discord.com/*
  8. // @grant none
  9. // @license You can modify as long as you credit me ©AARR DEV
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. let observer;
  16. let isBoxVisible = false;
  17. let initialBoxPosition = { x: 80, y: 120 };
  18. let copyFormat = 'newline';
  19.  
  20. function makeElementDraggable(el) {
  21. el.onmousedown = function(event) {
  22. event.preventDefault();
  23.  
  24. let shiftX = event.clientX - el.getBoundingClientRect().left;
  25. let shiftY = event.clientY - el.getBoundingClientRect().top;
  26.  
  27. function moveAt(pageX, pageY) {
  28. const newX = Math.min(Math.max(0, pageX - shiftX), window.innerWidth - el.offsetWidth);
  29. const newY = Math.min(Math.max(0, pageY - shiftY), window.innerHeight - el.offsetHeight);
  30.  
  31. el.style.left = newX + 'px';
  32. el.style.top = newY + 'px';
  33.  
  34. const backgroundX = initialBoxPosition.x - newX;
  35. const backgroundY = initialBoxPosition.y - newY;
  36. el.style.backgroundPosition = `${backgroundX}px ${backgroundY}px`;
  37. }
  38.  
  39. function onMouseMove(event) {
  40. moveAt(event.pageX, event.pageY);
  41. }
  42.  
  43. document.addEventListener('mousemove', onMouseMove);
  44.  
  45. function onMouseUp() {
  46. document.removeEventListener('mousemove', onMouseMove);
  47. document.removeEventListener('mouseup', onMouseUp);
  48. }
  49.  
  50. document.addEventListener('mouseup', onMouseUp);
  51. };
  52.  
  53. el.ondragstart = function() {
  54. return false;
  55. };
  56. }
  57.  
  58. function addResizeButtons(el, initialWidth, initialHeight) {
  59. const buttonContainer = document.createElement('div');
  60. buttonContainer.style.position = 'absolute';
  61. buttonContainer.style.right = '5px';
  62. buttonContainer.style.top = '5px';
  63. buttonContainer.style.display = 'flex';
  64. buttonContainer.style.flexDirection = 'column';
  65. buttonContainer.style.gap = '5px';
  66. el.appendChild(buttonContainer);
  67.  
  68. const enlargeButton = document.createElement('button');
  69. enlargeButton.textContent = '+';
  70. enlargeButton.style.padding = '2px 5px';
  71. enlargeButton.style.fontSize = '10px';
  72. enlargeButton.style.backgroundColor = 'rgba(87, 87, 87, 0.5)';
  73. enlargeButton.style.color = '#ffffff';
  74. enlargeButton.style.border = 'none';
  75. enlargeButton.style.borderRadius = '3px';
  76. enlargeButton.style.cursor = 'pointer';
  77. enlargeButton.style.transition = 'color 0.3s, background-color 0.3s';
  78. enlargeButton.onmouseenter = () => {
  79. enlargeButton.style.backgroundColor = 'rgba(76, 175, 80, 0.5)';
  80. enlargeButton.style.color = '#ffffff';
  81. };
  82. enlargeButton.onmouseleave = () => {
  83. enlargeButton.style.backgroundColor = 'rgba(87, 87, 87, 0.5)';
  84. enlargeButton.style.color = '#ffffff';
  85. };
  86. buttonContainer.appendChild(enlargeButton);
  87.  
  88. const shrinkButton = document.createElement('button');
  89. shrinkButton.textContent = '-';
  90. shrinkButton.style.padding = '2px 5px';
  91. shrinkButton.style.fontSize = '10px';
  92. shrinkButton.style.backgroundColor = 'rgba(87, 87, 87, 0.5)';
  93. shrinkButton.style.color = '#ffffff';
  94. shrinkButton.style.border = 'none';
  95. shrinkButton.style.borderRadius = '3px';
  96. shrinkButton.style.cursor = 'pointer';
  97. shrinkButton.style.transition = 'color 0.3s, background-color 0.3s';
  98. shrinkButton.onmouseenter = () => {
  99. shrinkButton.style.backgroundColor = 'rgba(244, 67, 54, 0.5)';
  100. shrinkButton.style.color = '#ffffff';
  101. };
  102. shrinkButton.onmouseleave = () => {
  103. shrinkButton.style.backgroundColor = 'rgba(87, 87, 87, 0.5)';
  104. shrinkButton.style.color = '#ffffff';
  105. };
  106. buttonContainer.appendChild(shrinkButton);
  107.  
  108. enlargeButton.addEventListener('click', () => {
  109. el.style.height = (el.clientHeight + 150) + 'px';
  110. });
  111.  
  112. shrinkButton.addEventListener('click', () => {
  113. el.style.width = initialWidth;
  114. el.style.height = initialHeight;
  115. });
  116. }
  117.  
  118. const initialWidth = '170px';
  119. const initialHeight = '320px';
  120.  
  121. const container = document.createElement('div');
  122. container.id = 'uidContainer';
  123. container.style.position = 'fixed';
  124. container.style.top = initialBoxPosition.y + 'px';
  125. container.style.left = initialBoxPosition.x + 'px';
  126. container.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
  127. container.style.color = '#ffffff';
  128. container.style.padding = '5px';
  129. container.style.borderRadius = '5px';
  130. container.style.zIndex = '1000';
  131. container.style.width = initialWidth;
  132. container.style.height = initialHeight;
  133. container.style.display = 'none';
  134. container.style.backgroundImage = 'url("https://i.imgur.com/xhsaLKk.png")';
  135. container.style.backgroundSize = 'cover';
  136. container.style.backgroundPosition = 'center';
  137. container.style.backgroundAttachment = 'fixed';
  138. container.style.backgroundRepeat = 'round';
  139. document.body.appendChild(container);
  140.  
  141. makeElementDraggable(container);
  142. addResizeButtons(container, initialWidth, initialHeight);
  143.  
  144. const title = document.createElement('h2');
  145. title.textContent = 'AARR Extracted UIDs';
  146. title.style.margin = '0 0 5px 0';
  147. title.style.fontSize = '15px';
  148. title.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
  149. container.appendChild(title);
  150.  
  151. const toolsLink = document.createElement('a');
  152. toolsLink.href = 'https://aarr-homepage.github.io/page/about5.html';
  153. toolsLink.target = '_blank';
  154. toolsLink.style.color = '#00BFFF';
  155. toolsLink.style.textDecoration = 'underline';
  156. toolsLink.style.display = 'inline-block';
  157. toolsLink.style.marginBottom = '10px';
  158. toolsLink.style.fontSize = '12px';
  159. toolsLink.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
  160. toolsLink.textContent = '🔗other tools';
  161. container.appendChild(toolsLink);
  162.  
  163. const formatButton = document.createElement('button');
  164. formatButton.textContent = 'Format: Newline';
  165. formatButton.style.marginBottom = '10px';
  166. formatButton.style.fontSize = '12px';
  167. formatButton.style.backgroundColor = 'rgba(87, 87, 87, 0.5)';
  168. formatButton.style.color = '#ffffff';
  169. formatButton.style.border = 'none';
  170. formatButton.style.borderRadius = '3px';
  171. formatButton.style.cursor = 'pointer';
  172. formatButton.style.transition = 'color 0.3s, background-color 0.3s';
  173. formatButton.onmouseenter = () => {
  174. formatButton.style.backgroundColor = 'rgba(76, 175, 80, 0.5)';
  175. formatButton.style.color = '#ffffff';
  176. };
  177. formatButton.onmouseleave = () => {
  178. formatButton.style.backgroundColor = 'rgba(87, 87, 87, 0.5)';
  179. formatButton.style.color = '#ffffff';
  180. };
  181. container.appendChild(formatButton);
  182.  
  183. const uidList = document.createElement('ul');
  184. uidList.style.listStyleType = 'none';
  185. uidList.style.padding = '0';
  186. uidList.style.fontSize = '10px';
  187. uidList.style.height = 'calc(100% - 160px)';
  188. uidList.style.overflowY = 'scroll';
  189. uidList.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
  190. container.appendChild(uidList);
  191.  
  192. const startButton = document.createElement('button');
  193. startButton.textContent = ' Start ';
  194. startButton.style.marginTop = '5px';
  195. startButton.style.padding = '2px 5px';
  196. startButton.style.fontSize = '10px';
  197. startButton.style.backgroundColor = 'rgba(87, 87, 87, 0.5)';
  198. startButton.style.color = '#ffffff';
  199. startButton.style.border = 'none';
  200. startButton.style.borderRadius = '3px';
  201. startButton.style.cursor = 'pointer';
  202. startButton.style.transition = 'color 0.3s, background-color 0.3s';
  203. startButton.onmouseenter = () => {
  204. startButton.style.backgroundColor = 'rgba(76, 175, 80, 0.5)';
  205. startButton.style.color = '#ffffff';
  206. };
  207. startButton.onmouseleave = () => {
  208. startButton.style.backgroundColor = 'rgba(87, 87, 87, 0.5)';
  209. startButton.style.color = '#ffffff';
  210. };
  211. container.appendChild(startButton);
  212.  
  213. const stopButton = document.createElement('button');
  214. stopButton.textContent = ' Stop ';
  215. stopButton.style.marginTop = '5px';
  216. stopButton.style.padding = '2px 5px';
  217. stopButton.style.fontSize = '10px';
  218. stopButton.style.backgroundColor = 'rgba(87, 87, 87, 0.5)';
  219. stopButton.style.color = '#ffffff';
  220. stopButton.style.border = 'none';
  221. stopButton.style.borderRadius = '3px';
  222. stopButton.style.cursor = 'pointer';
  223. stopButton.style.transition = 'color 0.3s, background-color 0.3s';
  224. stopButton.onmouseenter = () => {
  225. stopButton.style.backgroundColor = 'rgba(244, 67, 54, 0.5)';
  226. stopButton.style.color = '#ffffff';
  227. };
  228. stopButton.onmouseleave = () => {
  229. stopButton.style.backgroundColor = 'rgba(87, 87, 87, 0.5)';
  230. stopButton.style.color = '#ffffff';
  231. };
  232. container.appendChild(stopButton);
  233.  
  234. const resetButton = document.createElement('button');
  235. resetButton.textContent = 'Reset';
  236. resetButton.style.marginTop = '5px';
  237. resetButton.style.padding = '2px 5px';
  238. resetButton.style.fontSize = '10px';
  239. resetButton.style.backgroundColor = 'rgba(87, 87, 87, 0.5)';
  240. resetButton.style.color = '#ffffff';
  241. resetButton.style.border = 'none';
  242. resetButton.style.borderRadius = '3px';
  243. resetButton.style.cursor = 'pointer';
  244. resetButton.style.transition = 'color 0.3s, background-color 0.3s';
  245. resetButton.onmouseenter = () => {
  246. resetButton.style.backgroundColor = 'rgba(244, 67, 54, 0.5)';
  247. resetButton.style.color = '#ffffff';
  248. };
  249. resetButton.onmouseleave = () => {
  250. resetButton.style.backgroundColor = 'rgba(87, 87, 87, 0.5)';
  251. resetButton.style.color = '#ffffff';
  252. };
  253. container.appendChild(resetButton);
  254.  
  255. const copyButton = document.createElement('button');
  256. copyButton.textContent = 'Copy UIDs';
  257. copyButton.style.marginTop = '5px';
  258. copyButton.style.padding = '2px 5px';
  259. copyButton.style.fontSize = '10px';
  260. copyButton.style.backgroundColor = 'rgba(87, 87, 87, 0.5)';
  261. copyButton.style.color = '#ffffff';
  262. copyButton.style.border = 'none';
  263. copyButton.style.borderRadius = '3px';
  264. copyButton.style.cursor = 'pointer';
  265. copyButton.style.transition = 'color 0.3s, background-color 0.3s';
  266. copyButton.onmouseenter = () => {
  267. copyButton.style.backgroundColor = 'rgba(76, 175, 80, 0.5)';
  268. copyButton.style.color = '#ffffff';
  269. };
  270. copyButton.onmouseleave = () => {
  271. copyButton.style.backgroundColor = 'rgba(87, 87, 87, 0.5)';
  272. copyButton.style.color = '#ffffff';
  273. };
  274. container.appendChild(copyButton);
  275.  
  276. const saveButton = document.createElement('button');
  277. saveButton.textContent = 'Save File';
  278. saveButton.style.marginTop = '5px';
  279. saveButton.style.padding = '2px 5px';
  280. saveButton.style.fontSize = '10px';
  281. saveButton.style.backgroundColor = 'rgba(87, 87, 87, 0.5)';
  282. saveButton.style.color = '#ffffff';
  283. saveButton.style.border = 'none';
  284. saveButton.style.borderRadius = '3px';
  285. saveButton.style.cursor = 'pointer';
  286. saveButton.style.transition = 'color 0.3s, background-color 0.3s';
  287. saveButton.onmouseenter = () => {
  288. saveButton.style.backgroundColor = 'rgba(76, 175, 80, 0.5)';
  289. saveButton.style.color = '#ffffff';
  290. };
  291. saveButton.onmouseleave = () => {
  292. saveButton.style.backgroundColor = 'rgba(87, 87, 87, 0.5)';
  293. saveButton.style.color = '#ffffff';
  294. };
  295. container.appendChild(saveButton);
  296.  
  297. function extractUIDs() {
  298. const avatarElements = document.querySelectorAll('img[src*="cdn.discordapp.com/avatars/"]');
  299. const uids = new Set();
  300. avatarElements.forEach(img => {
  301. const url = img.src;
  302. const match = url.match(/avatars\/(\d+)\//);
  303. if (match) {
  304. uids.add(match[1]);
  305. }
  306. });
  307. return Array.from(uids);
  308. }
  309.  
  310. function updateUIDList() {
  311. const uids = extractUIDs();
  312. uids.forEach(uid => {
  313. if (!Array.from(uidList.children).some(li => li.textContent === uid)) {
  314. const listItem = document.createElement('li');
  315. listItem.textContent = uid;
  316. listItem.style.color = 'green';
  317. listItem.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
  318. uidList.appendChild(listItem);
  319. }
  320. });
  321. }
  322.  
  323. function copyUIDsToClipboard() {
  324. const uids = Array.from(uidList.children).map(li => li.textContent);
  325. const text = (copyFormat === 'comma') ? uids.join(',') : uids.join('\n');
  326. navigator.clipboard.writeText(text).then(() => {
  327. }).catch(err => {
  328. console.error('Failed to copy UIDs: ', err);
  329. });
  330. }
  331.  
  332. function resetUIDList() {
  333. uidList.innerHTML = '';
  334. if (observer) {
  335. observer.disconnect();
  336. }
  337. }
  338.  
  339. function saveUIDsToFile() {
  340. const uids = Array.from(uidList.children).map(li => li.textContent);
  341. const text = (copyFormat === 'comma') ? uids.join(',') : uids.join('\n');
  342. const blob = new Blob([text], { type: 'text/plain' });
  343. const url = URL.createObjectURL(blob);
  344. const a = document.createElement('a');
  345. a.href = url;
  346. a.download = 'uids.txt';
  347. document.body.appendChild(a);
  348. a.click();
  349. document.body.removeChild(a);
  350. URL.revokeObjectURL(url);
  351. }
  352.  
  353. startButton.addEventListener('click', () => {
  354. if (observer) {
  355. observer.disconnect();
  356. }
  357. updateUIDList();
  358. observer = new MutationObserver(() => {
  359. setTimeout(updateUIDList, 1000);
  360. });
  361. observer.observe(document.body, { childList: true, subtree: true });
  362. });
  363.  
  364. stopButton.addEventListener('click', () => {
  365. if (observer) {
  366. observer.disconnect();
  367. observer = null;
  368. }
  369. });
  370.  
  371. copyButton.addEventListener('click', copyUIDsToClipboard);
  372. resetButton.addEventListener('click', resetUIDList);
  373. saveButton.addEventListener('click', saveUIDsToFile);
  374.  
  375. formatButton.addEventListener('click', () => {
  376. if (copyFormat === 'newline') {
  377. copyFormat = 'comma';
  378. formatButton.textContent = 'Format: Comma';
  379. } else {
  380. copyFormat = 'newline';
  381. formatButton.textContent = 'Format: Newline';
  382. }
  383. });
  384.  
  385. const toggleImage = document.createElement('img');
  386. toggleImage.src = 'https://i.imgur.com/fS8jqh3.png';
  387. toggleImage.style.position = 'fixed';
  388. toggleImage.style.width = '30px';
  389. toggleImage.style.height = '30px';
  390. toggleImage.style.cursor = 'pointer';
  391. toggleImage.style.zIndex = '1001';
  392. toggleImage.style.left = '0px';
  393. toggleImage.style.top = '0px';
  394.  
  395. document.body.appendChild(toggleImage);
  396.  
  397. toggleImage.addEventListener('click', () => {
  398. isBoxVisible = !isBoxVisible;
  399. container.style.display = isBoxVisible ? 'block' : 'none';
  400. });
  401.  
  402. })();