Revert "Update 0BDFDB.plugin.js"

This reverts commit 2a7217b868.
This commit is contained in:
Mirco Wittrien 2022-09-01 11:17:19 +02:00
parent 2a7217b868
commit 3bc9a074b1
1 changed files with 8781 additions and 8757 deletions

View File

@ -2,7 +2,7 @@
* @name BDFDB
* @author DevilBro
* @authorId 278543574059057154
* @version 2.5.5
* @version 2.5.4
* @description Required Library for DevilBro's Plugins
* @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien
@ -13,28 +13,31 @@
*/
module.exports = (_ => {
if (window.BDFDB_Global && window.BDFDB_Global.PluginUtils && typeof window.BDFDB_Global.PluginUtils.cleanUp == "function") window.BDFDB_Global.PluginUtils.cleanUp(window.BDFDB_Global);
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);
}
const BDFDB = {
started: true
};
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 = {};
for (let key in config) key == "info" ? Object.assign(BDFDB, config[key]) : (BDFDB[key] = config[key]);
const Internal = Object.assign({}, BDFDB, {
patchPriority: 0,
@ -100,13 +103,12 @@ module.exports = (_ => {
chunkObserver: {},
contextChunkObserver: {}
};
const Plugin = function () {
const Plugin = function(config) {
return class Plugin {
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;}
getName () {return config.info.name;}
getAuthor () {return config.info.author;}
getVersion () {return config.info.version;}
getDescription () {return config.info.description;}
load () {
this.loaded = true;
this.defaults = {};
@ -114,11 +116,14 @@ module.exports = (_ => {
if (window.BDFDB_Global.loading) {
if (!PluginStores.delayed.loads.includes(this)) PluginStores.delayed.loads.push(this);
}
else BDFDB.TimeUtils.suppress(_ => {
PluginStores.loaded[this.name] = this;
else {
Object.assign(this, config.info, BDFDB.ObjectUtils.exclude(config, "info"));
BDFDB.TimeUtils.suppress(_ => {
PluginStores.loaded[config.info.name] = this;
BDFDB.PluginUtils.load(this);
if (typeof this.onLoad == "function") this.onLoad();
}, "Failed to load Plugin!", this)();
}, "Failed to load Plugin!", config.info)();
}
}
start () {
if (!this.loaded) this.load();
@ -131,7 +136,7 @@ module.exports = (_ => {
BDFDB.TimeUtils.suppress(_ => {
BDFDB.PluginUtils.init(this);
if (typeof this.onStart == "function") this.onStart();
}, "Failed to start Plugin!", this)();
}, "Failed to start Plugin!", config.info)();
delete this.stopping;
}
}
@ -147,7 +152,7 @@ module.exports = (_ => {
BDFDB.TimeUtils.suppress(_ => {
if (typeof this.onStop == "function") this.onStop();
BDFDB.PluginUtils.clear(this);
}, "Failed to stop Plugin!", this)();
}, "Failed to stop Plugin!", config.info)();
delete this.started;
}
@ -553,8 +558,8 @@ module.exports = (_ => {
BDFDB.PluginUtils = {};
BDFDB.PluginUtils.buildPlugin = function () {
return [Plugin(), BDFDB];
BDFDB.PluginUtils.buildPlugin = function (config) {
return [Plugin(config), BDFDB];
};
BDFDB.PluginUtils.load = function (plugin) {
if (!PluginStores.updateData.timeouts.includes(plugin.name)) {
@ -875,7 +880,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 == this || PluginStores.loaded[plugin.name] && PluginStores.loaded[plugin.name] == plugin && plugin.author == "DevilBro") && BDFDB.ReactUtils.createElement("div", {
footerChildren: (plugin == BDFDB || plugin == libraryInstance || 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",
@ -962,6 +967,16 @@ 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) {
@ -1164,7 +1179,7 @@ module.exports = (_ => {
Internal.getPluginURL = function (plugin) {
plugin = plugin == BDFDB && Internal || plugin;
if (BDFDB.ObjectUtils.is(plugin)) {
if (InternalData.PluginUrlMap && InternalData.PluginUrlMap[plugin.name]) return InternalData.PluginUrlMap[plugin.name];
if (plugin.rawUrl) return plugin.rawUrl;
else {
let name = InternalData.PluginNameMap && InternalData.PluginNameMap[plugin.name] || plugin.name;
return `https://mwittrien.github.io/BetterDiscordAddons/Plugins/${name}/${name}.plugin.js`;
@ -8066,7 +8081,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 == this || plugin.name && plugin.name && PluginStores.loaded[plugin.name] && PluginStores.loaded[plugin.name] == plugin)) {
if (plugin && (plugin == libraryInstance || 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);
@ -8917,7 +8932,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();
@ -8948,14 +8963,23 @@ 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;
if (!BDFDB.BDUtils.isPluginEnabled(this.name)) BDFDB.BDUtils.enablePlugin(this.name);
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);
}
start () {
if (!this.loaded) this.load();
}
stop () {
if (!BDFDB.BDUtils.isPluginEnabled(this.name)) BDFDB.BDUtils.enablePlugin(this.name);
if (!BDFDB.BDUtils.isPluginEnabled(config.info.name)) BDFDB.BDUtils.enablePlugin(config.info.name);
}
getSettingsPanel (collapseStates = {}) {