mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 07:08:08 +02:00
Chrome extension: uses encodeURIComponent; fixes download button
This commit is contained in:
parent
e1c6bfd77b
commit
0c7d45bbfb
1 changed files with 12 additions and 2 deletions
|
@ -1,18 +1,28 @@
|
|||
<!doctype html>
|
||||
<script>
|
||||
|
||||
function isPdfDownloadable(details) {
|
||||
return details.url.indexOf('pdfjs.action=download') >= 0;
|
||||
}
|
||||
|
||||
chrome.webRequest.onBeforeRequest.addListener(
|
||||
function(details) {
|
||||
if (isPdfDownloadable(details))
|
||||
return;
|
||||
|
||||
var viewerPage = 'content/web/viewer.html';
|
||||
var url = chrome.extension.getURL(viewerPage) + '?file=' + details.url;
|
||||
var url = chrome.extension.getURL(viewerPage) +
|
||||
'?file=' + encodeURIComponent(details.url);
|
||||
return { redirectUrl: url };
|
||||
},
|
||||
{
|
||||
urls: [
|
||||
"http://*/*.pdf",
|
||||
"file://*/*.pdf",
|
||||
"file://*/*.pdf"
|
||||
],
|
||||
types: [ "main_frame" ]
|
||||
},
|
||||
["blocking"]);
|
||||
|
||||
</script>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue