Hack #40. Remove All Page Styles on Selected Sites

Disable all CSS styling on sites that go out of their way to make themselves unreadable.

Firefox has options to ignore fonts and colors defined on web pages, buried behind the Colors button in the Preferences window. These are global settings, and they affect every site you visit until you go back to the preferences dialog and change them. They're also deceptively incomplete; disabling page fonts will affect which font is used, but Firefox will still respect other font styles defined by the page: italics, bold, even font size. Firefox has an option (under View Page Style) to completely disable a page's style, but this is a temporary setting that resets as soon as you follow a link or refresh the page.

This hack aims for a middle ground. It disables all styles on selected sites, based on the list of pages you include in the script configuration.

The Code

This user script runs on all pages, but you will probably want to modify the @include line to include just the sites that annoy you (unless you really like browsing the Web as if it were 1992). This script removes three types of styling:

  • Styles defined in externally linked stylesheets. Firefox helpfully collects these in the document.styleSheets collection. (Note the camelCase capitalization!)

  • Styles defined in <style> elements in the <head> section of the page.

  • Styles defined on individual elements, either with the style attribute, or a wide variety of proprietary but supported attributes, ...

Get Greasemonkey Hacks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.