53 lines
1.7 KiB
JavaScript
53 lines
1.7 KiB
JavaScript
//META{"name":"SteamProfileLink"}*//
|
|
|
|
class SteamProfileLink {
|
|
|
|
getName () {return "SteamProfileLink";}
|
|
|
|
getDescription () {return "Opens any Steam links in Steam instead of your internet browser.";}
|
|
|
|
getVersion () {return "1.0.4";}
|
|
|
|
getAuthor () {return "DevilBro";}
|
|
|
|
//legacy
|
|
load () {}
|
|
|
|
start () {
|
|
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();});
|
|
}
|
|
|
|
initialize () {
|
|
if (typeof BDFDB === "object") {
|
|
BDFDB.loadMessage(this);
|
|
|
|
$(document).on("click." + this.getName(), "a[href^='https://steamcommunity.'],a[href^='https://store.steampowered.']", (e) => {
|
|
e.preventDefault();
|
|
e.stopImmediatePropagation();
|
|
if (require("electron").shell.openExternal("steam://openurl/" + e.currentTarget.href));
|
|
else window.open(e.currentTarget.href, "_blank");
|
|
});
|
|
}
|
|
else {
|
|
console.error(this.getName() + ": Fatal Error: Could not load BD functions!");
|
|
}
|
|
}
|
|
|
|
|
|
stop () {
|
|
if (typeof BDFDB === "object") {
|
|
BDFDB.unloadMessage(this);
|
|
}
|
|
}
|
|
} |