From Yahoo to FanGraphs at the Touch of a Button

Another Edit: Some comments, like this one, have asked about the author of the script. The universally positive feedback for this goes to Justin Swift.

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.

You Aren't a FanGraphs Member
It looks like you aren't yet a FanGraphs Member (or aren't logged in). We aren't mad, just disappointed.
We get it. You want to read this article. But before we let you get back to it, we'd like to point out a few of the good reasons why you should become a Member.
1. Ad Free viewing! We won't bug you with this ad, or any other.
2. Unlimited articles! Non-Members only get to read 10 free articles a month. Members never get cut off.
3. Dark mode and Classic mode!
4. Custom player page dashboards! Choose the player cards you want, in the order you want them.
5. One-click data exports! Export our projections and leaderboards for your personal projects.
6. Remove the photos on the home page! (Honestly, this doesn't sound so great to us, but some people wanted it, and we like to give our Members what they want.)
7. Even more Steamer projections! We have handedness, percentile, and context neutral projections available for Members only.
8. Get FanGraphs Walk-Off, a customized year end review! Find out exactly how you used FanGraphs this year, and how that compares to other Members. Don't be a victim of FOMO.
9. A weekly mailbag column, exclusively for Members.
10. Help support FanGraphs and our entire staff! Our Members provide us with critical resources to improve the site and deliver new features!
We hope you'll consider a Membership today, for yourself or as a gift! And we realize this has been an awfully long sales pitch, so we've also removed all the other ads in this article. We didn't want to overdo it.

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.





Patrick Newman is a veteran enthusiast of Japanese baseball who happens to write about it at npbtracker.com, and on Twitter @npbtracker.

36 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
BrianA
15 years ago

Immensely cool.