From c265c7991691828019c0a06c44f62a5d2d072c0f Mon Sep 17 00:00:00 2001 From: André Oliveira <37463445+SpecialAro@users.noreply.github.com> Date: Tue, 12 Jul 2022 23:35:09 +0100 Subject: Change isImage to link and stayInsideDiscord (#120) * Change isImage to URL and stayInsideDiscord * Fix comments --- docs/frontend_api.md | 8 ++++---- recipes/discord/package.json | 2 +- recipes/discord/webview.js | 9 +++++++-- recipes/zoom/package.json | 2 +- recipes/zoom/webview.js | 4 ++-- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/docs/frontend_api.md b/docs/frontend_api.md index f1edc0f..b40ae76 100644 --- a/docs/frontend_api.md +++ b/docs/frontend_api.md @@ -29,7 +29,7 @@ - [safeParseInt(stringText)](#safeparseintstringtext) - [Arguments](#arguments-8) - [Usage](#usage-8) - - [isImage(url)](#isimageurl) + - [isImage(link)](#isimagelink) - [Arguments](#arguments-9) - [Usage](#usage-9) - [setDialogTitle(title)](#setdialogtitletitle-1) @@ -308,9 +308,9 @@ A utility method that can be used to safely parse the text content (handles null Ferdium.safeParseInt(mySelector.innerText) ``` -### isImage(url) +### isImage(link) -A utility method that can be used to verify if a url is an image. Returns `true` if is image and `false` if it is not an image. +A utility method that can be used to verify if a link is an image. Returns `true` if is image and `false` if it is not an image. #### Arguments @@ -319,7 +319,7 @@ A utility method that can be used to verify if a url is an image. Returns `true` #### Usage ```JavaScript -Ferdium.isImage(url) +Ferdium.isImage(link) ``` ### setDialogTitle(title) diff --git a/recipes/discord/package.json b/recipes/discord/package.json index aed7ab6..fe2b078 100644 --- a/recipes/discord/package.json +++ b/recipes/discord/package.json @@ -1,7 +1,7 @@ { "id": "discord", "name": "Discord", - "version": "1.7.6", + "version": "1.7.7", "license": "MIT", "config": { "serviceURL": "https://discordapp.com/login", 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) => { if (link || button) { const url = link ? link.getAttribute('href') : button.getAttribute('title'); - const stayInsideDiscord = url.includes('https://discordapp.com/channels/'); + const skipDomains = [/^https:\/\/discordapp\.com\/channels\//i, /^https:\/\/discord\.com\/channels\//i]; - if (!Ferdium.isImage(url) && !stayInsideDiscord) { + skipDomains.every(skipDomain => { + stayInsideDiscord = skipDomain.test(url); + return !stayInsideDiscord; + }); + + if (!Ferdium.isImage(link) && !stayInsideDiscord) { event.preventDefault(); event.stopPropagation(); diff --git a/recipes/zoom/package.json b/recipes/zoom/package.json index 5357394..2982a9d 100644 --- a/recipes/zoom/package.json +++ b/recipes/zoom/package.json @@ -1,7 +1,7 @@ { "id": "zoom", "name": "Zoom", - "version": "1.3.3", + "version": "1.3.4", "license": "MIT", "config": { "serviceURL": "https://zoom.us/join", diff --git a/recipes/zoom/webview.js b/recipes/zoom/webview.js index 1255675..45cc5b7 100644 --- a/recipes/zoom/webview.js +++ b/recipes/zoom/webview.js @@ -33,8 +33,8 @@ module.exports = (Ferdium, settings) => { if (link || button) { const url = link ? link.getAttribute('href') : button.getAttribute('title'); - - if (!Ferdium.isImage(url)) { + + if (!Ferdium.isImage(link)) { event.preventDefault(); event.stopPropagation(); -- cgit v1.2.3-70-g09d2