Update OpenSteamLinksInApp.plugin.js

This commit is contained in:
Mirco Wittrien 2021-08-17 16:40:16 +02:00
parent 3f0de2a396
commit 1e0e8c3bd1
1 changed files with 10 additions and 8 deletions

View File

@ -2,7 +2,7 @@
* @name OpenSteamLinksInApp
* @author DevilBro
* @authorId 278543574059057154
* @version 1.1.2
* @version 1.1.3
* @description Opens Steam Links in Steam instead of your Browser
* @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien
@ -17,8 +17,13 @@ module.exports = (_ => {
"info": {
"name": "OpenSteamLinksInApp",
"author": "DevilBro",
"version": "1.1.2",
"version": "1.1.3",
"description": "Opens Steam Links in Steam instead of your Browser"
},
"changeLog": {
"fixed": {
"HTTP Links": "Also works with http links and not only with https links"
}
}
};
@ -76,9 +81,7 @@ module.exports = (_ => {
onLoad () {}
onStart () {
for (let key in urls) BDFDB.ListenerUtils.add(this, document, "click", urls[key].map(url => url.indexOf("http") == 0 ? `a[href^="${url}"]` : `a[href*="${url}"][href*="${key}"]`).join(", "), e => {
this.openIn(e, key, e.currentTarget.href);
});
for (let key in urls) BDFDB.ListenerUtils.add(this, document, "click", BDFDB.ArrayUtils.removeCopies(urls[key].map(url => url.indexOf("http") == 0 ? (url.indexOf("https://") == 0 ? [`a[href^="${url}"]`, `a[href^="${url.replace(/https:\/\//i, "http://")}"]`] : `a[href^="${url}"]`) : `a[href*="${url}"][href*="${key}"]`).flat(10).filter(n => n)).join(", "), e => this.openIn(e, key, e.currentTarget.href));
}
onStop () {}
@ -95,11 +98,10 @@ module.exports = (_ => {
openInSteam (url) {
BDFDB.LibraryRequires.request(url, (error, response, body) => {
if (error) return;
else if (BDFDB.LibraryRequires.electron.shell.openExternal("steam://openurl/" + response.request.href));
if (BDFDB.LibraryRequires.electron.shell.openExternal("steam://openurl/" + response.request.href));
else BDFDB.DiscordUtils.openLink(response.request.href);
});
}
};
})(window.BDFDB_Global.PluginUtils.buildPlugin(config));
})();
})();