Skip to content

Commit

Permalink
Support PDF preview (only uploaded yet)
Browse files Browse the repository at this point in the history
  • Loading branch information
Exentrich authored and Exentrich committed Feb 10, 2020
1 parent 51cea68 commit c9eb4c2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
11 changes: 10 additions & 1 deletion src/webView.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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()}')`)
}
})
})

0 comments on commit c9eb4c2

Please sign in to comment.