From 2a20d9b32e3c6082091da2180c7b15f3db7b56b1 Mon Sep 17 00:00:00 2001 From: Mirco Wittrien Date: Mon, 24 Oct 2022 10:12:01 +0200 Subject: [PATCH] stuff --- .../OpenSteamLinksInApp.plugin.js | 17 ++++++++++------ .../TopRoleEverywhere.plugin.js | 20 ++++++++++--------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/Plugins/OpenSteamLinksInApp/OpenSteamLinksInApp.plugin.js b/Plugins/OpenSteamLinksInApp/OpenSteamLinksInApp.plugin.js index ac9a200146..e8fa1beffa 100644 --- a/Plugins/OpenSteamLinksInApp/OpenSteamLinksInApp.plugin.js +++ b/Plugins/OpenSteamLinksInApp/OpenSteamLinksInApp.plugin.js @@ -2,7 +2,7 @@ * @name OpenSteamLinksInApp * @author DevilBro * @authorId 278543574059057154 - * @version 1.1.4 + * @version 1.1.5 * @description Opens Steam Links in Steam instead of your Browser * @invite Jx3TjNS * @donate https://www.paypal.me/MircoWittrien @@ -65,7 +65,7 @@ module.exports = (_ => { onStart () { 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 => { - if (!(e.currentTarget.className && e.currentTarget.className.indexOf(BDFDB.disCN.imagezoom) > -1)) this.openIn(e, key, e.currentTarget.href); + if (!(e.currentTarget.className && e.currentTarget.className.indexOf(BDFDB.disCN.imagezoom) > -1) && !BDFDB.DOMUtils.getParent(BDFDB.dotCN.imagezoom, e.currentTarget)) this.openIn(e, key, e.currentTarget.href); }); } @@ -82,10 +82,15 @@ module.exports = (_ => { } openInSteam (url) { - BDFDB.LibraryRequires.request(url, (error, response, body) => { - if (BDFDB.LibraryRequires.electron.shell.openExternal("steam://openurl/" + response.request.href)); - else BDFDB.DiscordUtils.openLink(response.request.href); - }); + const xhr = new XMLHttpRequest(); + xhr.open("GET", url, true); + xhr.onreadystatechange = function () { + if (xhr.readyState != 4) return; + let responseUrl = xhr.responseURL || url; + if (BDFDB.LibraryRequires.electron.shell.openExternal("steam://openurl/" + responseUrl)); + else BDFDB.DiscordUtils.openLink(responseUrl); + }; + xhr.send(null); } }; })(window.BDFDB_Global.PluginUtils.buildPlugin(changeLog)); diff --git a/Plugins/TopRoleEverywhere/TopRoleEverywhere.plugin.js b/Plugins/TopRoleEverywhere/TopRoleEverywhere.plugin.js index 086f144e04..9a9f087669 100644 --- a/Plugins/TopRoleEverywhere/TopRoleEverywhere.plugin.js +++ b/Plugins/TopRoleEverywhere/TopRoleEverywhere.plugin.js @@ -2,7 +2,7 @@ * @name TopRoleEverywhere * @author DevilBro * @authorId 278543574059057154 - * @version 3.0.9 + * @version 3.1.0 * @description Adds the highest Role of a User as a Tag * @invite Jx3TjNS * @donate https://www.paypal.me/MircoWittrien @@ -75,12 +75,14 @@ module.exports = (_ => { } }; - this.patchedModules = { - after: { - MemberListItem: "render", - MessageUsername: "default", - VoiceUser: "render" - } + this.modulePatches = { + before: [ + "MessageHeader" + ], + after: [ + "MemberListItem", + "VoiceUser" + ] }; this.patchPriority = 4; @@ -173,9 +175,9 @@ module.exports = (_ => { }); } - processMessageUsername (e) { + processMessageHeader (e) { if (!e.instance.props.message) return; - let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "Popout"}); + let [children, index] = BDFDB.ReactUtils.findParent(e.instance.props.username, {filter: n => n && n.props && typeof n.props.renderPopout == "function"}); if (index == -1) return; const author = e.instance.props.userOverride || e.instance.props.message.author; if (this.settings.places.chat) this.injectRoleTag(children, author, "chat", e.instance.props.compact ? index : (index + 2), {