Friday, April 3, 2009

A Filter for Salon Letters (Important Update below — 9/15/09) (Updated again — 11/10/09)

In view of the vitriolic and acerbic nature of the comment section of Glenn's recent postings at UT, many commenters have asked for a filter to remove certain authors' letters from the comment thread. It got so bad, that one commenter was ready to kill:
Baring that, I'd kill for a "ignore" or "filter" option. At least that way I can completely skip the crap and not waste the time and bytes downloading text I'm not going to read.
KB4Hire

At the time, I said that I was too busy to take the necessary steps to produce such a filter, but this is the kind of simple programming task that I just can't pass up. So I brushed up my javascript and read a book on Greasemonkey and then wasted a day of my life writing a Q&D® filter to remove letters from specified authors from comments pages. It turns out it was about as simple as I predicted. And while it doesn't save on downloading, because you have to download the letters before you check and eliminate them, it does mean that you don't have to read the vitriol and invective that some people seem to be incapable of excluding from their writing. This will be a boon to those with peptic ulcers and high blood pressure.

The file is salonletterfilter.user.js, and, if you already have the Greasemonkey add-on for Firefox installed and active, it can be installed simply by clicking on the file name and selecting "Install" when the Greasemonkey dialog panel appears. If you don't already have Greasemonkey, install it by clicking on the link. If you're using Internet Explorer, eat your heart out.

Note that there is some manual configuration necessary to make the script functional. After installing the script, open the Greasemonkey "Manage User Scripts" dialog either by right-clicking on the Greasemonkey icon in the status bar at the bottom of your browser window or from the browser's "Tools" menu. Once the dialog panel is open, select "Salon Letter Filter" and click on "Edit". This will open the script in your designated text editor. Then go to the first line of the script that is not a comment (i.e., does not begin with "//") and replace the word "authors" with your kill list. Use a comma to separate individual authors if you want to exclude more than one author. Save the file, and the next time you open a Salon letters page, letters from the authors listed in "killfile" will be deleted.

The configured version is fairly "polite" in that it leaves behind a notice that a letter from a particular author has been deleted, the permalink to the message (as an icon) and the datestamp. As a less polite option, there is also a more vicious version that removes letters completely. To implement this, edit the script and in the last line of the code (//thisLet.innerHTML = "";) delete the "//" at the beginning. Unwanted letters will disappear without a trace.

You can, of course, retrieve deleted letters by editing the "killfile" variable at any time. And there is no need to uninstall the script if you no longer wish to have a killfile. Simply set the variable "killfile" to an empty string ('') and the script will stop. The only thing to keep in mind is that the "killfile" variable is used to create a regular expression so regular expression metacharacters have to have a backslash ("\") in front of them for the script to work properly.

[Disclaimer: No warranty, expressed or implied, is associated with this script. The use of this script is entirely at the user's risk. This offer void where prohibited by law.]

UPDATE: While we were sleeping, Salon changed the format of their letters pages (obviously to make them less readable than they were before). This means that the old version of the Salon Letters Filter no longer works. I have revised the Greasemonkey script and it is still available through the link above in this posting. In order to install the new version you will have to first delete the old one. For those who are unable to access the script through the link, the text of the new script is now available.

LATER UPDATE: Salon has mercifully restored the previous letters settings. There is now no need for version 0.0.2 of the Salon Letter Filter and the original version works fine. That is all.

STILL LATER UPDATE: Salon has now changed the format of their letter pages in conformance with their new beta "business model". This change is likely to be permanent. The text of the new script for the beta layout is now available. The link to a downloadable version of the script no longer works.

23 comments:

Karen M said...

Hallelujah! Thank you, Frankly, My Dear!

Guess I'll have to reinstall Firefox at home. I use both at work, but the last time I had to have some stuff done to my laptop, I didn't have Firefox reinstalled, because there were a few things I had to use IE for (and I hate MS!).

Frankly, my dear, ... said...

Okay. I'm hoping that this works with Firefox 3.0 and up. I haven't installed that at home because the Repagination add-on is incompatible with FF 3 and Repagination is something I find very useful with the Salon nonsense of 10-11 letters on a page. Repagination runs all the letters onto one page — essential for searching the letters.
On the other hand, I think this new script doesn't work with Repagination. It seems to only delete letters on the first page.

Paul Daniel Ash said...

You are made of win. -- PDA

Unknown said...

You rock the house, Frankly, my dear,...

Thanks for doing this. What's going to be interesting, I think, is to see what effect the mere availability of a kill file will be on Glenn's threads. Does anyone really want to be relegated to a kill file?

I think this is going to be a lot of fun to watch. I suspect to give it the cachet of a "visible cop on the corner" it would need to be mentioned in the next couple of threads. But, I assume that some of the worst habitual offenders of civility will take note. And, when they notice no one takes the bait, they can wonder whether they're being ignored, or if they're invisible.

I pop a champagne cork in your honor, Sir. Well done.

Frankly, my dear, ... said...

PDA: Thanks. We're fine until the next time Salon changes its letter format.

Bystander.noch.einmal: Thanks, but I didn't do it just for you guys. I've wanted one of these for a long time in order to bypass a certain few posters who never have anything substantive to say but insist on saying it anyway. Things have just gotten so bad in the past couple of weeks that it no longer seemed like a nice-to-have but a need-to-have. Some of the commentary in the recent threads has literally turned my stomach. I don't need that. There are some people that I can never read again and not miss.

Karen M said...

Ditto. I know I won't miss them. I can't wait til I get home and can try this out.

John Cowan said...

Karen M.: Firefox for Windows has the wonderful IETab add-on. Normally, you surf in Firefox. If you have a problem, just click on the little blue IE icon that gets installed in Firefox's bottom bar, and bingo, you are seeing the page in an IE subframe inside the Firefox main window. Other tabs aren't disturbed in any way.

It's wonderful for dealing with recalcitrant banks and such, and also for Windows Update/Microsoft Update.

Karen M said...

Thanks, John. It's not usually for surfing that I have those problems, but for times when I actually have to do something on a site. More often, work-related, which is why I have both at work. My laptop, though, is older, and I've been trying to keep the real estate under control. And I like to be able to do work from home, just in case of a blizzard or something like that. I used to have both on there. Maybe I'll go back to that.

and so they say said...

Frankly, my dear,
The greasemonkey script is only allowing me to use one name. As soon as I add additional names separated with a comma, the script stops working. I'm using Firefox 3.08 any ideas??

KB4Hire said...

For those who don't know, there is an unofficial hack by the original author of the "repagination" add-on for Firefox 3.x and the Mozilla family of browsers.

Hit google and use the search string repagination for Firefox 3 or send me an email and I'll shoot you off a copy.

-- kb4hire@gmail.com

PS: Thanks to Frankly ... for the fine work with GreaseMonkey!

PSS: I guess I can quit sharpening my pitchfork as of now!

:-)

and so they say said...

Frankly, my dear,
I worked out my script issue, all is well. Thanks very much for this.

Frankly, my dear, ... said...

and so they say: I can't say offhand what the problem might be. I tested it with up to four names and it worked fine. There's a debugging check that I left in that might help. Edit the script and in the second line of the block of code after the definition of the xpath function you'll see "myGM_log(myregexp);". Remove "myGM_log" and replace it with "alert" so that the line reads "alert(myregexp);". That should give you an alert box with the regexp that is being used. This should tell you what the problem is (if the program gets that far). If it doesn't, you're doing something that creates an empty string in "killfile".

Frankly, my dear, ... said...

KB4Hire: Thanks for the heads-up. I found it easily enough once I knew what to look for. It's the "unofficial" part that threw me. Firefox 3 just keeps telling me that there is no upward compatible version of repagination when what they mean is there is no "official" version.

Pedinska said...

Frankly, is this usable with safari? I quit using firefox because I don't like keeping more than one version of a browser open on my old G4, which is extraordinarily prone to hosing. Work email uses Outlook and Firefox didn't work well with it so I resorted to using safari and haven't had any problems since.

I am not at all informed about computers, so a lot of what I have read above is the equivalent of a foreign language.....can you explain in pidgin? ;-}

I Firefox is the only one I can use, then I'll just have to use that for reading UT.

Frankly, my dear, ... said...

Pedinska: The equivalent of Greasemonkey for Safari is called Greasekit.

It's supposed to handle most Greasemonkey scripts, but I have no idea of whether it can run this one. Again, it depends on how xpath is implemented in Safari (you can ignore everything in this sentence after "it depends").

Unknown said...

Thank you!!! I barely have time to read Glenn's posts, let alone the comments. How wonderful to be able to filter out all the noise. Though, I'm having a problem downloading it - I'm getting this: Error loading user script: 404: Not Found

Hope it's only the link and not me ;-)

Frankly, my dear, ... said...

EJ: I don't have any problem accessing the file, and since many people have obviously been able to access the script in its present location, I suspect that the reason that you and others have been getting a 404 error has to do with your browser configuration, particularly the cookies setting. Since the site where the script is is commercial, I imagine that it tries to set a cookie when you try to access the file and then blocks access if it can't.

If you are using Firefox, try setting your options to accept cookies and then try to install the script. If you are successful, you can always remove the cookie after you are finished.

Unknown said...

Thanks, Frankly. It turns out not to be a cookie problem. Maybe it's because I'm also using the repagination script. I can't live without that one, though :-)

Frankly, my dear, ... said...

EJ: Yes, adnoto reports the same thing. Sorry, I don't know what else to try. The script is presently located on a Yahoo Groups page and while access to the page itself is limited to group members, accessing a file from the page by URL should be open to anyone. The membership of the group is small, so the number of people who have been able to install the script with the link indicates that non-membership is not the issue. For a while I thought that being signed in to Yahoo might make the difference, but I tried signing out and I could still access the script.

Repagination can't have anything to do with it because I'm using it without problems, except that the script doesn't work on pages loaded with repagination. This is not surprising since linkification doesn't work on pages loaded with repagination either.

Frankly, my dear, ... said...

To all who haven't been able to install the script using the link: The text of the script is posted here.

Unknown said...

Thanks again for taking time for this, Frankly. The script works! In case anyone else had the problem I had...I was using the Salon Letters Collector Greasemonkey script, which seemed to give Frankly's script a hard time (only some of the blocked authors' messages would actually be blocked). So, I switched to the Repagination add-on for FF3 that KB4Hire recommended. Very nice!

Karen M said...

This post and its comments is just one more example of UT having some of the most intelligent and creative commenters in the blogosphere!

Many thanks to you all...

Frankly, my dear, ... said...

Thanks, Karen, and I agree (of course), but while I'm here I'd like to set something straight. Elsewhere you said that KB4Hire was the "inspiration" for this script, and in this, although I'm sure you didn't mean to, I think you do him/her a disservice. KB4Hire may have provided the "impetus", the final nudge to get off my duff and do it, but the "inspiration", the idea that such a script was desirable, came from someone completely different (and I think we both know who I am talking about). The idea of removing certain commentary from my view was planted in my mind long before KB4Hire galvanized me into action.

And one consolation in creating the script is the knowledge that this person will never be able to use it. By his own admission he feels a need to attack those who "attack" (read "disagree with") him. This is fairly obviously compulsive behavior so there is no way that he can fail to read every message posted lest he miss one where someone "attacks" him. It is just a physical impossibility. He can no more ignore any posted message than he can flap his arms and fly.