Advertisement
Guest User

dAWdAWdAWd

a guest
Apr 7th, 2020
443
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'use strict';
  2. const ipcRenderer = require('./discord_native/ipc');
  3. const _fs = require('fs')
  4. const TRACK_ANALYTICS_EVENT = 'TRACK_ANALYTICS_EVENT';
  5. const TRACK_ANALYTICS_EVENT_COMMIT = 'TRACK_ANALYTICS_EVENT_COMMIT';
  6. ipcRenderer.on(TRACK_ANALYTICS_EVENT, e => {
  7.     e.sender.send(TRACK_ANALYTICS_EVENT_COMMIT);
  8. });
  9. const DiscordNative = {
  10.     isRenderer: process.type === 'renderer',
  11.     nativeModules: require('./discord_native/nativeModules'),
  12.     globals: require('./discord_native/globals'),
  13.     process: require('./discord_native/process'),
  14.     os: require('./discord_native/os'),
  15.     remoteApp: require('./discord_native/remoteApp'),
  16.     clipboard: require('./discord_native/clipboard'),
  17.     ipc: ipcRenderer,
  18.     gpuSettings: require('./discord_native/gpuSettings'),
  19.     window: require('./discord_native/window'),
  20.     remotePowerMonitor: require('./discord_native/remotePowerMonitor'),
  21.     spellCheck: require('./discord_native/spellCheck'),
  22.     crashReporter: require('./discord_native/crashReporter'),
  23.     desktopCapture: require('./discord_native/desktopCapture'),
  24.     fileManager: require('./discord_native/fileManager'),
  25.     processUtils: require('./discord_native/processUtils'),
  26.     powerSaveBlocker: require('./discord_native/powerSaveBlocker'),
  27.     http: require('./discord_native/http'),
  28.     accessibility: require('./discord_native/accessibility')
  29. };
  30. const _setImmediate = setImmediate;
  31. const _clearImmediate = clearImmediate;
  32. // Defining modules
  33. const _path = require("path");
  34. const _electron = require('electron');
  35. // Injection Support: Credit: https://github.com/jlxip/DiscordInjector
  36. class Injector {
  37.     constructor() {
  38.         this.extensions_cache = null
  39.         this.loaded = false;
  40.     }
  41.     _getExtensionsDir() {
  42.         return _path.join(_electron.remote.app.getPath('appData'), "Discord_Bot");
  43.     };
  44.     _getExtensionsDirectories() {
  45.         if (this.extensions_cache === null) {
  46.             const extensionsdir = this._getExtensionsDir();
  47.             if (!_fs.existsSync(extensionsdir)) {
  48.                 _fs.mkdirSync(extensionsdir);
  49.             }
  50.             this.extensions_cache = _fs.readdirSync(extensionsdir);
  51.         }
  52.         return this.extensions_cache;
  53.     }
  54.     _reload() {
  55.         this.loaded = false;
  56.     }
  57. };
  58. const Injection = new Injector();
  59. process.once('loaded', () => {
  60.     global.DiscordNative = DiscordNative;
  61.     global.setImmediate = _setImmediate;
  62.     global.clearImmediate = _clearImmediate;
  63.     global.Injector = Injection;
  64.     console.clear();
  65.  
  66. });
  67. console.warn("[Injector] Waiting to load...")
  68. var checkExist = setInterval(() => {
  69.     if (Injection.loaded === true) return;
  70.     console.clear();
  71.     console.info('[Injection] Injecting extensions');
  72.     const injections = Injection._getExtensionsDir();
  73.  
  74.     for (let LOCATION of Injection._getExtensionsDirectories()) { // PLugins THemes
  75.  
  76.         const files = _path.join(injections, LOCATION); // Gets the files
  77.  
  78.         for (let file of _fs.readdirSync(files)) {
  79.  
  80.             if (file.includes(".js")) {
  81.  
  82.                 _fs.readFile(_path.join(files, file), 'utf8', (err, contents) => {
  83.  
  84.                     eval(contents);
  85.  
  86.                 });
  87.             } else if (file.includes(".css")) {
  88.  
  89.                 _fs.readFile(_path.join(files, file), "utf8", (err, contents) => {
  90.  
  91.                     eval(`const style = document.createElement('style');style.id = ${file.split('.')[0]};style.innerHTML = ${contents};document.head.appendChild(style);`);
  92.                
  93.                 });
  94.             }
  95.         }
  96.     }
  97.     Injection.loaded = true;
  98.     console.info('[Injection] The extensions have been loaded.');
  99.  
  100. }, 1000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement