├── README.md └── get-discord-token.js /README.md: -------------------------------------------------------------------------------- 1 | Automatically get your discord token from browser, bypassing the new security measures. 2 | 3 | 4 | 5 | ## How-to 6 | ### 1. Log into [Discordapp](https://discordapp.com/activity) in browser 7 | ### 2. Install [Tampermonkey](https://tampermonkey.net/) ([guide](https://www.youtube.com/watch?v=cu4XeYtqXbM)) 8 | ### 3. Add [script](https://github.com/FOCI-DEV/Get-Discord-Token/blob/master/get-discord-token.js) into Tampermonkey 9 | ### 4. Load/refresh [Discordapp](https://discordapp.com/activity) in browser 10 | 11 | --- 12 | 13 | ###### (If this script/guide has worked for you, please star this. If it hasn't worked, leave a comment and I'll help you.) 14 | -------------------------------------------------------------------------------- /get-discord-token.js: -------------------------------------------------------------------------------- 1 | // ==UserScript== 2 | // @name Get Discord Token 3 | // @namespace http://tampermonkey.net/ 4 | // @version 0.3 5 | // @description Allows you to retrieve your user token for reference. 6 | // @author Brendan#4698 7 | // @match https://discord.com/activ* 8 | // @match https://discord.com/channel* 9 | // @grant none 10 | // @run-at document-start 11 | // ==/UserScript== 12 | 13 | (function () { 14 | 'use strict'; 15 | 16 | // impliment localstorage behavior using cookie 17 | //--------------------------------------------- 18 | if(!window.localStorage) { 19 | Object.defineProperty(window, "localStorage", new(function () { 20 | var aKeys = [], 21 | oStorage = {}; 22 | Object.defineProperty(oStorage, "getItem", { 23 | value: function (sKey) { 24 | return this[sKey] ? this[sKey] : null; 25 | }, 26 | writable: false, 27 | configurable: false, 28 | enumerable: false 29 | }); 30 | Object.defineProperty(oStorage, "key", { 31 | value: function (nKeyId) { 32 | return aKeys[nKeyId]; 33 | }, 34 | writable: false, 35 | configurable: false, 36 | enumerable: false 37 | }); 38 | Object.defineProperty(oStorage, "setItem", { 39 | value: function (sKey, sValue) { 40 | if(!sKey) { 41 | return; 42 | } 43 | document.cookie = escape(sKey) + "=" + escape(sValue) + "; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"; 44 | }, 45 | writable: false, 46 | configurable: false, 47 | enumerable: false 48 | }); 49 | Object.defineProperty(oStorage, "length", { 50 | get: function () { 51 | return aKeys.length; 52 | }, 53 | configurable: false, 54 | enumerable: false 55 | }); 56 | Object.defineProperty(oStorage, "removeItem", { 57 | value: function (sKey) { 58 | if(!sKey) { 59 | return; 60 | } 61 | document.cookie = escape(sKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/"; 62 | }, 63 | writable: false, 64 | configurable: false, 65 | enumerable: false 66 | }); 67 | Object.defineProperty(oStorage, "clear", { 68 | value: function () { 69 | if(!aKeys.length) { 70 | return; 71 | } 72 | for(var sKey in aKeys) { 73 | document.cookie = escape(sKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/"; 74 | } 75 | }, 76 | writable: false, 77 | configurable: false, 78 | enumerable: false 79 | }); 80 | this.get = function () { 81 | var iThisIndx; 82 | for(var sKey in oStorage) { 83 | iThisIndx = aKeys.indexOf(sKey); 84 | if(iThisIndx === -1) { 85 | oStorage.setItem(sKey, oStorage[sKey]); 86 | } else { 87 | aKeys.splice(iThisIndx, 1); 88 | } 89 | delete oStorage[sKey]; 90 | } 91 | for(aKeys; aKeys.length > 0; aKeys.splice(0, 1)) { 92 | oStorage.removeItem(aKeys[0]); 93 | } 94 | for(var aCouple, iKey, nIdx = 0, aCouples = document.cookie.split(/\s*;\s*/); nIdx < aCouples.length; nIdx++) { 95 | aCouple = aCouples[nIdx].split(/\s*=\s*/); 96 | if(aCouple.length > 1) { 97 | oStorage[iKey = unescape(aCouple[0])] = unescape(aCouple[1]); 98 | aKeys.push(iKey); 99 | } 100 | } 101 | return oStorage; 102 | }; 103 | this.configurable = false; 104 | this.enumerable = true; 105 | })()); 106 | } 107 | //--------------------------------------------------- 108 | 109 | var userToken = localStorage.getItem('token'); 110 | 111 | var warn = "Allowing anyone to see your token can result in them gaining access to your account. This can lead to impersonation, server bans, account closure, etc.\n\n\n\n If you do not understand this, press 'Cancel'." 112 | 113 | // show warning, if accepted show token 114 | document.addEventListener('readystatechange', event => { 115 | if(event.target.readyState === "interactive") {} else if(event.target.readyState === "complete") { 116 | setTimeout(function () { 117 | if(confirm(warn)) { 118 | prompt("Your token:", userToken) 119 | } 120 | }, 3000); 121 | } 122 | }); 123 | 124 | // prevent pasting token into discord 125 | document.addEventListener('paste', function (e) { 126 | if(e.clipboardData.getData('text/plain') == userToken) { 127 | // clear clipboard 128 | e.clipboardData.setData('text/plain', 'do not post your token here'); 129 | // prevent the default paste action 130 | e.preventDefault(); 131 | // prevent pasting token, paste warning instead 132 | var pasteToken = new ClipboardEvent('paste'); 133 | pasteToken.clipboardData.items.add('do not post your token here', 'text/plain'); 134 | document.dispatchEvent(pasteToken); 135 | // put token back into clipboard to allow pasting outside discord 136 | e.clipboardData.setData('text/plain', userToken); 137 | } 138 | }); 139 | })(); 140 | --------------------------------------------------------------------------------