Discord Channel ID Extractor

Extract Discord channel IDs from links on the page

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