This repository has been archived by the owner on Nov 21, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathindex.js
80 lines (61 loc) · 2.05 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
'use strict'
const { Plugin } = require('powercord/entities')
const { React } = require('powercord/webpack')
const path = require('path')
const BDApi = require('./libraries/BDApi.js')
const BDV2 = require('./libraries/BDV2.js')
const BDContentManager = require('./libraries/BDContentManager.js')
const BDPluginManager = require('./components/BDPluginManager.js')
const Settings = require('./reactcomponents/Settings.jsx')
class BDCompat extends Plugin {
startPlugin () {
this.loadCSS(path.join(__dirname, 'style.css'))
this.defineGlobals()
this.PluginManager = new BDPluginManager
this.registerSettings(
'pc-bdCompat',
'BetterDiscord Plugins',
() => React.createElement(Settings, { settings: this.settings })
)
}
pluginWillUnload () {
this.PluginManager.destroy()
this.unloadCSS()
this.destroyGlobals()
powercord.pluginManager
.get('pc-settings')
.unregister('pc-bdCompat')
}
defineGlobals () {
window.bdConfig = { dataPath: __dirname }
window.settingsCookie = {}
window.bdplugins = {}
window.pluginCookie = {}
window.bdpluginErrors = []
window.bdthemes = {}
window.themeCookie = {}
window.bdthemeErrors = []
window.BdApi = BDApi
window.bdPluginStorage = { get: BDApi.getData, set: BDApi.setData }
window.Utils = { monkeyPatch: BDApi.monkeyPatch, suppressErrors: BDApi.suppressErrors, escapeID: BDApi.escapeID }
window.BDV2 = BDV2
window.ContentManager = BDContentManager
this.log('Defined BetterDiscord globals')
}
destroyGlobals () {
delete window.bdConfig
delete window.settingsCookie
delete window.bdplugins
delete window.pluginCookie
delete window.bdpluginErrors
delete window.bdthemes
delete window.themeCookie
delete window.bdthemeErrors
delete window.BdApi
delete window.bdPluginStorage
delete window.Utils
delete window.BDV2
this.log('Destroyed BetterDiscord globals')
}
}
module.exports = BDCompat