2018-10-11 10:21:26 +02:00
|
|
|
module.exports = (Plugin, Api, Vendor) => {
|
|
|
|
if (typeof BDFDB !== "object") global.BDFDB = {$: Vendor.$, BDv2Api: Api};
|
|
|
|
|
|
|
|
const {$} = Vendor;
|
|
|
|
|
|
|
|
return class extends Plugin {
|
|
|
|
onStart () {
|
|
|
|
var libraryScript = null;
|
|
|
|
if (typeof BDFDB !== "object" || typeof BDFDB.isLibraryOutdated !== "function" || BDFDB.isLibraryOutdated()) {
|
|
|
|
libraryScript = document.querySelector('head script[src="https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.js"]');
|
|
|
|
if (libraryScript) libraryScript.remove();
|
|
|
|
libraryScript = document.createElement("script");
|
|
|
|
libraryScript.setAttribute("type", "text/javascript");
|
|
|
|
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.js");
|
|
|
|
document.head.appendChild(libraryScript);
|
|
|
|
}
|
|
|
|
this.startTimeout = setTimeout(() => {this.initialize();}, 30000);
|
|
|
|
if (typeof BDFDB === "object" && typeof BDFDB.isLibraryOutdated === "function") this.initialize();
|
|
|
|
else libraryScript.addEventListener("load", () => {this.initialize();});
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
initialize () {
|
|
|
|
if (typeof BDFDB === "object") {
|
|
|
|
BDFDB.loadMessage(this);
|
|
|
|
|
|
|
|
$(document).on("click." + this.name, "a[href^='https://steamcommunity.com/profiles/']", (e) => {
|
|
|
|
if (require("electron").shell.openExternal("steam://openurl/" + e.currentTarget.href)) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopImmediatePropagation();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else {
|
2019-01-24 13:37:08 +01:00
|
|
|
console.error(`%c[${this.name}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
|
2018-10-11 10:21:26 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
onStop () {
|
|
|
|
if (typeof BDFDB === "object") {
|
|
|
|
$(document).off("click." + this.name, "a[href^='https://steamcommunity.com/profiles/']");
|
|
|
|
|
|
|
|
BDFDB.unloadMessage(this);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|