authorization Extractor(β)

Extract Discord Token and display it in a draggable and resizable box without popups

  1. // ==UserScript==
  2. // @name authorization Extractor(β)
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.6
  5. // @description Extract Discord Token and display it in a draggable and resizable box without popups
  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. function makeElementDraggable(el) {
  16. el.onmousedown = function(event) {
  17. event.preventDefault();
  18.  
  19. let shiftX = event.clientX - el.getBoundingClientRect().left;
  20. let shiftY = event.clientY - el.getBoundingClientRect().top;
  21.  
  22. function moveAt(pageX, pageY) {
  23. el.style.left = Math.min(Math.max(0, pageX - shiftX), window.innerWidth - el.offsetWidth) + 'px';
  24. el.style.top = Math.min(Math.max(0, pageY - shiftY), window.innerHeight - el.offsetHeight) + 'px';
  25. }
  26.  
  27. function onMouseMove(event) {
  28. moveAt(event.pageX, event.pageY);
  29. }
  30.  
  31. document.addEventListener('mousemove', onMouseMove);
  32.  
  33. function onMouseUp() {
  34. document.removeEventListener('mousemove', onMouseMove);
  35. document.removeEventListener('mouseup', onMouseUp);
  36. }
  37.  
  38. document.addEventListener('mouseup', onMouseUp);
  39. };
  40.  
  41. el.ondragstart = function() {
  42. return false;
  43. };
  44. }
  45.  
  46. function addResizeButtons(el) {
  47. const buttonContainer = document.createElement('div');
  48. buttonContainer.style.position = 'absolute';
  49. buttonContainer.style.right = '10px';
  50. buttonContainer.style.top = '10px';
  51. buttonContainer.style.display = 'flex';
  52. buttonContainer.style.flexDirection = 'column';
  53. buttonContainer.style.gap = '10px';
  54. el.appendChild(buttonContainer);
  55. }
  56.  
  57. function createUI() {
  58. const initialWidth = '300px';
  59. const initialHeight = '200px';
  60.  
  61. const container = document.createElement('div');
  62. container.id = 'tokenContainer';
  63. container.style.position = 'fixed';
  64. container.style.top = '10px';
  65. container.style.left = '10px';
  66. container.style.backgroundColor = '#2f3136';
  67. container.style.color = '#ffffff';
  68. container.style.padding = '20px';
  69. container.style.borderRadius = '5px';
  70. container.style.zIndex = '1000';
  71. container.style.width = initialWidth;
  72. container.style.height = initialHeight;
  73. container.style.overflowY = 'auto';
  74. container.style.display = 'none';
  75. document.body.appendChild(container);
  76.  
  77. makeElementDraggable(container);
  78. addResizeButtons(container);
  79.  
  80. const title = document.createElement('h2');
  81. title.textContent = 'authorization Extractor β';
  82. title.style.margin = '0 0 10px 0';
  83. title.style.fontSize = '16px';
  84. container.appendChild(title);
  85.  
  86. const tokenDisplay = document.createElement('code');
  87. tokenDisplay.style.whiteSpace = 'pre-wrap';
  88. tokenDisplay.style.wordBreak = 'break-word';
  89. tokenDisplay.style.display = 'block';
  90. tokenDisplay.style.marginBottom = '10px';
  91. tokenDisplay.style.backgroundColor = '#000000';
  92. tokenDisplay.style.color = '#00FF00';
  93. tokenDisplay.textContent = 'Failed acquisition Wait for a while and press the “Retry” button';
  94. container.appendChild(tokenDisplay);
  95.  
  96. const copyButton = document.createElement('button');
  97. copyButton.textContent = 'Copy';
  98. copyButton.style.padding = '10px';
  99. copyButton.style.backgroundColor = '#7289da';
  100. copyButton.style.color = '#ffffff';
  101. copyButton.style.border = 'none';
  102. copyButton.style.borderRadius = '3px';
  103. copyButton.style.cursor = 'pointer';
  104. container.appendChild(copyButton);
  105.  
  106. copyButton.addEventListener('click', function() {
  107. const dummy = document.createElement('textarea');
  108. document.body.appendChild(dummy);
  109. dummy.value = tokenDisplay.getAttribute('data-token');
  110. dummy.select();
  111. document.execCommand('copy');
  112. document.body.removeChild(dummy);
  113. alert("copied your authorization to clipboard.");
  114. });
  115.  
  116. const retryButton = document.createElement('button');
  117. retryButton.textContent = 'Retry';
  118. retryButton.style.padding = '10px';
  119. retryButton.style.backgroundColor = '#ff9800';
  120. retryButton.style.color = '#ffffff';
  121. retryButton.style.border = 'none';
  122. retryButton.style.borderRadius = '3px';
  123. retryButton.style.cursor = 'pointer';
  124. container.appendChild(retryButton);
  125.  
  126. retryButton.addEventListener('click', () => {
  127. location.reload();
  128. });
  129.  
  130. return { container, tokenDisplay };
  131. }
  132.  
  133. function createToggleImage(container) {
  134. const toggleImage = document.createElement('img');
  135. toggleImage.src = 'https://i.imgur.com/fv0qOVS.png';
  136. toggleImage.style.position = 'fixed';
  137. toggleImage.style.width = '30px';
  138. toggleImage.style.height = '30px';
  139. toggleImage.style.cursor = 'pointer';
  140. toggleImage.style.zIndex = '1001';
  141. toggleImage.style.left = '75px';
  142. toggleImage.style.bottom = '189px';
  143. document.body.appendChild(toggleImage);
  144.  
  145. toggleImage.addEventListener('click', () => {
  146. const isHidden = container.style.display === 'none';
  147. container.style.display = isHidden ? 'block' : 'none';
  148. });
  149.  
  150. console.log('Toggle image created and event listener added');
  151. }
  152.  
  153. function maskToken(token) {
  154. return '*'.repeat(token.length);
  155. }
  156.  
  157. function getToken(tokenDisplay) {
  158. console.log('Attempting to retrieve token');
  159. let token = localStorage.getItem('token');
  160. if (token) {
  161. token = token.slice(1, -1);
  162. tokenDisplay.textContent = maskToken(token);
  163. tokenDisplay.setAttribute('data-token', token);
  164. console.log('Token successfully retrieved:', token);
  165. } else {
  166. console.log('Token not found in localStorage');
  167. }
  168.  
  169. console.log('Token retrieval completed');
  170. }
  171.  
  172. const { container, tokenDisplay } = createUI();
  173.  
  174. createToggleImage(container);
  175. getToken(tokenDisplay);
  176. })();