3 ms·
Here is a bookmarklet I just wrote to look at all the links on a page and open any ending in ".pdf" in google's viewer. (if you have firefox set to open tabs fo
by _ck_ 17y ago
Here is a bookmarklet I just wrote to look at all the links on a page and open any ending in ".pdf" in google's viewer. (if you have firefox set to open tabs for windows, it will open them in new tabs) Feel free to share and improve.
- - - (select entire text and make into a link)
- - -
javascript:(function(){dl=document.links;for(i=0;i<dl.length;++i){if(dl[i].href.substr(-4)==".pdf"){window.open("http://docs.google.com/gview?embedded=true&url="+dl[i].href);}}})()
- - -
- chaosprophet 17y agoI made this into a greasemonkey userscript. It searches for PDF links on a page and sets them to open in Google's pdf viewer. Userscript at: http://userscripts.org/scripts/show/57453 http://userscripts.org/scripts/show/57453 Tested on Minefield latest nightly, winxp, greasemonkey.
- parterburn 17y agoThanks! It needs to not work on http://docs.google.com http://docs.google.com so that you can click the "Download" link if you need to...otherwise you are stuck in a loop. Also, I noticed that the search on the full-screen page isn't always available (ie http://bit.ly/4tf1xt http://bit.ly/4tf1xt)
- chaosprophet 17y agoAbout the search not being available, I think it's something to do with google's implementation, not the script. The other, I'll fix ASAP. Edit: Fixed version available now.
- Chramard 17y agoThis one transforms the links rather than opening them automatically. For pages with a lot of pdf links. javascript:(function(){dl=document.links;for(i=0;i<dl.length;++i){if(dl[i].href.substr(-4)==".pdf"){dl[i].href="http://docs.google.com/gview?embedded=true&url=+dl[i].href;}}})()
- roshanr 17y agoFixed a missing quote and added void(0) at the end: javascript:dl=document.links;for(i=0;i<dl.length;++i){if(dl[i].href.substr(-4)==".pdf"){dl[i].href="http://docs.google.com/gview?embedded=true&url="+dl[i].href;}}void(0);
- Corophazard 17y agoWithout the lambda, you run the risk of overwriting dl in the global scope, which could cause another script to misbehave.