2020-02-27 08:44:03 +01:00
|
|
|
//META{"name":"RevealAllSpoilersOption","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/RevealAllSpoilersOption","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/RevealAllSpoilersOption/RevealAllSpoilersOption.plugin.js"}*//
|
2019-02-01 12:37:27 +01:00
|
|
|
|
2020-02-04 08:20:40 +01:00
|
|
|
var RevealAllSpoilersOption = (_ => {
|
|
|
|
return class RevealAllSpoilersOption {
|
|
|
|
getName () {return "RevealAllSpoilersOption";}
|
2019-02-01 12:37:27 +01:00
|
|
|
|
2020-05-19 17:14:26 +02:00
|
|
|
getVersion () {return "1.0.5";}
|
2019-02-01 12:37:27 +01:00
|
|
|
|
2020-02-04 08:20:40 +01:00
|
|
|
getAuthor () {return "DevilBro";}
|
2019-02-01 12:37:27 +01:00
|
|
|
|
2020-02-04 08:20:40 +01:00
|
|
|
getDescription () {return "Adds an entry to the message contextmenu to reveal all spoilers within a messageblock.";}
|
2019-02-01 12:37:27 +01:00
|
|
|
|
2020-02-04 08:20:40 +01:00
|
|
|
constructor () {
|
|
|
|
this.changelog = {
|
2020-05-19 17:14:26 +02:00
|
|
|
"fixed":[["Context Menu Update","Fixes for the context menu update, yaaaaaay"]]
|
2020-02-04 08:20:40 +01:00
|
|
|
};
|
|
|
|
}
|
2019-02-01 12:37:27 +01:00
|
|
|
|
|
|
|
|
2020-04-11 19:32:58 +02:00
|
|
|
// Legacy
|
2020-08-21 16:17:47 +02:00
|
|
|
load () {
|
|
|
|
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) BDFDB.PluginUtils.load(this);
|
|
|
|
}
|
2019-02-01 12:37:27 +01:00
|
|
|
|
2020-02-04 08:20:40 +01:00
|
|
|
start () {
|
|
|
|
if (!window.BDFDB) window.BDFDB = {myPlugins:{}};
|
|
|
|
if (window.BDFDB && window.BDFDB.myPlugins && typeof window.BDFDB.myPlugins == "object") window.BDFDB.myPlugins[this.getName()] = this;
|
|
|
|
let libraryScript = document.querySelector("head script#BDFDBLibraryScript");
|
|
|
|
if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) {
|
|
|
|
if (libraryScript) libraryScript.remove();
|
|
|
|
libraryScript = document.createElement("script");
|
|
|
|
libraryScript.setAttribute("id", "BDFDBLibraryScript");
|
|
|
|
libraryScript.setAttribute("type", "text/javascript");
|
|
|
|
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js");
|
|
|
|
libraryScript.setAttribute("date", performance.now());
|
|
|
|
libraryScript.addEventListener("load", _ => {this.initialize();});
|
|
|
|
document.head.appendChild(libraryScript);
|
|
|
|
}
|
|
|
|
else if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
|
|
|
|
this.startTimeout = setTimeout(_ => {
|
|
|
|
try {return this.initialize();}
|
|
|
|
catch (err) {console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not initiate plugin! " + err);}
|
|
|
|
}, 30000);
|
2019-02-01 12:37:27 +01:00
|
|
|
}
|
|
|
|
|
2020-02-04 08:20:40 +01:00
|
|
|
initialize () {
|
|
|
|
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
|
|
|
if (this.started) return;
|
|
|
|
BDFDB.PluginUtils.init(this);
|
|
|
|
}
|
|
|
|
else console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not load BD functions!");
|
2019-02-01 12:37:27 +01:00
|
|
|
}
|
|
|
|
|
2020-02-04 08:20:40 +01:00
|
|
|
stop () {
|
|
|
|
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
|
|
|
this.stopping = true;
|
2019-10-22 11:37:23 +02:00
|
|
|
|
2020-02-04 08:20:40 +01:00
|
|
|
BDFDB.PluginUtils.clear(this);
|
|
|
|
}
|
2019-02-01 12:37:27 +01:00
|
|
|
}
|
|
|
|
|
2019-09-04 12:34:02 +02:00
|
|
|
|
2020-04-11 19:32:58 +02:00
|
|
|
// Begin of own functions
|
2019-02-01 12:37:27 +01:00
|
|
|
|
2020-02-04 08:20:40 +01:00
|
|
|
onMessageContextMenu (e) {
|
|
|
|
if (e.instance.props.message && e.instance.props.target) {
|
2020-05-19 17:14:26 +02:00
|
|
|
let messageDiv = BDFDB.DOMUtils.getParent(BDFDB.dotCN.message, e.instance.props.target);
|
|
|
|
if (!messageDiv || !messageDiv.querySelector(BDFDB.dotCN.spoilerhidden)) return;
|
|
|
|
let hint = BDFDB.BDUtils.isPluginEnabled("MessageUtilities") ? BDFDB.BDUtils.getPlugin("MessageUtilities").getActiveShortcutString("__Reveal_Spoilers") : null;
|
2020-05-20 14:40:43 +02:00
|
|
|
let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "devmode-copy-id", group: true});
|
2020-05-20 11:55:46 +02:00
|
|
|
children.splice(index > -1 ? index : children.length, 0, BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, {
|
|
|
|
children: BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
|
2020-05-19 17:14:26 +02:00
|
|
|
label: "Reveal all Spoilers",
|
|
|
|
id: BDFDB.ContextMenuUtils.createItemId(this.name, "reveal-all"),
|
|
|
|
hint: hint && (_ => {
|
2020-05-20 14:40:43 +02:00
|
|
|
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MenuItems.MenuHint, {
|
2020-05-19 17:14:26 +02:00
|
|
|
hint: hint
|
|
|
|
});
|
|
|
|
}),
|
|
|
|
action: _ => {
|
|
|
|
this.revealAllSpoilers(messageDiv);
|
|
|
|
}
|
|
|
|
})
|
2020-02-04 08:20:40 +01:00
|
|
|
}));
|
|
|
|
}
|
2019-02-01 12:37:27 +01:00
|
|
|
}
|
2019-09-04 12:34:02 +02:00
|
|
|
|
2020-02-04 08:20:40 +01:00
|
|
|
revealAllSpoilers (target) {
|
2020-05-19 17:14:26 +02:00
|
|
|
let messageDiv = BDFDB.DOMUtils.getParent(BDFDB.dotCN.message, target);
|
|
|
|
if (!messageDiv) return;
|
|
|
|
for (let spoiler of messageDiv.querySelectorAll(BDFDB.dotCN.spoilerhidden)) spoiler.click();
|
2020-02-04 08:20:40 +01:00
|
|
|
}
|
2019-02-01 12:37:27 +01:00
|
|
|
}
|
2020-07-26 16:39:51 +02:00
|
|
|
})();
|
|
|
|
|
|
|
|
module.exports = RevealAllSpoilersOption;
|