Skip to content

Instantly share code, notes, and snippets.

@na2hiro
Last active August 29, 2015 14:03
Show Gist options
  • Save na2hiro/60120804e6d0a9de351c to your computer and use it in GitHub Desktop.
Save na2hiro/60120804e6d0a9de351c to your computer and use it in GitHub Desktop.
ICPC国内予選順位表 (http://icpcsec.storage.googleapis.com/icpc2014-domestic-live/standings.html) で突破チームをカラーリングするブックマークレット
//順位変動時に自動でカラーリングされる(つもり)
//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