Follow Slashdot blog updates by subscribing to our blog RSS feed

 



Forgot your password?
typodupeerror
×
Programming

Journal Fordiman's Journal: A WSJ hack for Firefox users

One of the more annoying things about the way the Wall Street Journal is set up is its assumption that you're some kind of corporate news theif. As a result, you can't directly access articles by their link, and 'open in new tab' just brings up another search window.

Also, due to an error in the way Firefox handles text wrapping, sometimes article printouts come out clipped on the right side.

To fix both of these issues, I wrote a quick Javascriptlet (javascript: type bookmark) that fixes these issues in a single click. All that's needed is to bookmark the preceeding link, and to use it on search pages at WSJ and on print pages that don't 'look' right.

Let us look at the code, shall we? (Formatting should be removed before using the following code)

Update (2006-10-19): They changed their search results slightly to accomodate the 'open in new tab' group. Thanks for listening, guys! Meanwhile, it means that my Javascriptlet doesn't work for going straight to print view (my preferred), nor does it fix the long, spaceless links. As such, the code below has been updated to match the new search output.

javascript:

//We do this in order to suppress a return value
(function(){

//Get all the links
var X=document.getElementsByTagName('A');
// Iterate through 'em
for (i=0; i // Clear the onClick handler
X[i].onclick=function(){};
// If the link has a comma,
if(X[i].innerHTML.indexOf(',')!=-1)

// Make it wrappable by adding a space
X[i].innerHTML=X[i].innerHTML.replace(',',', ');

// Article links contain this string
var a = X[i].href.indexOf('/SB');
if (a!=-1)

//Essentailly, clip off the '/', and reformat
X[i].href='http://online.wsj.com/article_print/'+X[i].href.substr(a+1,20)+'.html';

}
// another hack; sometimes tables expand the page
X=document.getElementsByTagName('table');
// so? make sure they don't.
for(i=0;i if(typeof X[i].width!='undefined')

// Set the width to nuffin'
X[i].width='';

//Close up our function
})();

When bad men combine, the good must associate; else they will fall one by one, an unpitied sacrifice in a contemptible struggle. - Edmund Burke

Working...