User:Kevin B12/iprange/monobook.js

// /////////////////////////////////IP range contribs check///////////////////////////////// //globals var starting_IP_trunk = ''; var starting_IP_end = 0; var IP_num_JS_count = 0; var IP_num_JS_static = 0; //

$(IPRange_contribs_tab) function IPRange_contribs_tab { if (location.href.search(/Special(:|%3A)Contributions/) != -1 && location.href.search(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/) != -1 && location.href.search(/\d{1,3}(@|%40)\d{1,2}/) == -1) { addTab("javascript:IPRange_contribs_query", "IP Range", "ca-range", "Check a range", ""); } }

function IPRange_contribs_query { if (location.href.indexOf('/Special:Contributions/') != -1) {var IP = location.href.split('/Special:Contributions/')[1];} else {var IP = location.href.split('&target=')[1].split('&')[0];} var number = prompt('Number of consecutive IPs?' + '\n' + '(/24 bit check or less.)'); if (!number){return;} location.href = 'http://en.wikipedia.org/w/index.php?&limit=1&target=' + IP + '@' + number + '&title=Special%3AContributions&namespace='; }

function IPRange_contribs { if (location.href.search(/title=Special:Contributions&target=\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}@\d{1,2}/) != -1) { var target = location.href.split('&target=')[1]; var static_IP_mark = target.split('.')[3]; starting_IP_trunk = target.split(static_IP_mark)[0]; var ending_num = target.split('@')[1]; starting_IP_end = target.split('.')[3].split('@')[0]; // var IP_end_last_show = 1*starting_IP_end + 1*ending_num; var IP_start_show = starting_IP_trunk + starting_IP_end; var IP_last_show = starting_IP_trunk + IP_end_last_show; document.getElementById('bodyContent').innerHTML = document.getElementById('bodyContent').innerHTML.replace('No changes were found matching these criteria.',''); document.getElementById('siteSub').innerHTML += " Checking IP range contributions from " + IP_start_show + " to " + IP_last_show + " :"; IPRange_contribs_XML; } else if (location.href.search(/&target=\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}%40\d{1,2}/) != -1 && location.href.indexOf('&title=Special%3AContributions') != -1) { var target = location.href.split('&target=')[1].split('&')[0]; var static_IP_mark = target.split('.')[3]; starting_IP_trunk = target.split(static_IP_mark)[0]; var ending_num = target.split('%40')[1]; starting_IP_end = target.split('.')[3].split('%40')[0]; // var IP_end_last_show = 1*starting_IP_end + 1*ending_num; var IP_start_show = starting_IP_trunk + starting_IP_end; var IP_last_show = starting_IP_trunk + IP_end_last_show; document.getElementById('bodyContent').innerHTML = document.getElementById('bodyContent').innerHTML.replace('No changes were found matching these criteria.',''); document.getElementById('siteSub').innerHTML += " Checking IP range contributions from " + IP_start_show + " to " + IP_last_show + " :"; IPRange_contribs_XML; } // else if (location.href.search(/&target=\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}@\d{1,2}/) != -1 && location.href.indexOf('&title=Special%3AContributions') != -1) { document.getElementById('siteSub').innerHTML += ' Select a namespace and press "Go" to check contribtutions from this IP range. This will only check back 20 edits however. '; } }

function IPRange_contribs_XML { var namespace = '&namespace='; if (location.href.search(/&namespace=\d/) != -1) {namespace = '&namespace=' + location.href.split('&namespace=')[1].split('&')[0];} var target = location.href.split('&target=')[1].split('&')[0]; if (target.indexOf('@') != -1) {var ending_num = target.split('@')[1];} else if (target.indexOf('%40') != -1) {var ending_num = target.split('%40')[1];} if (IP_num_JS_count > ending_num){alert('Edits retrieved.'); return;} var current_num = 1*starting_IP_end + 1*IP_num_JS_count; if (current_num > 255){alert('IP bloc number exceeds 255, query stopped!'); return;} if (location.href.indexOf('Special:Contributions&target=') != -1) { var URL = location.href.split('Special:Contributions&target=')[0] + 'Special:Contributions&target=' + starting_IP_trunk + current_num + namespace + '&limit=30'; } else { var URL = 'http://en.wikipedia.org/w/index.php?title=Special:Contributions&target=' + starting_IP_trunk + current_num + namespace + '&limit=30'; } document.getElementById('contentSub').innerHTML = " Checking: " + starting_IP_trunk + current_num + " | URL: " + URL + " "; gml_http = HTTPClient; gml_http.open("GET", URL, true); gml_http.onreadystatechange = parse_contribs_xml; gml_http.send(null); }

function parse_contribs_xml { if (gml_http.readyState != 4) {return;} xml = gml_http.responseText; if (xml.indexOf('No changes were found matching these criteria.') == -1) { var contribs = xml.split('')[1].split('')[0]; var current_num = 1*starting_IP_end + 1*IP_num_JS_count; document.getElementById('bodyContent').innerHTML += ' ' + starting_IP_trunk + current_num + ' ' + '' + contribs + ''; } IP_num_JS_count += 1; IPRange_contribs_XML; } /////////////////////////////////

//Revert options $(Revertfunctions) function Revertfunctions { IPRange_contribs; } //