should return a boolean if (!filterFunc || !filterFunc instanceof Function) return null; // go up the dom tree starting at node and look for anchor // before hitting a header, div or table element while ((node != null) && (node.tagName != null) && (node.tagName != "A")) { if (filterFunc(node)) { node = null; break; } node = node.parentNode; } return node;};searchshield.getDocuments = function (frame, frameArray){ // recursively get all embedded frames/docs frameArray.push(frame.document); var frames = frame.frames; for (var i = 0; i < frames.length; i++) { // recurse on each frame searchshield.getDocuments(frames[i], frameArray); } return frameArray;};searchshield.NextSiblingNode = function (element){ var TEXTNODE = 3; var ParentNode = element.parentNode; if (!ParentNode) return; var NextSibling = ParentNode.nextSibling; while (NextSibling) { if (NextSibling.nodeType != TEXTNODE) return NextSibling; NextSibling = NextSibling.nextSibling; } return;};searchshield.getParentNodeByAttribute = function (attrName, attrValue, node, maxDepth){ if (!node) return null; var maxLoop = maxDepth ? maxDepth : 1; var pNode = node.parentNode; if (!pNode) return null; for(; 0 < maxLoop; maxLoop--) { if ((pNode[attrName]) && (pNode[attrName].toLowerCase() === attrValue.toLowerCase())) { return pNode; } pNode = pNode.parentNode; if (!pNode) return null; } return null;};searchshield.getParentNodeByClassName = function (className, node, maxDepth) { return searchshield.getParentNodeByAttribute("className", className, node, maxDepth);};searchshield.getParentNodeById = function (id, node, maxDepth){ return searchshield.getParentNodeByAttribute("id", id, node, maxDepth);};searchshield.getParentNodeByTagName = function (tagName, node, attrName) { // find parent node by tag name and optional attribute name if (!tagName || !node || !node.parentNode) return null; tagName = tagName.toUpperCase(); while ((node != null) && (node.nodeType != 9)) { // if attrName is not provided just return TRUE if (node.nodeName == tagName) { var nodeHasAttribute = !!attrName ? node[attrName] : true; if (nodeHasAttribute) return node; } node = node.parentNode; } // no div return null;};searchshield.getHrefFromCiteElement = function (tag){ var rtnHtml; var tp = tag.parentNode; var tgpn = tp ? tp.parentNode : null; if (!tgpn) return; lastChildElem = tgpn.lastChild; while ((lastChildElem != null) && (lastChildElem.nodeName != 'SPAN') && (lastChildElem.nodeName != 'DIV')) { lastChildElem = lastChildElem.previousSibling; } if (lastChildElem) rtnHtml = lastChildElem.getElementsByTagName('cite')[0]; if (rtnHtml) rtnHtml = rtnHtml.innerHTML; return rtnHtml;};searchshield.getHrefFromSpanElement = function (tag){ var rtnHtml; var tp = tag.parentNode; var tgpn = tp ? tp.parentNode : null; if (!tgpn) return; siblingElem = tgpn.nextSibling; while ((siblingElem != null) && (siblingElem.nodeName != 'SPAN') && (siblingElem.className != 'site')) { siblingElem = siblingElem.nextSibling; if (siblingElem && siblingElem.className && (siblingElem.className.match(/res[13]/))) break; } if (siblingElem) rtnHtml = siblingElem.getElementsByTagName('a')[0]; if (rtnHtml) rtnHtml = rtnHtml.innerHTML; return rtnHtml;};searchshield.getTopLevelDocument = function (doc){ // return the top level document for the given doc, could be itself // TODO: determine a method of doing this for IE, if necessary // don't check about:blank if (doc && ((doc.location.href == "about:blank") || (doc.location.href == "about:Tabs"))) return doc; // Check if already a top level document for (var i = 0; i < gBrowser.browsers.length; i++) { if (doc == gBrowser.browsers[i].contentDocument) return doc; } // Not a top level, check all frames var documents; for (var j = 0; j < gBrowser.browsers.length; j++) { // get all docs for each browser documents = searchshield.getDocuments(gBrowser.browsers[j].contentWindow, new Array()); for (var k = 0; k < documents.length; k++) { // check if doc is from current browser if (doc == documents[k]) { // it is,