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