Post by Samuel on Feb 3, 2007 4:52:37 GMT -5
Ok I am going to break down the code coded by simie (here), which removes user's post count for anyone without admin powers(the admin button)
Ok, let's get started right away!
<script type="text/javascript">
This quite obviously starts the script
sTD = document.getElementsByTagName("td");
This is the part which assigns a variable for all of the TD tags in the document,so we can easily grab them. sTD is our variable name.
if(location.href.match(/on=(displ|search2|viewpr|pmv|(user)?rece|cal\w+iew)/i) && !sTD[5].innerHTML.match(/ion=admin/i)){
If statement,Ok this part uses a location check,in this case, if the page is displaying a thread, searching, viewing a profile or reading a pm and a few others using RegExp
The next part is the "&&" which is basically two conditions and !sTD mean if sTD[5].innerHTML is NOT equal too and then what to look for.
for(i=0;i<sTD.length;i++){
For loop, for the TD variable, so we can look for the TD with the user's post count in
if(sTD.innerHTML.match(/Posts: /i)){
If statement, this is checking every TD cell for this certain part of information
sTD.innerHTML = sTD.innerHTML.replace(/Posts: \d{0,100}(\s)?\<br(\s)?(\/)?\>/i, '');
Ok, this part might look a bit crazy, but the only confusing part of it is the RegExp. This part replaces the Post Count part(and the <br /> after it) with a blank space(nothing).
}
}
}
</script>
Ends if statement, for loop, if statement and then ends the script
Visit here for a list Regular Expressions
Visit here for a Quick Tutorial on RegExp
Repost if you want, only took me about 15 minutes. Pretty good explanation though
<script type="text/javascript">
sTD = document.getElementsByTagName("td");
if(location.href.match(/on=(displ|search2|viewpr|pmv|(user)?rece|cal\w+iew)/i) && !sTD[5].innerHTML.match(/ion=admin/i)){
for(i=0;i<sTD.length;i++){
if(sTD[i].innerHTML.match(/Posts: /i)){
sTD[i].innerHTML = sTD[i].innerHTML.replace(/Posts: \d{0,100}(\s)?\<br(\s)?(\/)?\>/i, '');
}
}
}
</script>
Ok, let's get started right away!
<script type="text/javascript">
This quite obviously starts the script
sTD = document.getElementsByTagName("td");
This is the part which assigns a variable for all of the TD tags in the document,so we can easily grab them. sTD is our variable name.
if(location.href.match(/on=(displ|search2|viewpr|pmv|(user)?rece|cal\w+iew)/i) && !sTD[5].innerHTML.match(/ion=admin/i)){
If statement,Ok this part uses a location check,in this case, if the page is displaying a thread, searching, viewing a profile or reading a pm and a few others using RegExp
The next part is the "&&" which is basically two conditions and !sTD mean if sTD[5].innerHTML is NOT equal too and then what to look for.
for(i=0;i<sTD.length;i++){
For loop, for the TD variable, so we can look for the TD with the user's post count in
if(sTD.innerHTML.match(/Posts: /i)){
If statement, this is checking every TD cell for this certain part of information
sTD.innerHTML = sTD.innerHTML.replace(/Posts: \d{0,100}(\s)?\<br(\s)?(\/)?\>/i, '');
Ok, this part might look a bit crazy, but the only confusing part of it is the RegExp. This part replaces the Post Count part(and the <br /> after it) with a blank space(nothing).
}
}
}
</script>
Ends if statement, for loop, if statement and then ends the script
Visit here for a list Regular Expressions
Visit here for a Quick Tutorial on RegExp
Repost if you want, only took me about 15 minutes. Pretty good explanation though