2018-10-11 10:21:26 +02:00
|
|
|
//META{"name":"BetterNsfwTag"}*//
|
|
|
|
|
|
|
|
class BetterNsfwTag {
|
2019-01-17 23:48:29 +01:00
|
|
|
getName () {return "BetterNsfwTag";}
|
|
|
|
|
|
|
|
getVersion () {return "1.1.7";}
|
|
|
|
|
|
|
|
getAuthor () {return "DevilBro";}
|
|
|
|
|
|
|
|
getDescription () {return "Adds a more noticeable tag to NSFW channels.";}
|
|
|
|
|
2018-10-11 10:21:26 +02:00
|
|
|
initConstructor () {
|
2018-12-27 11:38:05 +01:00
|
|
|
this.patchModules = {
|
|
|
|
"ChannelItem":"componentDidMount"
|
|
|
|
};
|
2018-10-11 10:21:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//legacy
|
|
|
|
load () {}
|
|
|
|
|
|
|
|
start () {
|
2019-01-17 23:48:29 +01:00
|
|
|
var libraryScript = document.querySelector('head script[src="https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.js"]');
|
|
|
|
if (!libraryScript || performance.now() - libraryScript.getAttribute("date") > 600000) {
|
2018-10-11 10:21:26 +02:00
|
|
|
if (libraryScript) libraryScript.remove();
|
|
|
|
libraryScript = document.createElement("script");
|
|
|
|
libraryScript.setAttribute("type", "text/javascript");
|
|
|
|
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.js");
|
2019-01-17 23:48:29 +01:00
|
|
|
libraryScript.setAttribute("date", performance.now());
|
|
|
|
libraryScript.addEventListener("load", () => {
|
|
|
|
BDFDB.loaded = true;
|
|
|
|
this.initialize();
|
|
|
|
});
|
2018-10-11 10:21:26 +02:00
|
|
|
document.head.appendChild(libraryScript);
|
|
|
|
}
|
2019-01-17 23:48:29 +01:00
|
|
|
else if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
|
2018-10-11 10:21:26 +02:00
|
|
|
this.startTimeout = setTimeout(() => {this.initialize();}, 30000);
|
|
|
|
}
|
|
|
|
|
|
|
|
initialize () {
|
2019-01-17 23:48:29 +01:00
|
|
|
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
2018-10-11 10:21:26 +02:00
|
|
|
BDFDB.loadMessage(this);
|
|
|
|
|
2018-12-27 11:38:05 +01:00
|
|
|
BDFDB.WebModules.forceAllUpdates(this);
|
2018-10-11 10:21:26 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
console.error(this.getName() + ": Fatal Error: Could not load BD functions!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stop () {
|
2019-01-17 23:48:29 +01:00
|
|
|
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
2018-12-27 11:38:05 +01:00
|
|
|
BDFDB.removeEles(".NSFW-tag");
|
2018-10-11 10:21:26 +02:00
|
|
|
BDFDB.unloadMessage(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// begin of own functions
|
|
|
|
|
2018-12-27 11:38:05 +01:00
|
|
|
processChannelItem (instance, wrapper) {
|
|
|
|
if (instance.props && instance.props.channel && instance.props.channel.nsfw) {
|
2019-01-17 23:48:29 +01:00
|
|
|
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>`));
|
2018-10-11 10:21:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|