From c9eb4c2603397ce76f642516cf4f9c332e375973 Mon Sep 17 00:00:00 2001 From: Exentrich Date: Mon, 10 Feb 2020 17:48:13 +0300 Subject: [PATCH] Support PDF preview (only uploaded yet) --- package.json | 2 +- src/webView.js | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 1beee2b..64881cb 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "Raindrop.io", "productName": "Raindrop.io", - "version": "5.1.8", + "version": "5.1.9", "description": "Crossplatform bookmarking app", "main": "src/index.js", "repository": { diff --git a/src/webView.js b/src/webView.js index 49095d3..f49a9c9 100644 --- a/src/webView.js +++ b/src/webView.js @@ -20,7 +20,7 @@ app.on('web-contents-created', (e, contents) => { if (disposition == 'new-window') return shell.openExternal(url) - }) + }) } contents.on('will-attach-webview', (e, webPreferences, params) => { @@ -33,4 +33,13 @@ app.on('web-contents-created', (e, contents) => { // Disable Node.js integration webPreferences.nodeIntegration = false }) +}) + +app.on('session-created', (session) => { + session.on('will-download', (e, item, contents) => { + if (item.getMimeType() == 'application/pdf' && item.getURL().includes('up.raindrop.io')){ + e.preventDefault() + contents.executeJavaScript(`document.querySelector('iframe[src="${item.getURL()}"]').setAttribute('src', 'https://up.raindrop.io/pdfjs/web/viewer.html?file=${item.getURL()}')`) + } + }) }) \ No newline at end of file