Jump to content

User:Voice of All/monobook/parse.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// Some functions for parsing raw HTML.
// Need to be maintained...

window.getSumOfHistLI = function(li)
{
	var the_sum = '';
	var l = document.getElementById('bodyContent').getElementsByTagName('li')[li];
	var ls = l.getElementsByTagName('span');
	
	for (k = 0; k < ls.length; k++)
	{
		if (ls[k].className=='autocomment') 
			{       
                 if (ls[k-1].innerHTML.indexOf("-</span> ") !=-1)
                 {the_sum = ls[k-1].innerHTML.split("-</span> ")[1].split("</span>")[0];}
                 else if (ls[k-1].innerHTML.indexOf("-</span>") !=-1)
                 {the_sum = ls[k-1].innerHTML.split("-</span>")[1].split("</span>")[0];}
                 else if (ls[k-1].innerHTML.indexOf("</span>") !=-1)
                 {the_sum = ls[k-1].innerHTML.split("</span>")[1].split("</span>")[0];}
                 else {the_sum = '';}
                  break;
			}
		else if (ls[k].className=='comment') 
			{the_sum = ls[k].innerHTML;}
	}
	the_sum = the_sum.replace(/(-<\/span>|→)/gi,'');
	return the_sum;
}

window.getSumOfContribsLI = function(li)
{
	return getSumOfHistLI(li);
}

window.getTimeOfHistLI = function(li)
{
	var the_time = '';
	var l = document.getElementById('bodyContent').getElementsByTagName('li')[li];
	var la = l.getElementsByTagName('a');
	
	for ( var k = 0; k < la.length; k++)
	{
		if( la[k].href.indexOf('&oldid=') !=-1 && la[k].href.indexOf('&diff=') ==-1 ) {
			the_time = la[k].innerHTML;
			break;
		}
	}
	return the_time;
}

window.getTimeOfContribsLI = function(li)
{
	var the_time = '';
	var l = document.getElementById('bodyContent').getElementsByTagName('li')[li];
	var la = l.getElementsByTagName('a');
	
	for ( var k = 0; k < la.length; k++)
	{
		if( la[k].href.indexOf('&oldid=') !=-1 && la[k].href.indexOf('&diff=') ==-1 ) {
			the_time = la[k].innerHTML;
			break;
		}
	}
	return the_time;
}