[On 11/10/09 Salon again changed the format of their letter pages. A new script to filter Salon letters is again available here. The old code is left here in case Salon changes the format back again.]
For those who have been unable to install the Salon Letter Filter Greasemonkey script from the link to the file, here is the text of the script. To install, copy everything between //BEGIN CODE and //END CODE into a text file (do not copy //BEGIN CODE and //END CODE). Name the text file salonletterfilter.user.js and save it. Open the file in your browser (you can drag and drop). If Greasemonkey is installed and active, when you open the file a Greasemonkey dialog will appear asking if you want to install the script. Click on install.
IMPORTANT: Your file name must end with .user.js for Greasemonkey to recognize it as a user script.
Do not panic if it appears that the lines of code end in midair on the blog page. It is all there even if it doesn't display because of the Blogger page layout. Simply select the code, copy it, and paste it into a new text file. Notepad or some other fairly simple text editor is recommended for this.
//BEGIN CODE
//
// MANUAL CONFIGURATION REQUIRED
//
// To configure the letters filter, you must have a "killfile" variable configured.
// A template for this variable is given below. The "killfile" varable includes a
// comma-delimited string of the nyms of the authors that you wish to filter out.
// A sample "killfile variable configuration looks like:
//
// new String(killfile = 'author1,author2,author3');
// or
// new String(killfile = 'author');
//
// Simply replace the word "authors" in the template below with the nyms of the authors you
// wish to expunge, each one separated by a comma, and save the file.
// Entries are case insensitive. Since the "killfile" will become a regular expression,
// regular expression metacharacters (such as "." or "+") appearing in a nym should be
// preceded by a backslash ("\"; e.g., 'L\.W\.M\.') in order to work properly.
//
new String(killfile = 'authors');
if (killfile.length == 0) exit;
//
// --------------------------------------------------------------------
//
// This is a Greasemonkey user script.
//
// To install, you need Greasemonkey: http://greasemonkey.mozdev.org/
// Then restart Firefox and revisit this script.
// Under Tools, there will be a new menu item to "Install User Script".
// Accept the default configuration and install.
//
// To uninstall, go to Tools/Manage User Scripts,
// select "Letter_Filter", and click Uninstall.
//
// --------------------------------------------------------------------
//
// ==UserScript==
// @name Salon Letter filter
// @author Frankly, my dear, ...
// @namespace http://language-grammar.blogspot.com/2009/04/filter-for-salon-letters.html
// @description Filter letters from Salon. WARNING: manual configuration required. Before use you must edit the script and enter your "killfile" in the string variable near the top of the script.
// @include http://letters.salon.com/*
// @version 0.0.1
// ==/UserScript==
//
// Set debug to 1 to see debug output in Javascript console
//
var debug = 1;
//
// Only print information to console if debug is on
//
function myGM_log(args) {
if (debug == 1) {
GM_log(args);
}
}
//
// Shortcut function to evalute an XPath in the document
//
function xpath(query, sourceDoc) {
return document.evaluate(query, sourceDoc, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
}
myregexp = new RegExp(killfile.replace(/, */g, "|"), "i");
myGM_log(myregexp);
var allLets, thisLet, allAuthors, thisAuthor, allFooters, thisFooter;
allLets = xpath("//li[@class='letter_node']",document);
allAuthors = xpath("//div[@class='letter_entry_author'] | //div[@class='letter_entry_author premium']",document);
allFooters = xpath("//div[@class='letter_entry_footer']",document);
for (var i = 0; i < allLets.snapshotLength; i++) {
thisLet = allLets.snapshotItem(i);
thisAuthor = allAuthors.snapshotItem(i);
thisFooter = allFooters.snapshotItem(i);
var author = thisAuthor.innerHTML;
if (myregexp.test(author)) {
mymatch = myregexp.exec(author);
thisLet.innerHTML = "<h3><b>Letter from " + mymatch + " deleted</h3></b>" + thisFooter.innerHTML +"<hr>";
//thisLet.innerHTML = "";
}
}
//END CODE