Tracker 需要移除页面的 HTML 注释节点,鉴于注释的复杂性,为了靠谱点,不使用正则了,顺手写了个获取 HTML 注释的工具函数:vargetHtmlCommentNodes =function(){varcn, push;cn =document.COMMENT_NODE;push = [].push;returnfunctionf(node){varresult, c, l, i;result = [];if( node.nodeType == cn )result.push( node );elseif( c = node.childNodes, l = c.length )for( i =0; i < l; i ++ )push.apply( result, f( c[ i ] ) );returnresult;}}();用法:getHtmlCommentNodes(document.documentElement );
...
继续阅读
(20)