Kill Images in NetNewsWire via CSS and Applescript

January 15th, 2008  |  Published in etc

Updated: Added the Ruby version of the script and changed the CSS to look for to reflect changes to NNW since I first wrote this. — 6/8/2010

I asked Newsgator to include the ability to toggle images on and off in NetNewsWire or at least include it as a thing I could get at via Applescript. A look at NNW’s scripting dictionary this morning seemed to indicate that no such ability is in there. There’s also no direct way to set NNW’s style through Applescript.

I don’t have some religious objection to images in RSS readers, but I really hate the huge, graceless globs of pixels some bloggers toss up regardless of the value they add to the text. But I don’t want to have to toggle images off across the board, either. Sometimes they’re useful.

io9 was the straw that broke the camel’s back with yet another ginormous image that pushed out a bunch of text. I broke down and set up style toggling in NNW with a combination of CSS and UI scripting so I could toggle without having to reach for the mouse and select an option from the dinky style menu NNW presents.

1. Make a Custom Style Sheet

NetNewsWire keeps all its styles in ~/Library/Application Support/NetNewsWire/StyleSheets/. They’re all called “*.nnwstyle,” and they’re bundles with a plist and a plain old CSS file called “stylesheet.css.”

I copied the default style (Default (3.1).nnwstyle) over to Default - Image Free.nnwstyle, right-clicked to “Show Package Contents” on the new .nnwstyle file, and opened the stylesheet.css file in an editor.

I added this selector:

    .newsItemDescription img {

    display: none;


Update: “newsItemDescription” is now an id, not a class, so use this for newer versions of NNW:

          #_newsItemDescription img {



I saved the file and doubleclicked the .nnwstyle file, which caused NNW to install it.

Here are before and after shots of NNW with the new stylesheet:

NNW with images (note weeping Baby Jesus)Image-free NNW. Note smiling Baby Jesus

2. UI Scripting to Toggle Stylesheets

Next up, I fired up Prefab UI Browser to figure out how to handle the UI scripting. The fruits of that are below.

Nutshell: return the value of the styles menu in the lower right corner of the NNW menu (note that you may need to toggle “Show Styles Menu” in the “View” menu), then click either the image-free or default style sheet.

Open this script in a new Script Editor window.

set myImageFreeCSS to "Default – Image Free"
set myDefaultCSS to "Default (3.1)"

activate application "NetNewsWire"
tell application "System Events"
    tell process "NetNewsWire"
set mySheet to get value of pop up button 1 of window 1
perform action "AXPress" of pop up button 1 of window 1
if mySheet is equal to myImageFreeCSS then
            perform action "AXPress" of menu item myDefaultCSS of menu 1 of pop up button 1 of window 1
            perform action "AXPress" of menu item myImageFreeCSS of menu 1 of pop up button 1 of window 1
        end if
    end tell
end tell

Because I’m feeling friendly and expansive, I made the stylesheets variables for easy modification.

2.5 Update: Or Do It the Ruby Way with rb-appscript:

#!/usr/bin/env ruby

require "rubygems"

require "appscript"

include Appscript

# Define your image free stylesheet and standard stylesheet

image_free = "ImageFree"

with_images = "Default (3.2)"

# Define some shortcuts to bits of the NNW interface

se = app("System Events")

nnw_process = se.processes["NetNewsWire"]

nnw_style_menu =[1].pop_up_buttons[1]


# Get the current style

active_css =[1].pop_up_buttons[1].value.get

active_css  == image_free ? new_css = with_images : new_css = image_free

# Open the styles menu and toggle the style



3. Connect It to a Keyboard Shortcut

Once I had a working script, I saved it in ~/Library/Scripts/Applications/NetNewsWire. I use Red Sweater’s FastScripts to assign keyboard shortcuts to scripts. So now ^⌘S toggles between styles.

Leave a Response

© Michael Hall, licensed under a Creative Commons Attribution-ShareAlike 3.0 United States license.