diff options
author | André Oliveira <37463445+SpecialAro@users.noreply.github.com> | 2022-07-12 23:35:09 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-12 23:35:09 +0100 |
commit | c265c7991691828019c0a06c44f62a5d2d072c0f (patch) | |
tree | 0d1563f8d8a4f12d04a3d65c23582ca58863021d /recipes/discord/webview.js | |
parent | Fix facebook notifications counter (#118) (diff) | |
download | ferdium-recipes-c265c7991691828019c0a06c44f62a5d2d072c0f.tar.gz ferdium-recipes-c265c7991691828019c0a06c44f62a5d2d072c0f.tar.zst ferdium-recipes-c265c7991691828019c0a06c44f62a5d2d072c0f.zip |
Change isImage to link and stayInsideDiscord (#120)
* Change isImage to URL and stayInsideDiscord
* Fix comments
Diffstat (limited to 'recipes/discord/webview.js')
-rw-r--r-- | recipes/discord/webview.js | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/recipes/discord/webview.js b/recipes/discord/webview.js index 3ad4a60..bfd0683 100644 --- a/recipes/discord/webview.js +++ b/recipes/discord/webview.js | |||
@@ -33,9 +33,14 @@ module.exports = (Ferdium, settings) => { | |||
33 | 33 | ||
34 | if (link || button) { | 34 | if (link || button) { |
35 | const url = link ? link.getAttribute('href') : button.getAttribute('title'); | 35 | const url = link ? link.getAttribute('href') : button.getAttribute('title'); |
36 | const stayInsideDiscord = url.includes('https://discordapp.com/channels/'); | 36 | const skipDomains = [/^https:\/\/discordapp\.com\/channels\//i, /^https:\/\/discord\.com\/channels\//i]; |
37 | 37 | ||
38 | if (!Ferdium.isImage(url) && !stayInsideDiscord) { | 38 | skipDomains.every(skipDomain => { |
39 | stayInsideDiscord = skipDomain.test(url); | ||
40 | return !stayInsideDiscord; | ||
41 | }); | ||
42 | |||
43 | if (!Ferdium.isImage(link) && !stayInsideDiscord) { | ||
39 | event.preventDefault(); | 44 | event.preventDefault(); |
40 | event.stopPropagation(); | 45 | event.stopPropagation(); |
41 | 46 | ||