help with Google PR, In JS

Status
Not open for further replies.

litewarez

Active Member
1,367
2008
1
0
heya guys.

im working on a PR Checker plugin for jQuery but i cant seem to get the hashing to work.

The hashing it returns is invalid and im unsure why exactly.

Take a look at the code

Code:
(
	$.fn.PageRank = function(callback)
	{
		var _library = new Object();
		
		//Creat the system library
		var HASH_SEED = "Mining PageRank is AGAINST GOOGLE'S TERMS OF SERVICE. Yes, I'm talking to you, scammer."
		_library.parseUrl = function(a)
		{
			var b = {};
			/*
				* parse the url to extract its parts
			*/
			if (a = a.match(/((s?ftp|https?):\/\/){1}([^\/:]+)?(:([0-9]+))?([^\?#]+)?(\?([^#]+))?(#(.+))?/)) {
				b.scheme = a[2] ? a[2] : "http";
				b.host = a[3] ? a[3] : null;
				b.port = a[5] ? a[5] : null;
				b.path = a[6] ? a[6] : null;
				b.args = a[8] ? a[8] : null;
				b.anchor = a[10] ? a[10] : null
			}
			return b
		}

		_library.toHex = function(a){
			return (a < 16 ? "0" : "") + a.toString(16)
		}

		_library.hexEncodeU32 = function(a) {
			var b = _library.toHex(a >>> 24);
			b += _library.toHex(a >>> 16 & 255);
			b += _library.toHex(a >>> 8 & 255);
			return b + _library.toHex(a & 255)
		}
		
		_library.generateHash = function(a)
		{
			for (var b = 16909125, c = 0; c < a.length; c++)
			{
				b ^= HASH_SEED.charCodeAt(c % 87) ^ a.charCodeAt(c);
				b = b >>> 23 | b << 9;
			}
			return _library.hexEncodeU32(b)
		}

		var CheckPageRank = function(url)
		{
			urlSegments = _library.parseUrl(url);
			if(urlSegments && urlSegments.host)
			{
				checkLocation = "http://www.google.com/search?client=navclient-auto&ch=8" + _library.generateHash(urlSegments.host) + "&features=Rank&q=info:" + urlSegments.host;
				return checkLocation
			}
			return false;
		}		
		//Return the callback
		$(this).each(function(){
			page_rank = CheckPageRank(this.href);
			callback(page_rank);
		})
	}
)(jQuery);

Usage in jQuery is like so:

Code:
$(document).ready(function() {
	$('a').PageRank(function(pr){
             $(this).append('Pr: ' pr);
	})
})

but if you alert the pr its the url obv because i havent built in te ajax yet but can anyone understand why this is not working ?

Heres the code i have studied

http://www.v7n.com/forums/coding-forum/30174-javascript-php.html
 
6 comments
Have you tried asking for help over at stackoverflow.com
Im still learning jquery so i cant help unfortunately but i have asked some questions about jquery and other stuff over their and they are really helpful just an option if no one can help you here :)
 
Ca't really post his on my Stack Account lol, it is illegal :/ Im waiting for Hypers,Jayfella to see if they have experience here :(

Thanks anyway.
 
yea i fixed it now, it was because of the href being detected by jQuery has to be the exact domain and path not litewarez.net/

I knew the algorithm was ok because its not really that complex, just the 1 string into a checksum.
 
^ lol, that makes me remember one time I was pulling my hair because my AJAX requests wouldn't work (I had just changed to https) and then I realised it was related to cross domain issues xD
 
Status
Not open for further replies.
Back
Top