Edit: Commenter CJett pointed out that this script can be readily installed on Google’s Chrome browser as well as FireFox. I’ve edited the post slightly to reflect this addition.
Disclaimer 1: This has nothing to do with my previous post on the Yahoo Fantasy Sports API.
Disclaimer 2: You must be using FireFox or Chrome to enjoy the script described in this post.
Disclaimer 3: I didn’t write the script, so I won’t take credit or blame for it (though it deserves the former).
Now that we’ve gotten that out of the way, let’s get on with business.
Greasemonkey is a FireFox browser extension that allows users to manipulate web pages after loading them. Why is that cool? Because it lets you add a link to FanGraph’s beside each player’s name on Yahoo’s Fantasy Baseball page, like this:
Here’s how to give it a try:
0. If you’re on FireFox, proceed to step 1. If you’re using Chrome, skip ahead to step 2.
1. Install the Greasemonkey plug-in into FireFox. If you don’t have FireFox, I recommend checking it out; it’s a free, high-quality browser. Once you have FireFox, installing Greasemonkey is a one click process, but it does require a browser restart.
2. Install the FanGraphs link script. Before doing so, please be sure to read the userscripts.org disclaimer. If you’re cool with the disclaimer and terms of service, head over to the link script’s page. Click the “install” button and you’re all set. If you’re so inclined, you can check out the script’s source code.
3. Head over to Yahoo Fantasy Baseball, and try clicking the small FanGraphs icon that should now appear beside each player’s name. It should open a link to the player’s FanGraphs page in a new browser tab or window.
4. If you ever want to remove this script from your browser, perform the following steps: on your browsers menu bar, choose Tools > Greasemonkey > Manage User Scripts; highlight Yahoo Fantasy – FanGraphs Link in the list of scripts; and click the uninstall button.
Another disclaimer: I tried this script on two computers, one Windows and one Linux, and it seems to work fine and the source code looks safe to me. But as a rule of thumb, be careful with what you install on your browser. If you aren’t sure if something is safe to install or not, my recommendation is not to install it.
How’s it work?
In a nutshell, after you load a web page in your browser, you have a full html document loaded on your computer for the browser to display. Greasemonkey uses this premise to provide a means to customize the html in your browser. The script that we just installed works because of Yahoo’s good html design. Each player’s name is placed in a container called a <div> which is further defined as “name” (<div class=”name”>). So the script looks for the player names identified in the html, grabs the name from inside the <div> container, generates a link to FanGraphs, and appends it to the original <div> container.
Print This Post