0

Hello,

I'm trying to code a script using GreaseMonkey that alert's you when someone removes a reputation from you. It's for a mybb forum.

So it needs to: Search the source for the usernames > Put each into an array > Store the array and check it only when that one page is accessed (reputation.php) > Tell you if someones removed it. The page will only contain 15 names, so it shouldn't cause any loading issues.

This is what I've got so far.

// ==UserScript==
// @name           test
// @namespace      testing
// @description    Tells you went someone removes a rep from you
// @include         http://*myforum.net/reputation.php?uid=310224*
// ==/UserScript==

function dump(arr,level) {
	var dumped_text = "";
	if(!level) level = 0;
	
	//The padding given at the beginning of the line.
	var level_padding = "";
	for(var j=0;j<level+1;j++) level_padding += "    ";
	
	if(typeof(arr) == 'object') { //Array/Hashes/Objects 
		for(var item in arr) {
			var value = arr[item];
			
			if(typeof(value) == 'object') { //If it is an array,
				dumped_text += level_padding + "'" + item + "' ...\n";
				dumped_text += dump(value,level+1);
			} else {
				dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
			}
		}
	} else { //Stings/Chars/Numbers etc.
		dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
	}
	return dumped_text;
}
var body = document.body.innerHTML;
if(body.match(/<span style="color:#0066FF">(.*)<\/span><\/a>/g)) {
alert('win');
var myarray;
myarray = body.match(/<span style="color\:[^a-fA-F0-9][a-fA-F0-9][^"]+">([^<]+)<\/span><\/a>/g);
alert(dump(myarray,1));
if (document.getElementById("pm_notice")) {
document.getElementById("pm_notice").innerHTML= "XXX Has removed there rep!";
}
} else {
alert("fail");
}

I'd really appreciate any help with making this work.

Example of a reputation page: [IMG]http://www.mybb.com/assets/images/tour/reputation.png[/IMG]

Example of giving someone a reputation: [IMG]http://www.mybb.com/assets/images/tour/reputation-rate.png[/IMG]

Thankyou.

P.S - If you have MSN, PM me and i'll add you. Thanks

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Taywin
0

From screening through, I found one type of syntax error which is at the line below.

body.match(/<span style="color:#0066FF">(.*)<\/span><\/a>/g)
// and
myarray = body.match(/<span style="color\:[^a-fA-F0-9][a-fA-F0-9][^"]+">([^<]+)<\/span><\/a>/g);

This should be...

body.match(/<span style=\"color:#0066FF\">(.*)<\/span><\/a>/g)
// and
myarray = body.match(/<span style=\"color\:[^a-fA-F0-9][a-fA-F0-9][^\"]+\">([^<]+)<\/span><\/a>/g);

but the second one could be a bit more intuitive as...

myarray = body.match(/<span style=\"color:[^>]*>([^<]+)<\/span><\/a>/g);

Edited by Taywin: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.