Last active
August 29, 2015 14:03
-
-
Save na2hiro/60120804e6d0a9de351c to your computer and use it in GitHub Desktop.
ICPC国内予選順位表 (http://icpcsec.storage.googleapis.com/icpc2014-domestic-live/standings.html) で突破チームをカラーリングするブックマークレット
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//順位変動時に自動でカラーリングされる(つもり) | |
//http://icpc.iisf.or.jp/2014-waseda/domestic/selection/ | |
//上記選抜ルールの手順2までです. | |
//ブックマークレット用 | |
javascript:function showChosen(){console.log("show");var $teams = $("div.row li.team");var teamsByUniv = {};var chosenTeams = 0;for(var i=0; i<$teams.length; i++){var row = $teams[i];var univ = $("td.team-university", row).text();$(row).css("background-color", "");if(!teamsByUniv[univ])teamsByUniv[univ]=0;if(chosenTeams<5){if(teamsByUniv[univ]>=4) continue;}else if(chosenTeams<10){if(teamsByUniv[univ]>=3) continue;}else if(chosenTeams<20){if(teamsByUniv[univ]>=2) continue;}else if(chosenTeams<29/*26*/){if(teamsByUniv[univ]>=1) continue;}else{continue;}teamsByUniv[univ]++;chosenTeams++;$(row).css("background-color", "#ccc")}}var f = console.log.bind(console);console.log = function(arg){f(arg);if(arg=="Update success."){showChosen();}};showChosen(); | |
//可読形式 | |
function showChosen(){ | |
console.log("show"); | |
var $teams = $("div.row li.team"); | |
var teamsByUniv = {}; | |
var chosenTeams = 0; | |
for(var i=0; i<$teams.length; i++){ | |
var row = $teams[i]; | |
var univ = $("td.team-university", row).text(); | |
$(row).css("background-color", ""); | |
if(!teamsByUniv[univ])teamsByUniv[univ]=0; | |
if(chosenTeams<5){ | |
if(teamsByUniv[univ]>=4) continue; | |
}else if(chosenTeams<10){ | |
if(teamsByUniv[univ]>=3) continue; | |
}else if(chosenTeams<20){ | |
if(teamsByUniv[univ]>=2) continue; | |
}else if(chosenTeams<29/*26*/){ | |
if(teamsByUniv[univ]>=1) continue; | |
}else{ | |
continue; | |
} | |
teamsByUniv[univ]++; | |
chosenTeams++; | |
$(row).css("background-color", "#ccc"); | |
} | |
} | |
var f = console.log.bind(console); | |
console.log = function(arg){ | |
f(arg); | |
if(arg=="Update success."){ | |
showChosen(); | |
} | |
}; | |
showChosen(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment