/
foxify.js
1 lines (1 loc) · 2.1 KB
/
foxify.js
1
javascript:%20(function(){function%20hasParentWithClass(element,className){var%20reClassName=new%20RegExp('(?:\\s|^)'+className+'(?:\\s|$)');while((element=element.parentNode)){if(element&&reClassName.test(element.className))return%20true;}%20return%20false;}%20function%20getVersionTotal(element){var%20parentRow;while((element=element.parentNode)){if(element&&(element.tagName.toUpperCase()==='TR')){parentRow=element;break;}}%20for(var%20i=0,j=0,child,len=parentRow.childNodes.length;i<len;i++){child=parentRow.childNodes[i];if(child.nodeType!==1)continue;if(j++==2)return%20parseInt(child.innerHTML.replace(/,/g,''));}}%20function%20countPercentages(){var%20total=0;for(var%20prop%20in%20versionTotals){total+=versionTotals[prop];}%20for(var%20prop%20in%20versionTotals){versionTotals[prop]+=('%20('+((versionTotals[prop]*100)/total).toFixed(2)+'%)');}}%20function%20padString(str,length){var%20numSpacesToPad;if(str.length<length){numSpacesToPad=length-str.length;return%20str+new%20Array(numSpacesToPad+1).join('%20');}%20return%20str;}%20function%20displayTotals(){var%20str='';for(var%20name%20in%20versionTotals){str+=(padString(name,5)+':%20'+versionTotals[name]+'\n')}%20alert(str);}%20var%20anchors=document.getElementsByTagName('a'),i=anchors.length,el,match,majorVersion,color,bgColor;var%20versionTotals={'1':0,'1.5':0,'2':0,'3':0,'3.5+':0};while(i--){if(!hasParentWithClass((el=anchors[i]),'text_wrapper'))continue;if((match=el.innerHTML.match(/^\s*(\d\.\d)/))&&match[1]){majorVersion=parseFloat(match[1]);color='inherit';if(majorVersion>=3.5){bgColor='lightgreen';versionTotals['3.5+']+=getVersionTotal(el);}%20else%20if(majorVersion>=3){bgColor='yellow';versionTotals['3']+=getVersionTotal(el);}%20else%20if(majorVersion>=2){bgColor='orange';versionTotals['2']+=getVersionTotal(el);}%20else%20if(majorVersion>=1.5){bgColor='red';color='#fff';versionTotals['1.5']+=getVersionTotal(el);}%20else%20if(majorVersion>=1){bgColor='black';color='#fff';versionTotals['1']+=getVersionTotal(el);}%20else%20continue;el.style.backgroundColor=bgColor;el.style.padding='0.5em';el.style.color=color;}}%20countPercentages();displayTotals();})();