As part of my high-volume web reading habits, I click through to the print versions of articles whenever possible. Annoyingly, sites will often use JavaScript to automatically make the page print. Here’s a simple way to stop it.
- Download and install GlimmerBlocker.
- Create a new Filter group (top left of preference pane).
- Add a new Rule.
- Set the Action to “Whitelist URL, optionally modifying content”.
- Set Host: to “all hosts”.
- Go to the transform tab.
- Paste in the following text:
replace(/(window|self)\.print(\(\))?;/, ""); - Save the rule.
The regex here will look for window.print or self.print (with or
without parentheses) and strip it, thereby stopping the automatic print
command.
I forget exactly how I came up with this, but it works great.
UPDATE: an improved version is available.