65 lines
2.4 KiB
JavaScript
65 lines
2.4 KiB
JavaScript
module.exports = (Plugin, Api, Vendor) => {
|
|
if (!global.BDFDB || typeof BDFDB != "object") global.BDFDB = {myPlugins:{}, BDv2Api: Api};
|
|
|
|
return class extends Plugin {
|
|
initConstructor () {
|
|
this.patchModules = {
|
|
"ChannelItem":"componentDidMount"
|
|
};
|
|
}
|
|
|
|
onStart () {
|
|
if (global.BDFDB && global.BDFDB.myPlugins && typeof global.BDFDB.myPlugins == "object") global.BDFDB.myPlugins[this.name] = this;
|
|
var libraryScript = document.querySelector('head script[src="https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.js"]');
|
|
if (!global.BDFDB || typeof BDFDB != "object" || performance.now() - BDFDB.creationTime > 600000) {
|
|
if (libraryScript) libraryScript.remove();
|
|
libraryScript = document.createElement("script");
|
|
libraryScript.setAttribute("type", "text/javascript");
|
|
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.js");
|
|
libraryScript.setAttribute("date", performance.now());
|
|
libraryScript.addEventListener("load", () => {if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();});
|
|
document.head.appendChild(libraryScript);
|
|
}
|
|
else if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
|
|
this.startTimeout = setTimeout(() => {this.initialize();}, 30000);
|
|
}
|
|
|
|
initialize () {
|
|
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
|
if (this.started) return true;
|
|
BDFDB.loadMessage(this);
|
|
|
|
BDFDB.WebModules.forceAllUpdates(this);
|
|
|
|
return true;
|
|
}
|
|
else {
|
|
console.error(`%c[${this.name}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
|
|
return false;
|
|
}
|
|
}
|
|
|
|
onStop () {
|
|
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
|
BDFDB.removeEles(".NSFW-tag");
|
|
|
|
BDFDB.unloadMessage(this);
|
|
return true;
|
|
}
|
|
else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
// begin of own functions
|
|
|
|
processChannelItem (instance, wrapper) {
|
|
if (instance.props && instance.props.channel && instance.props.channel.nsfw) {
|
|
let channelname = wrapper.querySelector(BDFDB.dotCN.channelname);
|
|
if (channelname) channelname.appendChild(BDFDB.htmlToElement(`<span class="NSFW-tag ${BDFDB.disCNS.bottag + BDFDB.disCNS.bottagregular + BDFDB.disCN.bottagnametag}" style="background-color: rgb(241, 71, 71) !important; color: white !important; top: -3px; position: relative;">NSFW</span>`));
|
|
}
|
|
}
|
|
}
|
|
};
|