Update 0BDFDB.plugin.js
This commit is contained in:
parent
3bc9a074b1
commit
594c8cba40
|
@ -2,7 +2,7 @@
|
|||
* @name BDFDB
|
||||
* @author DevilBro
|
||||
* @authorId 278543574059057154
|
||||
* @version 2.5.4
|
||||
* @version 2.5.5
|
||||
* @description Required Library for DevilBro's Plugins
|
||||
* @invite Jx3TjNS
|
||||
* @donate https://www.paypal.me/MircoWittrien
|
||||
|
@ -13,31 +13,28 @@
|
|||
*/
|
||||
|
||||
module.exports = (_ => {
|
||||
const BdApi = window.BdApi;
|
||||
|
||||
const config = {
|
||||
"info": {
|
||||
"name": "BDFDB",
|
||||
"author": "DevilBro",
|
||||
"version": "2.5.4",
|
||||
"description": "Required Library for DevilBro's Plugins"
|
||||
},
|
||||
"rawUrl": "https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js"
|
||||
};
|
||||
|
||||
const Cache = {data: {}, modules: {}};
|
||||
|
||||
var libraryInstance;
|
||||
var changeLogs = {};
|
||||
|
||||
if (window.BDFDB_Global && window.BDFDB_Global.PluginUtils && typeof window.BDFDB_Global.PluginUtils.cleanUp == "function") {
|
||||
window.BDFDB_Global.PluginUtils.cleanUp(window.BDFDB_Global);
|
||||
}
|
||||
if (window.BDFDB_Global && window.BDFDB_Global.PluginUtils && typeof window.BDFDB_Global.PluginUtils.cleanUp == "function") window.BDFDB_Global.PluginUtils.cleanUp(window.BDFDB_Global);
|
||||
|
||||
const BDFDB = {
|
||||
started: true
|
||||
};
|
||||
for (let key in config) key == "info" ? Object.assign(BDFDB, config[key]) : (BDFDB[key] = config[key]);
|
||||
|
||||
return class BDFDB_Frame {
|
||||
constructor (meta) {for (let key in meta) {
|
||||
if (!this[key]) this[key] = meta[key];
|
||||
if (!BDFDB[key]) BDFDB[key] = meta[key];
|
||||
}}
|
||||
getName () {return this.name;}
|
||||
getAuthor () {return this.author;}
|
||||
getVersion () {return this.version;}
|
||||
getDescription () {return this.description;}
|
||||
|
||||
load () {
|
||||
const BdApi = window.BdApi;
|
||||
|
||||
const Cache = {data: {}, modules: {}};
|
||||
|
||||
var changeLogs = {};
|
||||
|
||||
const Internal = Object.assign({}, BDFDB, {
|
||||
patchPriority: 0,
|
||||
|
@ -103,27 +100,26 @@ module.exports = (_ => {
|
|||
chunkObserver: {},
|
||||
contextChunkObserver: {}
|
||||
};
|
||||
const Plugin = function(config) {
|
||||
const Plugin = function (changeLog) {
|
||||
return class Plugin {
|
||||
getName () {return config.info.name;}
|
||||
getAuthor () {return config.info.author;}
|
||||
getVersion () {return config.info.version;}
|
||||
getDescription () {return config.info.description;}
|
||||
constructor (meta) {for (let key in meta) if (!this[key]) this[key] = meta[key];}
|
||||
getName () {return this.name;}
|
||||
getAuthor () {return this.author;}
|
||||
getVersion () {return this.version;}
|
||||
getDescription () {return this.description;}
|
||||
load () {
|
||||
this.changeLog = changeLog;
|
||||
this.loaded = true;
|
||||
this.defaults = {};
|
||||
this.labels = {};
|
||||
if (window.BDFDB_Global.loading) {
|
||||
if (!PluginStores.delayed.loads.includes(this)) PluginStores.delayed.loads.push(this);
|
||||
}
|
||||
else {
|
||||
Object.assign(this, config.info, BDFDB.ObjectUtils.exclude(config, "info"));
|
||||
BDFDB.TimeUtils.suppress(_ => {
|
||||
PluginStores.loaded[config.info.name] = this;
|
||||
else BDFDB.TimeUtils.suppress(_ => {
|
||||
PluginStores.loaded[this.name] = this;
|
||||
BDFDB.PluginUtils.load(this);
|
||||
if (typeof this.onLoad == "function") this.onLoad();
|
||||
}, "Failed to load Plugin!", config.info)();
|
||||
}
|
||||
}, "Failed to load Plugin!", this)();
|
||||
}
|
||||
start () {
|
||||
if (!this.loaded) this.load();
|
||||
|
@ -136,7 +132,7 @@ module.exports = (_ => {
|
|||
BDFDB.TimeUtils.suppress(_ => {
|
||||
BDFDB.PluginUtils.init(this);
|
||||
if (typeof this.onStart == "function") this.onStart();
|
||||
}, "Failed to start Plugin!", config.info)();
|
||||
}, "Failed to start Plugin!", this)();
|
||||
delete this.stopping;
|
||||
}
|
||||
}
|
||||
|
@ -152,7 +148,7 @@ module.exports = (_ => {
|
|||
BDFDB.TimeUtils.suppress(_ => {
|
||||
if (typeof this.onStop == "function") this.onStop();
|
||||
BDFDB.PluginUtils.clear(this);
|
||||
}, "Failed to stop Plugin!", config.info)();
|
||||
}, "Failed to stop Plugin!", this)();
|
||||
|
||||
delete this.started;
|
||||
}
|
||||
|
@ -558,8 +554,8 @@ module.exports = (_ => {
|
|||
|
||||
|
||||
BDFDB.PluginUtils = {};
|
||||
BDFDB.PluginUtils.buildPlugin = function (config) {
|
||||
return [Plugin(config), BDFDB];
|
||||
BDFDB.PluginUtils.buildPlugin = function (changeLog) {
|
||||
return [Plugin(changeLog), BDFDB];
|
||||
};
|
||||
BDFDB.PluginUtils.load = function (plugin) {
|
||||
if (!PluginStores.updateData.timeouts.includes(plugin.name)) {
|
||||
|
@ -849,7 +845,7 @@ module.exports = (_ => {
|
|||
});
|
||||
};
|
||||
BDFDB.PluginUtils.checkChangeLog = function (plugin) {
|
||||
if (!BDFDB.ObjectUtils.is(plugin) || !BDFDB.ObjectUtils.is(plugin.changeLog)) return;
|
||||
if (!BDFDB.ObjectUtils.is(plugin) || !BDFDB.ObjectUtils.is(plugin.changeLog) || plugin.changeLog.info) return;
|
||||
if (!changeLogs[plugin.name] || BDFDB.NumberUtils.compareVersions(plugin.version, changeLogs[plugin.name])) {
|
||||
changeLogs[plugin.name] = plugin.version;
|
||||
BDFDB.DataUtils.save(changeLogs, BDFDB, "changeLogs");
|
||||
|
@ -880,7 +876,7 @@ module.exports = (_ => {
|
|||
contentClassName: BDFDB.disCNS.changelogcontainer + BDFDB.disCN.modalminicontent,
|
||||
footerDirection: Internal.LibraryComponents.Flex.Direction.HORIZONTAL,
|
||||
children: BDFDB.ReactUtils.elementToReact(BDFDB.DOMUtils.create(changeLogHTML)),
|
||||
footerChildren: (plugin == BDFDB || plugin == libraryInstance || PluginStores.loaded[plugin.name] && PluginStores.loaded[plugin.name] == plugin && plugin.author == "DevilBro") && BDFDB.ReactUtils.createElement("div", {
|
||||
footerChildren: (plugin == BDFDB || plugin == this || PluginStores.loaded[plugin.name] && PluginStores.loaded[plugin.name] == plugin && plugin.author == "DevilBro") && BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN.changelogfooter,
|
||||
children: [{
|
||||
href: "https://www.paypal.me/MircoWittrien",
|
||||
|
@ -967,16 +963,6 @@ module.exports = (_ => {
|
|||
}
|
||||
};
|
||||
|
||||
window.BDFDB_Global = Object.assign({
|
||||
started: true,
|
||||
loading: true,
|
||||
PluginUtils: {
|
||||
buildPlugin: BDFDB.PluginUtils.buildPlugin,
|
||||
cleanUp: BDFDB.PluginUtils.cleanUp
|
||||
}
|
||||
}, config, window.BDFDB_Global);
|
||||
|
||||
|
||||
const request = require("request"), fs = require("fs"), path = require("path");
|
||||
|
||||
Internal.writeConfig = function (plugin, path, config) {
|
||||
|
@ -1179,7 +1165,7 @@ module.exports = (_ => {
|
|||
Internal.getPluginURL = function (plugin) {
|
||||
plugin = plugin == BDFDB && Internal || plugin;
|
||||
if (BDFDB.ObjectUtils.is(plugin)) {
|
||||
if (plugin.rawUrl) return plugin.rawUrl;
|
||||
if (InternalData.PluginUrlMap && InternalData.PluginUrlMap[plugin.name]) return InternalData.PluginUrlMap[plugin.name];
|
||||
else {
|
||||
let name = InternalData.PluginNameMap && InternalData.PluginNameMap[plugin.name] || plugin.name;
|
||||
return `https://mwittrien.github.io/BetterDiscordAddons/Plugins/${name}/${name}.plugin.js`;
|
||||
|
@ -8081,7 +8067,7 @@ module.exports = (_ => {
|
|||
if (!checkbox) return;
|
||||
let props = BDFDB.ObjectUtils.get(BDFDB.ReactUtils.getInstance(card), "return.stateNode.props");
|
||||
let plugin = props && props.addon && (props.addon.plugin || props.addon.instance);
|
||||
if (plugin && (plugin == libraryInstance || plugin.name && plugin.name && PluginStores.loaded[plugin.name] && PluginStores.loaded[plugin.name] == plugin)) {
|
||||
if (plugin && (plugin == this || plugin.name && plugin.name && PluginStores.loaded[plugin.name] && PluginStores.loaded[plugin.name] == plugin)) {
|
||||
let url = Internal.getPluginURL(plugin);
|
||||
let controls = [];
|
||||
let footerControls = card.querySelector(BDFDB.dotCNS._repofooter + BDFDB.dotCN._repocontrols);
|
||||
|
@ -8932,7 +8918,7 @@ module.exports = (_ => {
|
|||
buildPlugin: BDFDB.PluginUtils.buildPlugin,
|
||||
cleanUp: BDFDB.PluginUtils.cleanUp
|
||||
}
|
||||
}, config);
|
||||
});
|
||||
|
||||
while (PluginStores.delayed.loads.length) PluginStores.delayed.loads.shift().load();
|
||||
while (PluginStores.delayed.starts.length) PluginStores.delayed.starts.shift().start();
|
||||
|
@ -8963,23 +8949,14 @@ module.exports = (_ => {
|
|||
};
|
||||
requestLibraryHashes(true);
|
||||
|
||||
return class BDFDB_Frame {
|
||||
getName () {return config.info.name;}
|
||||
getAuthor () {return config.info.author;}
|
||||
getVersion () {return config.info.version;}
|
||||
getDescription () {return config.info.description;}
|
||||
|
||||
load () {
|
||||
this.loaded = true;
|
||||
libraryInstance = this;
|
||||
Object.assign(this, config.info, BDFDB.ObjectUtils.exclude(config, "info"));
|
||||
if (!BDFDB.BDUtils.isPluginEnabled(config.info.name)) BDFDB.BDUtils.enablePlugin(config.info.name);
|
||||
if (!BDFDB.BDUtils.isPluginEnabled(this.name)) BDFDB.BDUtils.enablePlugin(this.name);
|
||||
}
|
||||
start () {
|
||||
if (!this.loaded) this.load();
|
||||
}
|
||||
stop () {
|
||||
if (!BDFDB.BDUtils.isPluginEnabled(config.info.name)) BDFDB.BDUtils.enablePlugin(config.info.name);
|
||||
if (!BDFDB.BDUtils.isPluginEnabled(this.name)) BDFDB.BDUtils.enablePlugin(this.name);
|
||||
}
|
||||
|
||||
getSettingsPanel (collapseStates = {}) {
|
||||
|
|
Loading…
Reference in New Issue