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 | |
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
-rw-r--r-- | docs/frontend_api.md | 8 | ||||
-rw-r--r-- | recipes/discord/package.json | 2 | ||||
-rw-r--r-- | recipes/discord/webview.js | 9 | ||||
-rw-r--r-- | recipes/zoom/package.json | 2 | ||||
-rw-r--r-- | 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 @@ | |||
29 | - [safeParseInt(stringText)](#safeparseintstringtext) | 29 | - [safeParseInt(stringText)](#safeparseintstringtext) |
30 | - [Arguments](#arguments-8) | 30 | - [Arguments](#arguments-8) |
31 | - [Usage](#usage-8) | 31 | - [Usage](#usage-8) |
32 | - [isImage(url)](#isimageurl) | 32 | - [isImage(link)](#isimagelink) |
33 | - [Arguments](#arguments-9) | 33 | - [Arguments](#arguments-9) |
34 | - [Usage](#usage-9) | 34 | - [Usage](#usage-9) |
35 | - [setDialogTitle(title)](#setdialogtitletitle-1) | 35 | - [setDialogTitle(title)](#setdialogtitletitle-1) |
@@ -308,9 +308,9 @@ A utility method that can be used to safely parse the text content (handles null | |||
308 | Ferdium.safeParseInt(mySelector.innerText) | 308 | Ferdium.safeParseInt(mySelector.innerText) |
309 | ``` | 309 | ``` |
310 | 310 | ||
311 | ### isImage(url) | 311 | ### isImage(link) |
312 | 312 | ||
313 | 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. | 313 | 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. |
314 | 314 | ||
315 | #### Arguments | 315 | #### Arguments |
316 | 316 | ||
@@ -319,7 +319,7 @@ A utility method that can be used to verify if a url is an image. Returns `true` | |||
319 | #### Usage | 319 | #### Usage |
320 | 320 | ||
321 | ```JavaScript | 321 | ```JavaScript |
322 | Ferdium.isImage(url) | 322 | Ferdium.isImage(link) |
323 | ``` | 323 | ``` |
324 | 324 | ||
325 | ### setDialogTitle(title) | 325 | ### 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 @@ | |||
1 | { | 1 | { |
2 | "id": "discord", | 2 | "id": "discord", |
3 | "name": "Discord", | 3 | "name": "Discord", |
4 | "version": "1.7.6", | 4 | "version": "1.7.7", |
5 | "license": "MIT", | 5 | "license": "MIT", |
6 | "config": { | 6 | "config": { |
7 | "serviceURL": "https://discordapp.com/login", | 7 | "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) => { | |||
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 | ||
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 @@ | |||
1 | { | 1 | { |
2 | "id": "zoom", | 2 | "id": "zoom", |
3 | "name": "Zoom", | 3 | "name": "Zoom", |
4 | "version": "1.3.3", | 4 | "version": "1.3.4", |
5 | "license": "MIT", | 5 | "license": "MIT", |
6 | "config": { | 6 | "config": { |
7 | "serviceURL": "https://zoom.us/join", | 7 | "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) => { | |||
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 | 36 | ||
37 | if (!Ferdium.isImage(url)) { | 37 | if (!Ferdium.isImage(link)) { |
38 | event.preventDefault(); | 38 | event.preventDefault(); |
39 | event.stopPropagation(); | 39 | event.stopPropagation(); |
40 | 40 | ||