diff options
-rw-r--r-- | uftow-stats-simple.user.js | 225 | ||||
-rw-r--r-- | uftow-stats.user.js | 265 |
2 files changed, 336 insertions, 154 deletions
diff --git a/uftow-stats-simple.user.js b/uftow-stats-simple.user.js new file mode 100644 index 0000000..f04c987 --- /dev/null +++ b/uftow-stats-simple.user.js @@ -0,0 +1,225 @@ +// ==UserScript== +// @name uftow-stats-simple +// @namespace uftow-stats-simple +// @include https://ubuntuforums.org/showthread.php?t=1579442* +// @version 1.3.0 +// @Description Generates stats for Tug of War - simple variant. +// @grant GM_log +// @grant GM_getValue +// @grant GM_setValue +// @grant GM_listValues +// @grant GM_deleteValue +// @grant GM_registerMenuCommand +// ==/UserScript== + +var towStats = { + alreadyHasStartCounting:false, + scores:new Array(), + lastPostNumber:null, + lastPoster:null, + startPostNumber:null, + endPostNumber:null, + init: function(){ + this.postContainers=document.getElementsByClassName('postcontainer'); + this.firstPostNumber=parseInt(this.postContainers[0].getElementsByClassName('postcounter')[0].textContent.substr(1)); + this.lastPostNumber=parseInt(this.postContainers[this.postContainers.length-1].getElementsByClassName('postcounter')[0].textContent.substr(1)); + if(!GM_getValue("statsActive",false)){ + GM_registerMenuCommand("Start counting posts",function(){towStats.startCounting();},'S'); + this.alreadyHasStartCounting=true; + }else{ + this.startCounting(); + } + GM_registerMenuCommand("Clear counter",function(){towStats.clearStats();},'A'); + }, + recordPosts: function(startPost){ + var postNumber; + var startDiff=startPost-this.firstPostNumber; + var postInfo; + if(startDiff<0 || startPost>this.firstPostNumber+this.postContainers.length-1){ + alert("Post #"+startPost+" is not on this page."); + return false; + } + for (var i=startDiff;i<this.postContainers.length;i++){ + postInfo=this.getPostInfo(this.postContainers[i]); + this.lastPostNumber=postInfo[1]; + if(this.lastPoster==postInfo[0]){ + //GM_log("Post #"+this.lastPostNumber+" is a duplicate and has been skipped."); + continue; + } + if(this.endPostNumber!=null && this.lastPostNumber>this.endPostNumber){ + break; + } + this.scorePost(postInfo); + } + return true; + }, + getPostInfo: function(postElement){ + var userSpanTag=postElement.getElementsByClassName('username')[0].getElementsByTagName('span')[0]; + var userName=userSpanTag.textContent; + var postNumber=parseInt(postElement.getElementsByClassName('postcounter')[0].textContent.substr(1)); + return new Array(userName,postNumber); + }, + scorePost: function(postInfo){ + this.lastPoster=postInfo[0]; + userIndex=this.scores.indexOf(postInfo[0]); + //The second check in the if statement makes sure users with usernames being actual numbers don't break this script + if(userIndex!=-1&&userIndex%2==0){ + this.scores[userIndex+1]++; + }else{ + this.scores.push(postInfo[0]); + this.scores.push(1); + } + }, + getSummary: function(){ + var alertText="[B]TUG OF WAR LAST ROUND STATS[/B]\n"; + var totalParticipants=0; + var totalPosts=0; + for(var i=1;i<this.scores.length;i+=2){ + //GM_log("STATS: User: "+this.scores[i-1]+", Posts: "+this.scores[i]); + totalParticipants++; + totalPosts+=this.scores[i]; + } + alertText+="[B]Post range:[/B] "+this.startPostNumber+" - "+ + ((this.endPostNumber!=null)?this.endPostNumber:this.lastPostNumber)+"\n"; + alertText+="[B]Post count:[/B] "+totalPosts+"\n"; + alertText+="[B]Participants:[/B] "+totalParticipants+"\n\n"; + alertText+="[B]PARTICIPANTS[/B]"; + alertText+=this.getListText(this.scores); + window.alert(alertText); + }, + getListText: function(participants){ + var statsText=""; + var thisScore; + var currScore=0; + var reCheck=true; + var tempSpot; + while(reCheck){ + reCheck=false; + for(var i=0;i<participants.length;i+=2){ + if(i+2>=participants.length){ + break; + } + if(participants[i+1]<participants[i+3]){ + tempSpot=new Array(participants[i],participants[i+1]); + participants[i]=participants[i+2]; + participants[i+1]=participants[i+3]; + participants[i+2]=tempSpot[0]; + participants[i+3]=tempSpot[1]; + reCheck=true; + } + } + } + //List individually + //for(var i=0;i<participants.length;i+=2){ + // thisScore=participants[i+1]; + // statsText+="[B]"+participants[i]+":[/B] "+participants[i+1]+" "; + // statsText+="post"+((thisScore!=1)?"s":""); + // statsText+="\n"; + //} + //Group by post count + for(var i=0;i<participants.length;i+=2){ + thisScore=participants[i+1]; + if(thisScore!=currScore){ + currScore=thisScore; + statsText+="\n[B]"+thisScore+" post"+((thisScore!=1)?"s":"")+":[/B] "+participants[i]; + }else{ + statsText+=", "+participants[i]; + } + } + if(participants.length==0){ + statsText+="None\n"; + } + return new Array(statsText); + }, + restoreStats: function(){ + if(!GM_getValue("statsActive",false)){ + GM_setValue("statsActive",true); + return false; + } + var scoresCount=GM_getValue("scores.count",0); + this.lastPoster=GM_getValue("lastPoster",null); + this.lastPostNumber=parseInt(GM_getValue("lastPostNumber")); + this.startPostNumber=parseInt(GM_getValue("startPostNumber")); + this.endPostNumber=GM_getValue("endPostNumber"); + if(this.endPostNumber!=null){ + this.endPostNumber=parseInt(this.endPostNumber); + } + for(i=0;i<scoresCount;i++){ + this.scores.push(GM_getValue("scores."+i)); + } + return true; + }, + startCounting: function(){ + if(this.restoreStats()){ + startPost=this.lastPostNumber+1; + }else{ + answerStart=window.prompt("Specifiy a post number to begin counting.\n"+ + "If you do not know the post number, click Cancel."); + if(answerStart!=null){ + startPost=parseInt(answerStart); + this.startPostNumber=startPost; + answerEnd=window.prompt("Specifiy a post number to end counting.\n"+ + "If you want to count until the end, click Cancel."); + if(answerEnd!=null){ + this.endPostNumber=parseInt(answerEnd); + } + GM_setValue("statsActive",true); + }else{ + this.clearStats(); + return false; + } + } + if(!this.recordPosts(startPost)){ + return false; + } + this.saveStats(); + if((this.endPostNumber!=null && this.lastPostNumber>=this.endPostNumber) || !this.goToNextPage()){ + if(this.scores.length>=2 && !(this.endPostNumber!=null && this.lastPostNumber<this.endPostNumber)){ + window.alert("Counting complete.\n"+ + "Stats will be displayed in the next dialog box."); + this.getSummary(); + }else{ + window.alert("Tug of War is yet to be completed."); + } + this.clearStats(); + } + }, + saveStats: function(){ + //GM_log("Last post on this page: "+this.lastPostNumber); + GM_setValue("lastPostNumber",this.lastPostNumber); + for(i=0;i<this.scores.length;i++){ + GM_setValue("scores."+i,this.scores[i]); + GM_setValue("scores.count",this.scores.length); + } + GM_setValue("lastPoster",this.lastPoster); + GM_setValue("startPostNumber",this.startPostNumber); + GM_setValue("endPostNumber",this.endPostNumber); + }, + goToNextPage: function(){ + var pageLinks=document.getElementsByClassName('pagination_top')[0]; + var nextLinkContainer=pageLinks.getElementsByClassName('prev_next')[1]; + if(nextLinkContainer!=undefined){ + nextLinkContainer.getElementsByTagName('a')[0].click(); + return true; + }else{ + return false; + } + }, + clearStats: function(){ + this.scores=new Array(); + this.lastPostNumber=null; + this.lastPoster=null; + this.startPostNumber=null; + this.endPostNumber=null; + keys=GM_listValues(); + for (var i=0,key=null; key=keys[i];i++) { + GM_deleteValue(key); + } + if(!this.alreadyHasStartCounting){ + GM_registerMenuCommand("Start counting posts",function(){towStats.startCounting()},'S'); + this.alreadyHasStartCounting=true; + } + } +}; + +towStats.init(); diff --git a/uftow-stats.user.js b/uftow-stats.user.js index fdfb838..db2a51e 100644 --- a/uftow-stats.user.js +++ b/uftow-stats.user.js @@ -1,23 +1,23 @@ // ==UserScript== // @name uftow-stats // @namespace uftow-stats -// @include http://ubuntuforums.org/showthread.php?t=1579442* -// @version 1.2.1 -// @Description Generates stats for Tug of War. +// @include https://ubuntuforums.org/showthread.php?t=1579442* +// @version 1.3.0 +// @Description Generates stats for Tug of War. +// @grant GM_log // @grant GM_getValue // @grant GM_setValue -// @grant GM_log // @grant GM_listValues -// @grant GM_setValue -// @grant GM_addStyle // @grant GM_deleteValue // @grant GM_registerMenuCommand // ==/UserScript== var towConfig = { multipliers:new Array( - //Forum Staff + //Forum Moderator 'images/rank_uf_moderator_2013-07.png',-2, + //Forum Super Moderator + 'images/rank_uf_super_moderator_2014_12.png',-3, //Forum Admin 'images/rank_uf_admin_2013-07.png',-4, //LoCo mods @@ -41,14 +41,14 @@ var towStats = { scores:new Array(), currentScore:0, lastPostNumber:null, + lastPoster:null, winner:null, marker:null, markerPost:null, - lastPoster:null, - init:function(){ + init: function(){ this.postContainers=document.getElementsByClassName('postcontainer'); - this.firstPostNumber=this.parsePostNumber(this.postContainers[0].getElementsByClassName('postcounter')[0].textContent); - this.lastPostNumber=this.parsePostNumber(this.postContainers[this.postContainers.length-1].getElementsByClassName('postcounter')[0].textContent); + this.firstPostNumber=parseInt(this.postContainers[0].getElementsByClassName('postcounter')[0].textContent.substr(1)); + this.lastPostNumber=parseInt(this.postContainers[this.postContainers.length-1].getElementsByClassName('postcounter')[0].textContent.substr(1)); this.currentScore=0; if(!GM_getValue("statsActive",false)){ GM_registerMenuCommand("Start counting posts",function(){towStats.startCounting();},'S'); @@ -58,24 +58,19 @@ var towStats = { } GM_registerMenuCommand("Clear counter",function(){towStats.clearStats();},'A'); }, - recordPosts: function(start){ + recordPosts: function(startPost){ var postNumber; - var startDiff=start-this.firstPostNumber; + var startDiff=startPost-this.firstPostNumber; var postInfo; - GM_log("Seek ahead by "+startDiff+" posts"); - //alt4Number=1+(startDiff*2); - if(startDiff<0){ - alert("No such post exists on this page"); + if(startDiff<0 || startPost>this.firstPostNumber+this.postContainers.length-1){ + alert("Post #"+startPost+" is not on this page."); return false; } for (var i=startDiff;i<this.postContainers.length;i++){ - //postInfo=this.getPostInfo(currentPagePost,i); postInfo=this.getPostInfo(this.postContainers[i]); - this.lastPostNumber = postInfo[3]; - //alt4Number+=2; - //currentPagePost++; + this.lastPostNumber=postInfo[3]; if(this.lastPoster==postInfo[0]){ - GM_log("Post #"+this.lastPostNumber+" is a duplicate and has been skipped."); + //GM_log("Post #"+this.lastPostNumber+" is a duplicate and has been skipped."); continue; } this.scorePost(postInfo); @@ -83,23 +78,21 @@ var towStats = { this.winner='mods'; }else if(this.currentScore>=200){ this.winner='community'; - }if(this.winner!=undefined){ + }if(this.winner!=null){ this.marker=postInfo[0]; this.markerPost=postInfo[3]; break; } - GM_log("Post: "+postInfo[3]+", Round score: "+this.currentScore); + //GM_log("Post: "+postInfo[3]+", Round score: "+this.currentScore); } + return true; }, getPostInfo: function(postElement){ var userSpanTag=postElement.getElementsByClassName('username')[0].getElementsByTagName('span')[0]; var userName=userSpanTag.textContent; var css=userSpanTag.getAttribute('style'); var rankURL=postElement.getElementsByClassName('rank')[0].getElementsByTagName('img')[0].getAttribute('src'); - var postNumber=this.parsePostNumber(postElement.getElementsByClassName('postcounter')[0].textContent); - if(userName==""){ - userName='[UNKNOWN USERNAME]'; - } + var postNumber=parseInt(postElement.getElementsByClassName('postcounter')[0].textContent.substr(1)); return new Array(userName,css,rankURL,postNumber); }, scorePost: function(postInfo){ @@ -121,94 +114,75 @@ var towStats = { } }, getSummary: function(){ - if(this.winner!=undefined){ - var alertText="[B]TUG OF WAR LAST ROUND STATS[/B]\n"; - var totalPoints=0; - var totalPosts=0; - var totalModPoints=0; - var totalModPosts=0; - var totalCommunityPoints=0; - var totalCommunityPosts=0; - var minimumRequiredMVP; - var mvpList=new Array(); - var communityParticipants=new Array(); - var winners; - var allowMVP; - var modParticipants=new Array(); - GM_log(this.scores); - for(var i=1;i<this.scores.length;i+=3){ - GM_log("STATS: User: "+this.scores[i-1]+", Multiplier: "+this.scores[i]+", Points: "+this.scores[i+1]+", Is Mod: "+this.scores[i+2]); - totalPoints+=(this.scores[i+1]*(Math.abs(this.scores[i]))); - if(this.scores[i]<0){ - totalModPoints+=this.scores[i+1]*(Math.abs(this.scores[i])); - totalModPosts+=this.scores[i+1]; - }else if(this.scores[i]>0){ - totalCommunityPoints+=this.scores[i+1]*this.scores[i]; - totalCommunityPosts+=this.scores[i+1]; - } - totalPosts+=this.scores[i+1]; - } - minimumRequiredMVP=Math.round(((this.winner=='community')?totalCommunityPoints:totalModPoints)*0.15); - alertText+="[B]Total points:[/B] "+totalPoints+" from "+totalPosts+" posts\n"; - alertText+="[B]Total community points:[/B] "; - if(totalCommunityPosts>0){ - alertText+=totalCommunityPoints+" from "+totalCommunityPosts+" posts\n"; - }else{ - alertText+="None\n"; + var alertText="[B]TUG OF WAR LAST ROUND STATS[/B]\n"; + var totalPoints=0; + var totalPosts=0; + var totalModPoints=0; + var totalModPosts=0; + var totalCommunityPoints=0; + var totalCommunityPosts=0; + var totalWinningPoints=0; + var minimumRequiredMVP; + var mvpList=new Array(); + var communityParticipants=new Array(); + var modParticipants=new Array(); + for(var i=1;i<this.scores.length;i+=3){ + //GM_log("STATS: User: "+this.scores[i-1]+", Multiplier: "+this.scores[i]+", Points: "+this.scores[i+1]+", Is Mod: "+this.scores[i+2]); + totalPoints+=(this.scores[i+1]*(Math.abs(this.scores[i]))); + if(this.scores[i]<0){ + totalModPoints+=this.scores[i+1]*(Math.abs(this.scores[i])); + totalModPosts+=this.scores[i+1]; + }else if(this.scores[i]>0){ + totalCommunityPoints+=this.scores[i+1]*this.scores[i]; + totalCommunityPosts+=this.scores[i+1]; } - alertText+="[B]Total mod points:[/B] "; - if(totalModPosts>0){ - alertText+=totalModPoints+" from "+totalModPosts+" posts\n"; + totalPosts+=this.scores[i+1]; + } + totalWinningPoints=(this.winner=='community')?totalCommunityPoints:totalModPoints; + minimumRequiredMVP=Math.round(totalWinningPoints*0.15); + alertText+="[B]Total points:[/B] "+totalPoints+" from "+totalPosts+" posts\n"; + alertText+="[B]Total community points:[/B] "; + alertText+=((totalCommunityPosts>0)?totalCommunityPoints+" from "+totalCommunityPosts+" posts":"None")+"\n"; + alertText+="[B]Total mod points:[/B] "; + alertText+=((totalModPosts>0)?totalModPoints+" from "+totalModPosts+" posts":"None")+"\n"; + alertText+="[B]Minimum required for MVP* ("+totalWinningPoints+" x 0.15):[/B] "+minimumRequiredMVP+"\n\n"; + for(var i=0;i<this.scores.length;i+=3){ + if(this.scores[i+1]<0){ + modParticipants.push(this.scores[i]); + modParticipants.push(Math.abs(this.scores[i+1])); + modParticipants.push(this.scores[i+2]); }else{ - alertText+="None\n"; + communityParticipants.push(this.scores[i]); + communityParticipants.push(this.scores[i+1]); + communityParticipants.push(this.scores[i+2]); } - alertText+="[B]Minimum required for MVP* ("+((this.winner=='community')?totalCommunityPoints:totalModPoints)+" x 0.15):[/B] "+minimumRequiredMVP+"\n\n"; - for(var i=0;i<this.scores.length;i+=3){ - if(this.scores[i+1]<0){ - modParticipants.push(this.scores[i]); - modParticipants.push(Math.abs(this.scores[i+1])); - modParticipants.push(this.scores[i+2]); - }else{ - communityParticipants.push(this.scores[i]); - communityParticipants.push(this.scores[i+1]); - communityParticipants.push(this.scores[i+2]); - } - } - alertText+="[B]COMMUNITY PARTICIPANTS[/B]\n"; - allowMVP=(this.winner=='community'); - communityStats=this.getListText(communityParticipants,minimumRequiredMVP); - alertText+=communityStats[0]+"\n"; - alertText+="[B]MODERATOR PARTICIPANTS[/B]\n"; - allowMVP=(this.winner=='mods'); - modStats=this.getListText(modParticipants,minimumRequiredMVP); - alertText+=modStats[0]+"\n"; - alertText+="[B]LAST ROUND MVPs[/B]\n"; - alertText+="- "+this.marker+" (at post #"+this.lastPostNumber+") \n"; - GM_log("MVP Order: "+this.marker+" made the mark at post #"+this.markerPost); - mvpList=(this.winner=='community')?communityStats[1]:modStats[1]; - for(var i=0;i<mvpList.length;i++){ - if(mvpList[i]!=this.marker){ - alertText+="- "+mvpList[i]+"\n"; - GM_log("MVP Order: "+mvpList[i]+" has spot #"+(i+2)); - } + } + alertText+="[B]COMMUNITY PARTICIPANTS[/B]\n"; + communityStats=this.getListText(communityParticipants,minimumRequiredMVP); + alertText+=communityStats[0]+"\n"; + alertText+="[B]MODERATOR PARTICIPANTS[/B]\n"; + modStats=this.getListText(modParticipants,minimumRequiredMVP); + alertText+=modStats[0]+"\n"; + alertText+="[B]LAST ROUND MVPs[/B]\n"; + alertText+="- "+this.marker+" (at post #"+this.markerPost+")\n"; + //GM_log("MVP order: "+this.marker+" made the mark at post #"+this.markerPost); + mvpList=(this.winner=='community')?communityStats[1]:modStats[1]; + for(var i=0;i<mvpList.length;i++){ + if(mvpList[i]!=this.marker){ + alertText+="- "+mvpList[i]+"\n"; + //GM_log("MVP order: "+mvpList[i]+" has spot #"+(i+2)); } - alertText+="\n*Starting with second place. The marker gets first place MVP."; - window.alert(alertText); - }else{ - window.alert("Tug of War is yet to be completed.\nIts score is "+this.currentScore+" points as of post #"+this.lastPostNumber); } - this.clearStats(); + alertText+="\n*Starting with second place. The marker gets first place MVP."; + window.alert(alertText); }, getListText: function(participants,minimumRequiredMVP){ var statsText=""; var thisScore; var mvpList=new Array(); - var doneSorting=false; var reCheck=true; - GM_log("Participant List: "+participants); var tempSpot; while(reCheck){ - reCheck=false; for(var i=0;i<participants.length;i+=3){ if(i+3>=participants.length){ @@ -228,12 +202,12 @@ var towStats = { } for(var i=0;i<participants.length;i+=3){ thisScore=participants[i+2]*participants[i+1]; - statsText+="[B]"+participants[i]+":[/B] "+participants[i+2]+" x "+participants[i+1]+" = "+thisScore+" "; - statsText+="point"+((thisScore!=1)?"s":""); - statsText+="\n"; - GM_log("Added "+participants[i]+" to the stats list DEBUG: Posts: "+participants[i+2]+", Multiplier: "+participants[i+1]+", Total Score: "+thisScore+", minimumRequiredMVP: "+minimumRequiredMVP); + statsText+="[B]"+participants[i]+":[/B] "+participants[i+2]+" x "+participants[i+1]+" = "+ + thisScore+" point"+((thisScore!=1)?"s":"")+"\n"; + //GM_log("Added "+participants[i]+" to the stats list DEBUG: Posts: "+participants[i+2]+", Multiplier: "+participants[i+1]+ + // ", Total Score: "+thisScore+", minimumRequiredMVP: "+minimumRequiredMVP); if(thisScore>=minimumRequiredMVP){ - GM_log("Adding "+participants[i]+" to the MVP list."); + //GM_log("Adding "+participants[i]+" to the MVP list."); mvpList.push(participants[i]); } } @@ -243,68 +217,61 @@ var towStats = { return new Array(statsText,mvpList); }, restoreStats: function(){ - var statsActive=GM_getValue("statsActive",false); - var scoresCount=GM_getValue("scores.count",0); - if(statsActive==false){ - GM_log("Attempting to save setting statsActive"); + if(!GM_getValue("statsActive",false)){ GM_setValue("statsActive",true); return false; - }else{ - this.lastUser=GM_getValue("lastPoster",null); - this.currentScore = parseInt(GM_getValue("CurrentScore")); - this.lastPostNumber = parseInt(GM_getValue("lastPostNumber")); - for(i=0;i<scoresCount;i++){ - this.scores.push(GM_getValue("scores."+i)); - //alert(GM_getValue("scores."+i)); - } - return true; } + var scoresCount=GM_getValue("scores.count",0); + this.lastPoster=GM_getValue("lastPoster",null); + this.currentScore=parseInt(GM_getValue("currentScore")); + this.lastPostNumber=parseInt(GM_getValue("lastPostNumber")); + for(i=0;i<scoresCount;i++){ + this.scores.push(GM_getValue("scores."+i)); + } + return true; }, startCounting: function(){ - //alert(5); - //var theAnswer; - //alert(6); if(this.restoreStats()){ startPost=this.lastPostNumber+1; }else{ - theAnswer=window.prompt("Specifiy a post number to begin counting.\nIf you do not know the post number, click Cancel."); + theAnswer=window.prompt("Specifiy a post number to begin counting.\n"+ + "If you do not know the post number, click Cancel."); if(theAnswer!=null){ startPost=parseInt(theAnswer); - GM_setValue('statsActive',true); + GM_setValue("statsActive",true); }else{ this.clearStats(); return false; } } - GM_log("Round score before counting: "+this.currentScore); - this.recordPosts(startPost); + //GM_log("Round score before counting: "+this.currentScore); + if(!this.recordPosts(startPost)){ + return false; + } if(this.winner!=null){ window.alert("Counting complete.\n"+ - "The "+((this.winner=='mods')?'-':'')+"200 mark is at post #"+this.markerPost+"\n"+ - "Stats will be displayed in the next dialog box."); + "The "+((this.winner=='mods')?'-':'')+"200 mark is at post #"+this.markerPost+"\n"+ + "Stats will be displayed in the next dialog box."); this.getSummary(); + this.clearStats(); }else{ this.saveStats(); if(!this.goToNextPage()){ - window.alert("Tug of War is yet to be completed.\nIts score is "+this.currentScore+" points as of post #"+this.lastPostNumber); + window.alert("Tug of War is yet to be completed.\n"+ + "Its score is "+this.currentScore+" points as of post #"+this.lastPostNumber); this.clearStats(); } } }, saveStats: function(){ - GM_log("lastPostNumber: "+this.lastPostNumber); - //GM_log("Attempting to save setting lastPostNumber, value: "+this.lastPostNumber); + //GM_log("Last post on this page: "+this.lastPostNumber); GM_setValue("lastPostNumber",this.lastPostNumber); - GM_log("Round score after counting this page's posts: "+this.currentScore); - //GM_log("Attempting to save setting currentScore, value: "+this.currentScore); - GM_setValue("CurrentScore",this.currentScore); + //GM_log("Current round score: "+this.currentScore); + GM_setValue("currentScore",this.currentScore); for(i=0;i<this.scores.length;i++){ - //GM_log("Attempting to save setting this.scores."+i+", value: "+this.scores[i]); GM_setValue("scores."+i,this.scores[i]); - //GM_log("Attempting to save setting this.scores.length, value: "+this.scores.length); GM_setValue("scores.count",this.scores.length); } - //GM_log("Attempting to save setting lastPoster, value: "+this.lastPoster); GM_setValue("lastPoster",this.lastPoster); }, goToNextPage: function(){ @@ -317,33 +284,23 @@ var towStats = { return false; } }, - isUserOnScoresList: function(username){ - for(var i=0;i<this.scores.length;i++){ - - } - }, clearStats: function(){ this.scores=new Array(); this.currentScore=0; this.lastPostNumber=null; + this.lastPoster=null; this.winner=null; this.marker=null; this.markerPost=null; - this.lastPoster=null; - keys = GM_listValues(); - for (var i=0, key=null; key=keys[i]; i++) { - GM_deleteValue(key); - GM_log("Deleted key: "+key); + keys=GM_listValues(); + for (var i=0,key=null; key=keys[i];i++) { + GM_deleteValue(key); } - GM_log("Reset Successful"); if(!this.alreadyHasStartCounting){ GM_registerMenuCommand("Start counting posts",function(){towStats.startCounting()},'S'); this.alreadyHasStartCounting=true; } - }, - parsePostNumber:function(numStr){ - return parseInt(numStr.substr(1)); } }; -towStats.init();
\ No newline at end of file +towStats.init(); |