diff options
Diffstat (limited to 'recipes/telegram/webview.js')
-rw-r--r-- | recipes/telegram/webview.js | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/recipes/telegram/webview.js b/recipes/telegram/webview.js index 544a573..288160a 100644 --- a/recipes/telegram/webview.js +++ b/recipes/telegram/webview.js | |||
@@ -4,7 +4,7 @@ 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 | const telegramVersion = document | 8 | const telegramVersion = document |
9 | .querySelector('meta[property="og:url"]') | 9 | .querySelector('meta[property="og:url"]') |
10 | ?.getAttribute('content'); | 10 | ?.getAttribute('content'); |
@@ -82,4 +82,25 @@ module.exports = Ferdium => { | |||
82 | Ferdium.loop(loopFunc); | 82 | Ferdium.loop(loopFunc); |
83 | 83 | ||
84 | Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); | 84 | Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); |
85 | |||
86 | // TODO: See how this can be moved into the main ferdium app and sent as an ipc message for opening with a new window or same Ferdium recipe's webview based on user's preferences | ||
87 | document.addEventListener('click', event => { | ||
88 | const link = event.target.closest('a[href^="http"]'); | ||
89 | const button = event.target.closest('button[title^="http"]'); | ||
90 | |||
91 | if (link || button) { | ||
92 | const url = link ? link.getAttribute('href') : button.getAttribute('title'); | ||
93 | |||
94 | if (!Ferdium.isImage(link)) { | ||
95 | event.preventDefault(); | ||
96 | event.stopPropagation(); | ||
97 | |||
98 | if (settings.trapLinkClicks === true) { | ||
99 | window.location.href = url; | ||
100 | } else { | ||
101 | Ferdium.openNewWindow(url); | ||
102 | } | ||
103 | } | ||
104 | } | ||
105 | }, true); | ||
85 | }; | 106 | }; |