pdf.js/extensions/chrome/pdfHandler.html

29 lines
567 B
HTML
Raw Normal View History

2011-10-19 02:43:43 +09:00
<!doctype html>
<script>
function isPdfDownloadable(details) {
return details.url.indexOf('pdfjs.action=download') >= 0;
}
chrome.webRequest.onBeforeRequest.addListener(
2011-10-19 02:43:43 +09:00
function(details) {
if (isPdfDownloadable(details))
return;
2011-11-08 00:01:50 +09:00
var viewerPage = 'content/web/viewer.html';
var url = chrome.extension.getURL(viewerPage) +
'?file=' + encodeURIComponent(details.url);
2011-10-19 02:43:43 +09:00
return { redirectUrl: url };
},
{
urls: [
"http://*/*.pdf",
"file://*/*.pdf"
2011-10-19 02:43:43 +09:00
],
types: [ "main_frame" ]
},
["blocking"]);
2011-10-19 02:43:43 +09:00
</script>