Here's the sourcecode for any skeptics; it looks fine to me.
// ==UserScript==
// @name Fantasy LCS
// @namespace http://frichter.de
// @include http://fantasy.*.lolesports.com/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// @version 0.3.9
// @grant GM_addStyle
// ==/UserScript==
function countGames(context, maxGames, isProjected) {
"use strict";
/*global $, waitForKeyElements */
var dotContainer = context.find(".completed"),
proGames = maxGames;
if (!(dotContainer.has(".completed-label").length || isProjected)) {
proGames = dotContainer.find(".complete").length;
}
return proGames;
}
function addPlayerPPG(context, maxGames, isProjected, side) {
var points = context.find(".formatted-points"),
proPoints = parseFloat(points.attr("data-number")),
team = context.find(".team-and-position"),
proGames = countGames(context, maxGames, isProjected),
proPPG = 0;
if (proGames > 0) {
proPPG = proPoints / proGames;
}
if (side == "blue") {
team.prepend('<span>(' + proPPG.toFixed(1) + ' PPG)</span>');
} else {
team.append('<span>(' + proPPG.toFixed(1) + ' PPG)</span>');
}
}
function addPlayerData(context, maxGames, isProjected) {
"use strict";
context.find(".fantasy-map-half-red-team").children().each(function () {
addPlayerPPG($(this), maxGames, isProjected, "red");
});
context.find(".fantasy-map-half-blue-team").children().each(function () {
addPlayerPPG($(this), maxGames, isProjected, "blue");
});
}
function addGamesPlayed(context, leftGames, rightGames) {
"use strict";
var leftName = context.find(".summoner-name" + ".red-team"),
rightName = context.find(".summoner-name" + ".blue-team");
leftName.append('<span> (' + leftGames + ' Games played)</span>');
rightName.prepend('<span>(' + rightGames + ' Games played) </span>');
}
function addMatchPPG(context, leftGames, rightGames, maxGames){
"use strict";
var leftHead = context.find(".fantasy-match-header-item > .points").children("*:first-child"),
rightHead = context.find(".fantasy-match-header-item > .points").children("*:last-child"),
leftPoints = leftHead.find(".formatted-points").attr("data-number"),
rightPoints = rightHead.find(".formatted-points").attr("data-number"),
leftPPG = 0,
rightPPG = 0;
if(leftGames > 0) {
leftPPG = leftPoints / leftGames;
} else {
leftPPG = leftPoints / (maxGames * 7);
}
if(rightGames > 0) {
rightPPG = rightPoints / rightGames;
} else {
rightPPG = rightPoints / (maxGames * 7);
}
leftHead.prepend('<span style="font-size: 40%;">' + leftPPG.toFixed(1) + '</span>');
rightHead.append('<span style="font-size: 40%;">' + rightPPG.toFixed(1) + '</span>');
}
function getWeekMaxGames(weekNum) {
"use strict";
var weekMaxGames = 2;
if (weekNum === 1 || weekNum === 7 || weekNum === 11) {
weekMaxGames = 4;
}
return weekMaxGames;
}
function main() {
"use strict";
$(".fantasy-match").each(function () {
var weekNum = parseInt($(this).parent().attr("data-week"), 10),
weekMaxGames = getWeekMaxGames(weekNum),
leftGamesPlayed = 0,
rightGamesPlayed = 0,
isProjected = $(this).find(".formatted-points").hasClass("formatted-points-projected");
if (!isProjected) {
$(this).find(".fantasy-map-half-red-team").children().each(function(){
leftGamesPlayed += countGames($(this), weekMaxGames, false);
});
$(this).find(".fantasy-map-half-blue-team").children().each(function(){
rightGamesPlayed += countGames($(this), weekMaxGames, false);
});
}
addPlayerData($(this), weekMaxGames, isProjected);
addGamesPlayed($(this), leftGamesPlayed, rightGamesPlayed);
addMatchPPG($(this), leftGamesPlayed, rightGamesPlayed, weekMaxGames);
});
}
waitForKeyElements(".week:first-child", main);