Extra caution is recommended when installing recently uploaded/updated scripts (read more)
Be sure you trust any scripts you install

Yahoo Fantasy Basketball

<p>minor update 2/22/2008 - update to handle in progress boxscore change <p>minor update 12/15/2007 - update to handle yahoo boxscore changes Live basketball fantasy scoring

this script goes through each of your players' boxscores for the night and then summarizes how they performed in a modal window.

To trigger the script, press the "Show Freebie Stats" button on the TOP RIGHT. This
is where the yahoo's "Launch Stat Tracker" link once appeared.

Check back for updates or subscribe to my blog to get notified
http://feeds.feedburner.com/robobruin

To log bugs or feature requests,
http://code.google.com/p/freebiestats/issues/list

To use the script, follow these 3 steps

  1. download firefox
  2. install greasemonkey extension
  3. come back here and click on the install button






1 point
login to vote
Posted Aug 9, 2008

hey glenn i know my question has nothing to do with this script but i couldnt find your email anywhere

so i was wondering if you could create this script except for baseball it is a bench all players without a game script

http://userscripts.org/scripts/show/6716

that is the script link

and here is the actual script

// ==UserScript==
// @name Yahoo Fantasy NBA Bench All
// @namespace http://mattandchristy.net/benchall
// @description Provides a button to bench all players without a game
// @include http://basketball.fantasysports.yahoo.com/nba/*...=*
// @include http://basketball.fantasysports.yahoo.com/nba/*...
// ==/UserScript==
//
// Change log:
// 2006-12-10 Initial version of script; used Yahoo Fantasy NBA Game Log Link
// as a base to start developing

var doBench = function(event) {

var allElements;
var thisElement;
var playerLink = "http://sports.yahoo.com/nba/players/"
var gameLogLink;


allElements = document.evaluate(
"//*[contains(@class, 'player')]/..",
document,
null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
null);

// burn the first two rows; they are headers, not players
for (var i = 2; i < allElements.snapshotLength; i++) {

thisElement = allElements.snapshotItem(i);

tds = thisElement.getElementsByTagName('td');
nameNode = tds[1];
if(nameNode) {
// td div a textnode value
name = nameNode.firstChild.firstChild.firstChild.nodeValue;

// get the opponent TD's innerHTML; text node won't work because
// the ? for 'no opponent' gets translated to a character =/
opp = tds[3].innerHTML;

if(opp == '?') {

newPosSelectNode = tds[2].firstChild;
// select the 'BN' node for these guys (last option)
newPosSelectNode.selectedIndex = newPosSelectNode.length-1;

GM_log("Benching " + name);
}
}
}

// stop event propagation, if this was a click
if(event) {
event.stopPropagation();
event.preventDefault();
}
}

/* gameLogLink = document.createElement('a'); */
/* gameLogLink.setAttribute("href",thisElement.href + "/gamelog") */
/* //gameLogLink.setAttribute("class","cellindent") */
/* gameLogLink.setAttribute("target","_blank") */
/* gameLogLink.setAttribute("title","game log link") */
/* gameLogLink.innerHTML = "" */
/* thisElement.parentNode.insertBefore(gameLogLink, thisElement.nextSibling.nextSibling); */

var BENCHBUTTON_ID = "bencherButton";
var BENCHBUTTON_TEXT = "[Bench players with no game]";

// create the bench button
var bencher = document.createElement("A");
bencher.addEventListener("click", doBench, true);
bencher.href = "#";
bencher.innerHTML = BENCHBUTTON_TEXT;
bencher.className = 'button';
/* bencher.style.backgroundColor = "#D8D9D5"; */
/* bencher.style.borderTopColor = "#A8A8A8"; */
/* bencher.style.borderBottomColor = "#A8A8A8"; */
/* bencher.style.borderLeftColor = "#A8A8A8"; */
/* bencher.style.borderRightColor = "#A8A8A8"; */
/* bencher.style.borderTopStyle = "outset"; */
/* bencher.style.borderBottomStyle = "outset"; */
/* bencher.style.borderLeftStyle = "outset"; */
/* bencher.style.borderRightStyle = "outset"; */
/* bencher.style.borderTopWidth = "1px"; */
/* bencher.style.borderBottomWidth = "1px"; */
/* bencher.style.borderLeftWidth = "1px"; */
/* bencher.style.borderRightWidth = "1px"; */
bencher.style.paddingTop = "2px";
bencher.style.paddingBottom = "5px";
bencher.style.paddingLeft = "5px";
bencher.style.paddingRight = "5px";
bencher.style.color = "#FFFFFF";
bencher.id = BENCHBUTTON_ID;

// attach the bench button right before the "submit changes" button
// at the bottom of the screen
var buttonBar = document.getElementById('buttonbar');
var inputs = buttonBar.getElementsByTagName('input');
var submitButton = inputs[inputs.length-1]
buttonBar.insertBefore(bencher, submitButton);

i tried to mess around with it a little bit but got no luck

please respond soon

i will post this on a couple other pages to ensure that you get the message

Aaron S

1 point
login to vote
Dave 3 script's author
Posted Feb 24, 2008

suoirafen - the player fix is in. and yes...my saturday night is this boring.

1 point
login to vote
suoirafen user
Posted Feb 24, 2008

the new update works fine from what i've seen. but i was wondering if it was possible to make it so the links to the player pages could be fixed.

the current links go to basketball.fantasysports.yahoo.com, while they should go to sports.yahoo.com

1 point
login to vote
Dave 3 script's author
Posted Feb 23, 2008

in progress players should be processed correctly now. I didn't have a chance to fully test it since most games have ended but I pushed the change anyway. please let me know if you run into issues.

1 point
login to vote
Dave 3 script's author
Posted Feb 22, 2008

yahoo tweaked their boxscores so I plan to update this script in the next day or two so that in progress games are processed correctly. stay tuned

1 point
login to vote
Dave 3 script's author
Posted Jan 20, 2008

B2608, the script only works when your players are in active/completed games. so if there is no boxscore link on the page, you won't see anything.

1 point
login to vote
B2608 user
Posted Jan 17, 2008

The "Show freebie stats" shows but nothing happens after I clicked on it. Have tried it on 3 different PCs and even on 1 with firefox and greasemonkey freshly installed. Wondering if anyone else has this issue

1 point
login to vote
Dave 3 script's author
Posted Dec 28, 2007

thanks for the bug report king leo, I fixed the problem.

1 point
login to vote
Posted Dec 26, 2007

I think this may be a one-time fluke, but I was trying to use the script to get the day's totals of my opponent (head-to-head), and he has Shaq on his team. Where the data for Shaq should be, it was Anderson Varejao's name and totals. I say fluke because I'm guessing this will only happen if Shaq & Varejao are in the same box score. My guess is something is going wrong handling the player ID's (Shaq=847; Varejao=3847). This isn't a big deal since they will only meet what two more times this season, but I thought it was worth noting.

1 point
login to vote
Posted Dec 16, 2007

Thanks for the update Dave, it works great.

1 point
login to vote
bawilson user
Posted Dec 16, 2007

Sorry I messed up on the copy there guys. Dave I saw that your update doesn't include what I called the "started" column. Yahoo also added a column showing if the player started and at what position. Here's what I did to fix it.

      '<thead><tr><td width="6%">Pos</td><td height="18" width="18%"> Name</td><td width="6%">Started</td><td width="6%">Min</td><td width="8%">FG</td><td width="8%">3Pt</td><td width="8%">FT</td><td width="8%">+/-</td><td width="8%">Off</td><td width="6%">Reb</td><td width="6%">Ast</td><td width="6%">TO</td><td width="6%">Stl</td><td width="6%">Blk</td><td width="6%">BA</td><td width="6%">PF</td><td width="8%">Pts </td></tr></thead>' +
      
      

1 point
login to vote
Dave 3 script's author
Posted Dec 15, 2007

hey guys, thanks for the heads up about the boxscore changes. I just updated the script to handle the new stats.

King Leo, I never anticipated that people would update their weekly stats this way. I wanted this script to be more lightweight than the baseball one so I didn't create the arrays. maybe I'll do that next season or if yahoo makes drastic changes to the boxscore.

1 point
login to vote
devohoang user
Posted Dec 15, 2007

bawilson I tried the change and couldn't get it to work either. Could you double check the line of code you posted? I just posted the two lines (original and modified) directly next to one another to compare and at a glance they look identical. Thanks

1 point
login to vote
bawilson user
Posted Dec 15, 2007

Chip - I found that if you just modified the script and then reloaded the page that greasemonkey wouldn't pick up that the script had changed. I had to either navigate away from the page and navigate back to it or just remove the "#" symbol from the web address. Let me know if that works for you. Here's a link to a screen shot of it working.

http://www.christinasportraits.com/basketball/S...

1 point
login to vote
Posted Dec 15, 2007

bawilson, I tried to replace the line that you said and it doesn't fix it. I tried to fix it but I have no idea what i'm doing. Could you help me out?

1 point
login to vote
bawilson user
Posted Dec 15, 2007

Yahoo changed the way their box scores were set up. They´ve added three new columns. The first new column signifies if the player started, second new column is the point differential while the player was on the court, and I´m not sure what the third new column is for with the BA.

I´ve gotten the script to work by changing line 178 in the script from

      '<thead><tr><td width="6%">Pos</td><td height="18" width="18%"> Name</td><td width="6%">Min</td><td width="8%">FG</td><td width="8%">3Pt</td><td width="8%">FT</td><td width="8%">Off</td><td width="6%">Reb</td><td width="6%">Ast</td><td width="6%">TO</td><td width="6%">Stl</td><td width="6%">Blk</td><td width="6%">PF</td><td width="8%">Pts </td></tr></thead>' +
      

to
      '<thead><tr><td width="6%">Pos</td><td height="18" width="18%"> Name</td><td width="6%">Min</td><td width="8%">FG</td><td width="8%">3Pt</td><td width="8%">FT</td><td width="8%">Off</td><td width="6%">Reb</td><td width="6%">Ast</td><td width="6%">TO</td><td width="6%">Stl</td><td width="6%">Blk</td><td width="6%">PF</td><td width="8%">Pts </td></tr></thead>' +
      

That should work until Dave has a change to update the script himself.

1 point
login to vote
Posted Dec 15, 2007

hey dave, really fine stuff you've done with both scripts. Just to let you know this script is no longer working as intended because Yahoo added new columns to the box score. I don't know anything about javascript, but I played around with your baseball script because it could do the entire league (as pulled from the standings). I managed to get it working with fantasy basketball to pull stats and even customize the order (using the Array). Although I couldn't figure out how to make it deal with the shooting numbers as you have in the basketball.

If this script will now require a system like the baseball one, where <td>'s are set to be a certain stat, would it be possible to have seperate columns for makes & attempts, and then pct's on another row (or column). This would be a way for the many fans of your script to keep track of their weekly FG%'s on their own.

Thanks for your hard work with this script. I can't wait for the next brilliant update.</td>

1 point
login to vote
linkin06 user
Posted Nov 26, 2007

yea i was referring to head to head leagues. it is rather easy to just look at the match up stats from yahoo and adding in today's stats. it's just with fg%, it doesn't work out as well. so i suppose it'd be really easy to just keep track of the weekly attempted and made shots at a minimum for a better idea where your fg and ft% stands. thanks for all your work.

1 point
login to vote
Joey Boy user
Posted Nov 22, 2007

wow...nvm i got it to work

much thanks man!

1 point
login to vote
Joey Boy user
Posted Nov 22, 2007

IT DOES'NT WORK MAN!!!

I downloaded it...then downloaded the script and went to fantasy basketball on yahoo and none of the stats showed!

1 point
login to vote
Dave 3 script's author
Posted Nov 20, 2007

linkin06 - is this for a h2h league? don't they already have something similar when looking at the matchups? they don't have the current days score but you could always open two windows; one for your team and the other for your opponent. if enough people want this feature I'd definitely consider it.

1 point
login to vote
linkin06 user
Posted Nov 19, 2007

i know this may be a little more daunting, but if there were a way to keep a running total for the week, that would be tremendous. could be a ton of code, but i could imagine just creating a new variable for each category and adding totals. the java seems fairly doable, and hopefully someone can implement it.

1 point
login to vote
Dave 3 script's author
Posted Oct 31, 2007

I just did a minor update of the script. Instead of auto launching the window you now need to click on the blue "Show Freebie Stats" link in the upper right. This link used to be the "Get StatTracker" link.

1 point
login to vote
jk- scriptwright
Posted Nov 19, 2006

this is great.. excellent work.

To get it to work only on my team page I removed the (funtion(){CODE_HERE}); that wrapped the script and replaced it with:
if (location.href.match(/^http\:\/\/basketball\.fantasysports\.yahoo\.com\/nba\/\d{1,7}\/\d{1,2}$/i)) {CODE_HERE};

1 point
login to vote
Tim Wilson scriptwright
Posted Nov 7, 2006

Dave, thanks for the z-index tip! That did it!

I'm going to try to take your script and make a football script. I know a couple people interested in a football version of the script.

You could comment on this script if you were logged in.