Jump to content


[javacript] please check


No replies to this topic

#1 Silence

    Semi-Pro

  • Member
  • 238 posts
  • Projects: Maintaning the N00Bity of people~

Posted 18 February 2008 - 12:15

can anyone check this js code? Its a friendster hack I made.
it show the viewers main pic and info. friendster is like myspace btw.

The Problem is that it multiplies uncontrollably creating many boxes.

please check if I made any mistakes.

if (typeof SPAWNPIC == "undefined") { SPAWNPIC = {}; }
SPAWNPIC = {
		photo: null,

		init: function() {
			if (pageViewerID!== "") {
				this.ajaxRequest("http://"+location.hostname+"/"+pageViewerID,SPAWNPIC.viewer,null);
			}
		},

		viewer: function(htm) {
				if (htm.replace(/^\s*|\s*$/g,"") === null) {

					alert("VMP Error: Unable to parse the photo!");
					return;
				}else if (htm) {
					var name = /controlpanel_header&#34;>&#40;&#91;\S\s&#93;+?&#41;<a\s+?name=&#34;controlpanel/i.exec&#40;htm&#41;&#91;1&#93;.replace&#40;/^&#40;\d&#41;$/,&#34;0$1&#34;&#41;;
					var photo = /imgblock200&#34;><a&#91;\S\s&#93;*?>&#40;&#91;\S\s&#93;+?&#41;<\/a><\/div>/i.exec&#40;htm&#41;&#91;1&#93;.replace&#40;/^&#40;\d&#41;$/,&#34;0$1&#34;&#41;;
					var status = /data&#34;>&#40;&#91;\S\s&#93;+?&#41;<\/span><\/li>/i.exec&#40;htm&#41;&#91;1&#93;.replace&#40;/^&#40;\d&#41;$/,&#34;0$1&#34;&#41;;
					var since = /Since\&#58;\s+?<\/span>&#40;&#91;\S\s&#93;+?&#41;<\/li>/i.exec&#40;htm&#41;&#91;1&#93;.replace&#40;/^&#40;\d&#41;$/,&#34;0$1&#34;&#41;;
					var location = /Location\&#58;\s+<\/span>&#40;&#91;\S\s&#93;+?&#41;<\/li>/i.exec&#40;htm&#41;&#91;1&#93;.replace&#40;/^&#40;\d&#41;$/,&#34;0$1&#34;&#41;;
					this.photo = &#34;<div class=\&#34;fitem1wrapper\&#34;>&#34;+
								 &#34;<table class\&#34;fitem1table\&#34;>&#34;+
								 &#34;<tr><td class=\&#34;itd\&#34;>&#34;+
								 &#34;<a href=\&#34;/&#34;+pageViewerID+&#34;\&#34; title=\&#34;&#34;+pageViewerFName+&#34;\&#34;>&#34;+photo+&#34;</a></td>&#34;+ 
								 &#34;<td class=\&#34;dtd\&#34;><ul class=\&#34;data\&#34;>&#34;+
								 &#34;<div class=\&#34;title\&#34;><li><a href=\&#34;/&#34;+pageViewerID+&#34;\&#34;>&#34;+name+&#34;</a><br>&#34;+
								 &#34;Friendster&nbsp;ID&#58;&nbsp;<a href=\&#34;/&#34;+pageViewerID+&#34;\&#34;>&#34;+pageViewerID+&#34;</a>&#34;+status+&#34;<br>&#34;+
								 &#34;Member&nbsp;Since&#58;&nbsp;&#34;+since+&#34;<br>&#34;+
								 &#34;Location&#58;&nbsp;&#34;+location+&#34;</li>&#34;+
								 &#34;</div></ul></td></tr></table></div>&#34;;
								 SPAWNPIC.box&#40;&#34;Hello &#34;+name,this.photo,&#34;spawnpic&#34;,/friends/i,&#34;above&#34;&#41;;
				}
		},

		ajaxRequest&#58; function&#40;url,func,handler&#41; {
				var httprequest = window.XMLHttpRequest? new XMLHttpRequest&#40;&#41;&#58;new ActiveXObject&#40;&#34;Msxml2.XMLHTTP&#34;&#41;;
				httprequest.onreadystatechange = function&#40;&#41; {
					if &#40;httprequest.readyState == 4&#41; {
						if &#40;httprequest.status == 200&#41; {
							func&#40;httprequest.responseText,handler&#41;;
						}			
					}
				};
				httprequest.open&#40;&#34;GET&#34;, url, true&#41;;
				httprequest.send&#40;null&#41;;

		},

		box&#58; function&#40;head,code,id,sibling,x&#41; {
				var sbdiv = document.createElement&#40;&#34;div&#34;&#41;;
				sbdiv.className=&#34;commonbox &#34;+id;
				sbdiv.id = id;
				if &#40;!head&#41; head = &#34;&#34;;
				else head = &#34;<h2>&#34;+head+&#34;</h2>&#34;;  
				sbdiv.innerHTML = head;
				sbdiv.appendChild&#40;document.createElement&#40;&#34;div&#34;&#41;&#41;;
				sbdiv.getElementsByTagName&#40;&#34;div&#34;&#41;&#91;0&#93;.id =&#34;content_&#34;+id;
				sbdiv.getElementsByTagName&#40;&#34;div&#34;&#41;&#91;0&#93;.innerHTML = code;
				var sbli = document.createElement&#40;&#34;LI&#34;&#41;;
				sbli.appendChild&#40;sbdiv&#41;; 
				if &#40;!x&#41; this.getModuleByClassName&#40;sibling&#41;&#91;0&#93;.parentNode.parentNode.appendChild&#40;sbli&#41;;
				else if &#40;x == &#34;below&#34;&#41; this.getModuleByClassName&#40;sibling&#41;&#91;0&#93;.parentNode.appendChild&#40;sbli&#41;;
				else if &#40;x == &#34;above&#34;&#41; {
						var ul = this.getModuleByClassName&#40;sibling&#41;&#91;0&#93;;
						ul.parentNode.parentNode.insertBefore&#40;sbli,ul.parentNode&#41;;
				}
		},

		getModuleByClassName&#58; function&#40;sClass&#41; {
				var elm = &#91;&#93;;
				var els = document.getElementsByTagName&#40;&#34;*&#34;&#41; || document.all;
				for &#40;var j=0,k=els.length;j<k;j++&#41; {
						if &#40;new RegExp&#40;sClass&#41;.test&#40;els&#91;j&#93;.className&#41;&#41;elm.push&#40;els&#91;j&#93;&#41;;
				}
				return elm;
		}
};SPAWNPIC.init&#40;&#41;;

Posted Image



1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users