Created
January 24, 2010 13:26
-
-
Save otsune/285202 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name PDF/PPT viewer with Google docs | |
// @namespace http://www.otsune.com/ | |
// @include http://* | |
// @include https://* | |
// @exclude http://docs.google.com/* | |
// @version 0.3 | |
// ==/UserScript== | |
// Based on http://d.hatena.ne.jp/blooo/20100118/1263818555 | |
// http://coderepos.org/share/browser/lang/javascript/userscripts/pdfppt_viewer_with_google.user.js? | |
(function() { | |
if (location.hostname == "docs.google.com") return; | |
function handle(node){ | |
var items = node.querySelectorAll('a[href$=".pdf"], a[href$=".ppt"]'); | |
for (var i = 0; i < items.length; i++) { | |
var item = items[i]; | |
if ( (item.hostname != "docs.google.com") && | |
(item.hostname != "b.hatena.ne.jp") ) { | |
var ico = document.createElement("img"); | |
ico.src = "http://docs.google.com/favicon.ico"; | |
item.parentNode.insertBefore(ico, item); | |
item.href = 'http://docs.google.com/viewer?url=' + item.href; | |
} | |
} | |
} | |
document.body.addEventListener('AutoPagerize_DOMNodeInserted',function(evt){ | |
var node = evt.target; | |
handle(node); | |
}, false); | |
handle(document); | |
})(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment