diff options
author | Vijay Aravamudhan <vraravam@users.noreply.github.com> | 2022-05-23 05:55:44 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-23 10:55:44 +0000 |
commit | 4983daff125009865f8482388c37f69de8a610f7 (patch) | |
tree | 4f58493028c4a2ba683da79c32676b45590cda9c /recipes/discord/webview.js | |
parent | Support for self-hosted github (diff) | |
download | ferdium-recipes-4983daff125009865f8482388c37f69de8a610f7.tar.gz ferdium-recipes-4983daff125009865f8482388c37f69de8a610f7.tar.zst ferdium-recipes-4983daff125009865f8482388c37f69de8a610f7.zip |
Add new service-level option 'trapLinkUrls' (#30)
This option can be used to allow the user to choose how to handle links
(whether to open in the default browser or within the Ferdium service itself)
Removed incorrect 'if' condition for zoom and discord for clickHandler
Diffstat (limited to 'recipes/discord/webview.js')
-rw-r--r-- | recipes/discord/webview.js | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/recipes/discord/webview.js b/recipes/discord/webview.js index 7612d83..cadafb1 100644 --- a/recipes/discord/webview.js +++ b/recipes/discord/webview.js | |||
@@ -4,7 +4,8 @@ function _interopRequireDefault(obj) { | |||
4 | return obj && obj.__esModule ? obj : { default: obj }; | 4 | return obj && obj.__esModule ? obj : { default: obj }; |
5 | } | 5 | } |
6 | 6 | ||
7 | module.exports = Ferdium => { | 7 | module.exports = (Ferdium, settings) => { |
8 | console.log('settings', settings); | ||
8 | const getMessages = () => { | 9 | const getMessages = () => { |
9 | let directCount = 0; | 10 | let directCount = 0; |
10 | const directCountPerServer = document.querySelectorAll( | 11 | const directCountPerServer = document.querySelectorAll( |
@@ -34,9 +35,12 @@ module.exports = Ferdium => { | |||
34 | if (link || button) { | 35 | if (link || button) { |
35 | const url = link ? link.getAttribute('href') : button.getAttribute('title'); | 36 | const url = link ? link.getAttribute('href') : button.getAttribute('title'); |
36 | 37 | ||
37 | if (url.includes('views/imgpsh_fullsize_anim')) { | 38 | event.preventDefault(); |
38 | event.preventDefault(); | 39 | event.stopPropagation(); |
39 | event.stopPropagation(); | 40 | |
41 | if (settings.trapLinkClicks === true) { | ||
42 | window.location.href = url; | ||
43 | } else { | ||
40 | Ferdium.openNewWindow(url); | 44 | Ferdium.openNewWindow(url); |
41 | } | 45 | } |
42 | } | 46 | } |