newAnchor.appendChild(img); img = null; // insert the node as either a sibling or a child if (insertNode != null) anchor.parentNode.insertBefore(newAnchor, insertNode); else anchor.parentNode.appendChild(newAnchor); return newAnchor; };//////////////// SEARCH ENGINE /////////////////////////////// GOOGLE SEARCH ENGINE ///////////////searchshield.GoogleSearchEngine = function(search){ searchshield.SearchEngine.call(this, search); this.onlyPrimaries = false;};searchshield.GoogleSearchEngine.prototype = new searchshield.SearchEngine();searchshield.GoogleSearchEngine.prototype.constructor = searchshield.GoogleSearchEngine;searchshield.GoogleSearchEngine.prototype.name = "google"; // the name by which the search engine is known (always lowercase)searchshield.GoogleSearchEngine.prototype.validSearch = function(href) { var uri; if (typeof(this.search) === 'undefined' || null === this.search) uri = searchshield.parseLink(href); else uri = this.search.uri; if(!uri || !uri.host) return false; var hostMatch = false; var domain = uri.host; // re stitch the uri path and query elements to // use existing logic var path = uri.path + uri.delimiter + uri.query; // Domains valid for google searches, must start with '.' var valid_domains = new Array(".google.co", ".mozilla.co"); // For Google the host must match: // .google.com OR // .google.co.XX where XX is a country code // .google.XX where XX is a country code // Where any subdomain can come before the top level domain var domLen = valid_domains.length; for (var i = 0; i < domLen; i++) { var domainLen = domain.length; var valid_domain_len = valid_domains[i].length; var tldPos = domain.indexOf(valid_domains[i]); if (tldPos > -1) { if (domain.charAt(tldPos + valid_domain_len) == 'm') hostMatch = true; else if ((domain.charAt(tldPos + valid_domain_len) == '.') && ((domainLen - tldPos) == valid_domain_len+3)) hostMatch = true; } else { // get the form .google. to check the length of var dot_pos = valid_domains[i].indexOf(".",1); var valid_short_name = valid_domains[i].substring(0, dot_pos+1); tldPos = domain.indexOf(valid_short_name); if ((tldPos > -1) && ((domainLen - tldPos) == valid_domain_len)) hostMatch = true; } if (hostMatch) { // replace beginning of domain with www.google since links will refer back to it if ((i > 0) && (tldPos > -1)) { var last_dot = domain.indexOf(".",tldPos+1) if (last_dot > -1) domain = "www.google" + domain.substring(last_dot); } break; } } if (hostMatch) { // using ajax engine if ((path.indexOf("search?") == 0) || (path.indexOf("sponsoredlinks?") == 0) || (path.indexOf("webhp?") == 0) || (path.indexOf("webhp#") == 0) || (path.indexOf("#q=") == 0) || (path.indexOf("#hl=") == 0) || (path.indexOf("#sclient=") == 0)) { return true; } } return false;};searchshield.GoogleSearchEngine.prototype.includeLink = function(tag){ var href = ""; var outHref = false; var findStr = ""; // check for interstitials if (searchshield.DoesURLContain(tag.href, this.search.uri.host)) { findStr = this.search.uri.host + "/interstitial?"; if (tag.className == "l" && tag.href) { if (tag.href.indexOf(findStr) != -1) { findStr = "?url="; var pos = tag.href.indexOf(findStr); if (pos !== -1) { pos += 5; outHref = tag.href.substring(pos); if (searchshield.FilterUrl(outHref, this.filter_urls)) return false; return outHref; } } } if (tag.className == "sla") { findStr = "/url?q="; urlPos = tag.href.indexOf(findStr); if (urlPos != -1) { urlPos += 7; outHref = tag.href.substring(urlPos); return outHref; } } // if an ad id if ((tag.id.indexOf("pa") == 0) || (tag.id.indexOf("an") == 0) || (tag.className == "resultLink")) { var urlPos = -1; // ads now need unescaping href = unescape(tag.href); findStr= "/url?sa="; if (href.indexOf(findStr) != -1) { // first kind, locate real url findStr= "&q=http"; urlPos = href.indexOf(findStr); if (urlPos != -1) urlPos += 3; // puts it on the http } if (urlPos == -1) { findStr = "/pagead/iclk?sa="; if (href.indexOf(findStr)