(ele, noTextEnable)
| 1628 | function getContentByLargest() { |
| 1629 | var childlist=pageData.querySelectorAll(largestContent.nodeName);//+(largestContent.className?"."+largestContent.className.replace(/(^\s*)|(\s*$)/g, '').replace(/\s+/g, '.'):"")); |
| 1630 | function getRightStr(ele, noTextEnable){ |
| 1631 | [].forEach.call(ele.querySelectorAll("a[href]"), a => { |
| 1632 | a.parentNode && a.parentNode.removeChild(a); |
| 1633 | }); |
| 1634 | if(retainImage){ |
| 1635 | [].forEach.call(ele.querySelectorAll("img[src]"), img => { |
| 1636 | let imgTxtNode=document.createTextNode(`, url || location.href)})`); |
| 1637 | img.parentNode.replaceChild(imgTxtNode, img); |
| 1638 | }); |
| 1639 | } |
| 1640 | let childNodes=ele.childNodes,cStr="\r\n",hasText=false; |
| 1641 | for(let j=0;j<childNodes.length;j++){ |
| 1642 | let childNode=childNodes[j]; |
| 1643 | if(childNode.nodeType==3 && childNode.data && !/^[\s\-\_\?\>\|]*$/.test(childNode.data))hasText=true; |
| 1644 | if(childNode.innerHTML){ |
| 1645 | childNode.innerHTML=childNode.innerHTML.replace(/\<\s*br\s*\>/gi,"\r\n").replace(/\n+/gi,"\n").replace(/\r+/gi,"\r"); |
| 1646 | } |
| 1647 | let content=childNode.textContent; |
| 1648 | if(content){ |
| 1649 | if(!content.trim())continue; |
| 1650 | cStr+=content.replace(/[\uFEFF\xA0 ]+/g," ").replace(/([^\r]|^)\n([^\r]|$)/gi,"$1\r\n$2"); |
| 1651 | } |
| 1652 | if(childNode.nodeType!=3 && !/^(I|A|STRONG|B|FONT|IMG)$/.test(childNode.nodeName))cStr+="\r\n"; |
| 1653 | else if(childNode.nextSibling && /^P$/.test(childNode.nextSibling.nodeName))cStr+="\r\n"; |
| 1654 | } |
| 1655 | if(hasText || noTextEnable || ele==largestContent)rStr+=cStr+"\r\n"; |
| 1656 | } |
| 1657 | var sameDepthChildren=[]; |
| 1658 | for(i=0;i<childlist.length;i++){ |
| 1659 | var child=childlist[i]; |
no test coverage detected