soon this will die
This commit is contained in:
parent
1de5ddbdd0
commit
80cde74f7b
100
js/main.js
100
js/main.js
|
@ -304,18 +304,22 @@ Core.prototype.init = async function() {
|
||||||
|
|
||||||
this.injectExternals();
|
this.injectExternals();
|
||||||
|
|
||||||
|
settingsPanel = new V2_SettingsPanel();
|
||||||
|
pluginModule = new PluginModule();
|
||||||
|
themeModule = new ThemeModule();
|
||||||
|
|
||||||
|
this.setupAPI();
|
||||||
|
|
||||||
await this.checkForGuilds();
|
await this.checkForGuilds();
|
||||||
BDV2.initialize();
|
BDV2.initialize();
|
||||||
|
|
||||||
Utils.log("Startup", "Updating Settings");
|
Utils.log("Startup", "Updating Settings");
|
||||||
settingsPanel = new V2_SettingsPanel();
|
|
||||||
settingsPanel.initializeSettings();
|
settingsPanel.initializeSettings();
|
||||||
|
|
||||||
Utils.log("Startup", "Loading Plugins");
|
Utils.log("Startup", "Loading Plugins");
|
||||||
pluginModule = new PluginModule();
|
|
||||||
pluginModule.loadPlugins();
|
pluginModule.loadPlugins();
|
||||||
|
|
||||||
Utils.log("Startup", "Loading Themes");
|
Utils.log("Startup", "Loading Themes");
|
||||||
themeModule = new ThemeModule();
|
|
||||||
themeModule.loadThemes();
|
themeModule.loadThemes();
|
||||||
|
|
||||||
$("#customcss").detach().appendTo(document.head);
|
$("#customcss").detach().appendTo(document.head);
|
||||||
|
@ -393,6 +397,48 @@ Core.prototype.loadSettings = function () {
|
||||||
settingsCookie = DataStore.getSettingGroup("settings");
|
settingsCookie = DataStore.getSettingGroup("settings");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Core.prototype.setupAPI = function() {
|
||||||
|
const createAddonAPI = function(cookie, list, manager) {
|
||||||
|
return new class AddonAPI {
|
||||||
|
|
||||||
|
isEnabled(name) {
|
||||||
|
return !!cookie[name];
|
||||||
|
}
|
||||||
|
|
||||||
|
enable(name) {
|
||||||
|
return manager.enable(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
disable(name) {
|
||||||
|
return manager.disable(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
toggle(name) {
|
||||||
|
if (cookie[name]) this.disable(name);
|
||||||
|
else this.enable(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
reload(name) {
|
||||||
|
return manager.reload(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
get(name) {
|
||||||
|
if (list.hasOwnProperty(name)) {
|
||||||
|
if (list[name].plugin) return list[name].plugin;
|
||||||
|
return list[name];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
getAll() {
|
||||||
|
return Object.keys(list).map(k => this.get(k)).filter(a => a);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
BdApi.Themes = createAddonAPI(themeCookie, bdthemes, themeModule);
|
||||||
|
BdApi.Plugins = createAddonAPI(pluginCookie, bdplugins, pluginModule);
|
||||||
|
};
|
||||||
|
|
||||||
Core.prototype.initObserver = function () {
|
Core.prototype.initObserver = function () {
|
||||||
const mainObserver = new MutationObserver((mutations) => {
|
const mainObserver = new MutationObserver((mutations) => {
|
||||||
|
|
||||||
|
@ -1821,7 +1867,7 @@ PluginModule.prototype.updatePluginList = function() {
|
||||||
PluginModule.prototype.loadPluginData = function () {
|
PluginModule.prototype.loadPluginData = function () {
|
||||||
let saved = DataStore.getSettingGroup("plugins");
|
let saved = DataStore.getSettingGroup("plugins");
|
||||||
if (saved) {
|
if (saved) {
|
||||||
pluginCookie = saved;
|
Object.assign(pluginCookie, saved);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1984,7 +2030,7 @@ ThemeModule.prototype.updateThemeList = function() {
|
||||||
ThemeModule.prototype.loadThemeData = function() {
|
ThemeModule.prototype.loadThemeData = function() {
|
||||||
let saved = DataStore.getSettingGroup("themes");
|
let saved = DataStore.getSettingGroup("themes");
|
||||||
if (saved) {
|
if (saved) {
|
||||||
themeCookie = saved;
|
Object.assign(themeCookie, saved);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2255,50 +2301,6 @@ BdApi.setBDData = function(key, data) {
|
||||||
return DataStore.setBDData(key, data);
|
return DataStore.setBDData(key, data);
|
||||||
};
|
};
|
||||||
|
|
||||||
((API) => {
|
|
||||||
const createAddonAPI = function(cookie, list, manager) {
|
|
||||||
return new class AddonAPI {
|
|
||||||
|
|
||||||
isEnabled(name) {
|
|
||||||
return !!cookie[name];
|
|
||||||
}
|
|
||||||
|
|
||||||
enable(name) {
|
|
||||||
return manager.enable(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
disable(name) {
|
|
||||||
return manager.disable(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
toggle(name) {
|
|
||||||
if (cookie[name]) this.disable(name);
|
|
||||||
else this.enable(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
reload(name) {
|
|
||||||
return manager.reload(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
get(name) {
|
|
||||||
if (list.hasOwnProperty(name)) {
|
|
||||||
if (list[name].plugin) return list[name].plugin;
|
|
||||||
return list[name];
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
getAll() {
|
|
||||||
return Object.keys(list).map(k => this.get(k)).filter(a => a);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
API.Themes = createAddonAPI(themeCookie, bdthemes, themeModule);
|
|
||||||
API.Plugins = createAddonAPI(pluginCookie, bdplugins, pluginModule);
|
|
||||||
})(BdApi);
|
|
||||||
|
|
||||||
Object.freeze(BdApi);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue