2019-01-31 17:06:48 +01:00
|
|
|
//META{"name":"SteamProfileLink","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/SteamProfileLink","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/SteamProfileLink/SteamProfileLink.plugin.js"}*//
|
2018-10-11 10:21:26 +02:00
|
|
|
|
|
|
|
class SteamProfileLink {
|
|
|
|
getName () {return "SteamProfileLink";}
|
|
|
|
|
2019-01-17 23:48:29 +01:00
|
|
|
getVersion () {return "1.0.5";}
|
2018-10-11 10:21:26 +02:00
|
|
|
|
|
|
|
getAuthor () {return "DevilBro";}
|
|
|
|
|
2019-01-17 23:48:29 +01:00
|
|
|
getDescription () {return "Opens any Steam links in Steam instead of your internet browser.";}
|
|
|
|
|
2018-10-11 10:21:26 +02:00
|
|
|
//legacy
|
|
|
|
load () {}
|
|
|
|
|
|
|
|
start () {
|
2019-02-04 09:13:15 +01:00
|
|
|
if (!global.BDFDB) global.BDFDB = {myPlugins:{}};
|
|
|
|
if (global.BDFDB && global.BDFDB.myPlugins && typeof global.BDFDB.myPlugins == "object") global.BDFDB.myPlugins[this.getName()] = this;
|
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());
|
2019-01-30 21:23:49 +01:00
|
|
|
libraryScript.addEventListener("load", () => {if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) 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) {
|
2019-01-22 11:05:54 +01:00
|
|
|
if (this.started) return;
|
2018-10-11 10:21:26 +02:00
|
|
|
BDFDB.loadMessage(this);
|
2019-01-26 22:45:19 +01:00
|
|
|
|
2019-01-17 23:48:29 +01:00
|
|
|
BDFDB.addEventListener(this, document, "click", "a[href^='https://steamcommunity.'],a[href^='https://store.steampowered.']", e => {
|
|
|
|
e.originalEvent.preventDefault();
|
|
|
|
e.originalEvent.stopImmediatePropagation();
|
2018-12-18 14:05:53 +01:00
|
|
|
if (require("electron").shell.openExternal("steam://openurl/" + e.currentTarget.href));
|
|
|
|
else window.open(e.currentTarget.href, "_blank");
|
2018-10-11 10:21:26 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
stop () {
|
2019-01-26 22:45:19 +01:00
|
|
|
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
2018-10-11 10:21:26 +02:00
|
|
|
BDFDB.unloadMessage(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|