while i really like the digital guardian, one feature of it that i really don’t like is the stupid pop-up window when displaying an article or a page as PDF — i’ve got a really nice PDF viewer (kpdf) and don’t really like embedded PDF pages…so, when i stumbled the other day over the firefox extension greasemonkey it sounded like just the tool to get rid of those annoying PDF pop-up windows.
greasemonkey allows you to write little pieces of javascript that get executed for either specific or all web pages after they’ve been loaded but before they get displayed. actually, “little pieces of javascript” is probably an understatement as one can do quite powerful stuff with this tool. probably the best tutorial is the diveintogreasemonkey tutorial by mark pilgrim. after a little hitch — when specifying the URL(s) for which a greasemonkey script should trigger, you need to specify either the whole URL or a regular expression, just the base URL won’t do — i had my itch scratched. here’s the greasemonkey script that disables the PDF-pop-ups on the digital guardian web site:
// digitalguardiannopdfwindows.user.js// version 1.0 // 2005-05-22// Copyright © 2005, Dirk Husemann// Released under the GPL license// http://www.gnu.org/copyleft/gpl.html//// --------------------------------------------------------------------//// This is a Greasemonkey user script. To install it, you need// Greasemonkey 0.3 or later: http://greasemonkey.mozdev.org/// Then restart Firefox and revisit this script.// Under Tools, there will be a new menu item to "Install User Script".// Accept the default configuration and install.//// To uninstall, go to Tools/Manage User Scripts,// select "Digital Guardian: No PDF windows", and click Uninstall.//// --------------------------------------------------------------------//// ==UserScript==// @name Digital Guardian: No PDF windows// @namespace http://d2h.net/// @description greasemonkey script to prevent digital guardian pages// from opening PDF in their own window// @include http://digital.guardian.co.uk/guardian/*// @include http://digital.guardian.co.uk/observer/*// ==/UserScript==window.openPagePdf = window.openPagePdfLocally;window.openStoryPdf = window.openStoryPdfLocally;
what am i doing here? well, the digital guardian and observer websites use a javascript based layout system to display the digital guardian and observer content. they have two functions for displaying PDF pages: openPagePdf() and openPagePdfLocally(). the former is the one that causes a pop-up to appear while the latter is just opening it — which is what i want.
funnily enough they use both functions for the PDF link: if you open the link by clicking on it, openPagePdf() gets used (ouch), if you open it in a different way (moving focus to it and then hitting the enter key?), openPagePdfLocally() is invoked. as i don’t want the pop-up-window variant, all i had to do was to redefine openPagePdf() as openPagePdfLocally() which these two lines of javascript do:
window.openPagePdf = window.openPagePdfLocally;window.openStoryPdf = window.openStoryPdfLocally;
(the second line does the same thing for story PDFs.
if you have the same itch to scratch, you can install my greasemonky script from here (obviously you need greasemonkey installed first
