Changing a Page’s Styles

The previous example works fine if the background color of an offensive page is set in the page’s HTML. But it’s ineffective if the page uses style sheets to change the background color, or to apply a background image to a page element. This next bookmarklet (Script 17.3) replaces the CSS styles for a page’s background color, text color, and link colors. The background color changes to white and the text color to black; links will be blue; and visited links will be purple. You can see these sorts of changes in the example shown in Figures 17.14 and 17.15.

Figure 17.14. The original page can be a bit difficult to read, so we want to swap out the CSS styles to make it more readable.
Figure 17.15. ...

Get JavaScript and Ajax for the Web: Visual QuickStart Guide, Seventh Edition 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.