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 * @name OpenSteamLinksInApp
* @author DevilBro * @author DevilBro
* @authorId 278543574059057154 * @authorId 278543574059057154
* @version 1.1.2 * @version 1.1.3
* @description Opens Steam Links in Steam instead of your Browser * @description Opens Steam Links in Steam instead of your Browser
* @invite Jx3TjNS * @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien * @donate https://www.paypal.me/MircoWittrien
@ -17,8 +17,13 @@ module.exports = (_ => {
"info": { "info": {
"name": "OpenSteamLinksInApp", "name": "OpenSteamLinksInApp",
"author": "DevilBro", "author": "DevilBro",
"version": "1.1.2", "version": "1.1.3",
"description": "Opens Steam Links in Steam instead of your Browser" "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 () {} onLoad () {}
onStart () { 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 => { 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));
this.openIn(e, key, e.currentTarget.href);
});
} }
onStop () {} onStop () {}
@ -95,8 +98,7 @@ module.exports = (_ => {
openInSteam (url) { openInSteam (url) {
BDFDB.LibraryRequires.request(url, (error, response, body) => { BDFDB.LibraryRequires.request(url, (error, response, body) => {
if (error) return; if (BDFDB.LibraryRequires.electron.shell.openExternal("steam://openurl/" + response.request.href));
else if (BDFDB.LibraryRequires.electron.shell.openExternal("steam://openurl/" + response.request.href));
else BDFDB.DiscordUtils.openLink(response.request.href); else BDFDB.DiscordUtils.openLink(response.request.href);
}); });
} }