Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial import.

  • Loading branch information...
commit 46a80b81284be60f3725ece6eeed8ee13a665990 0 parents
Juriy Zaytsev authored
Showing with 96 additions and 0 deletions.
  1. +1 −0  foxify.js
  2. +95 −0 foxify.src.js
1  foxify.js
@@ -0,0 +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();})();
95 foxify.src.js
@@ -0,0 +1,95 @@
+(function(){
+
+ function hasParentWithClass(element, className) {
+ var reClassName = new RegExp('(?:\\s|^)' + className + '(?:\\s|$)');
+ while ((element = element.parentNode)) {
+ if (element && reClassName.test(element.className)) return true;
+ }
+ return false;
+ }
+ function getVersionTotal(element) {
+ var parentRow;
+ while ((element = element.parentNode)) {
+ if (element && (element.tagName.toUpperCase() === 'TR')) {
+ parentRow = element;
+ break;
+ }
+ }
+ for (var i = 0, j = 0, child, len = parentRow.childNodes.length; i < len; i++) {
+ child = parentRow.childNodes[i];
+ if (child.nodeType !== 1) continue;
+ if (j++ == 2) return parseInt(child.innerHTML.replace(/,/g, ''));
+ }
+ }
+ function countPercentages() {
+ var total = 0;
+ for (var prop in versionTotals) {
+ total += versionTotals[prop];
+ }
+ for (var prop in versionTotals) {
+ versionTotals[prop] += (' (' + ((versionTotals[prop] * 100) / total).toFixed(2) + '%)');
+ }
+ }
+ function padString(str, length) {
+ var numSpacesToPad;
+ if (str.length < length) {
+ numSpacesToPad = length - str.length;
+ return str + new Array(numSpacesToPad + 1).join(' ');
+ }
+ return str;
+ }
+
+ function displayTotals() {
+ var str = '';
+ for (var name in versionTotals) {
+ str += (padString(name, 5) + ': ' + versionTotals[name] + '\n')
+ }
+ alert(str);
+ }
+
+ var anchors = document.getElementsByTagName('a'),
+ i = anchors.length, el, match, majorVersion,
+ color, bgColor;
+
+ var versionTotals = { '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);
+ }
+ else if (majorVersion >= 3) {
+ bgColor = 'yellow';
+ versionTotals['3'] += getVersionTotal(el);
+ }
+ else if (majorVersion >= 2) {
+ bgColor = 'orange';
+ versionTotals['2'] += getVersionTotal(el);
+ }
+ else if (majorVersion >= 1.5) {
+ bgColor = 'red';
+ color = '#fff';
+ versionTotals['1.5'] += getVersionTotal(el);
+ }
+ else if (majorVersion >= 1) {
+ bgColor = 'black';
+ color = '#fff';
+ versionTotals['1'] += getVersionTotal(el);
+ }
+ else continue;
+
+ el.style.backgroundColor = bgColor;
+ el.style.padding = '0.5em';
+ el.style.color = color;
+ }
+ }
+
+ countPercentages();
+ displayTotals();
+})();
Please sign in to comment.
Something went wrong with that request. Please try again.