Created
February 25, 2013 12:14
-
-
Save jodaka/5029430 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log(1111111,"hello"),function(e){"use strict";var t=e.body,n=0,r=0,i=0,s=0,o={img:0,text:0},u=/hidden|ad-break|ad_|-ad|ads|agegate|byline|combx|comment|controls|community|date|disqus|extra|facebook|foot|header|links|menu|pager|pagination|popup|print|remark|rss|sidebar|social|share|shoutbox|sidebar|sponsor|time|tags|tools|tweet|twitter|widget/i,a=function(e){for(var t=0,f=e.childNodes.length;t<f;t++){var l=e.childNodes[t];if(l.nodeType!==3&&l.nodeType!==1)continue;if(l.tagName==="SCRIPT"||l.tagName==="IFRAME"||l.tagName==="STYLE"||l.tagName==="FORM"||l.tagName==="INPUT"||l.tagName==="SELECT"||l.tagName==="TEXTAREA"||l.tagName==="HEADER"||l.tagName==="FOOTER"||l.tagName==="ASIDE"||l.tagName==="NOSCRIPT")continue;var c=l.tagName+" "+l.id+" "+l.className;if(c.search(u)!==-1)continue;if(l.nodeType===3){var h=l.textContent.trim().length;h>i&&(i=h),h>200&&s++,n+=h;continue}l.tagName==="A"&&(r+=l.textContent.trim().length),l.tagName==="IMG"&&l.width>400&&l.height>300&&o.img++,(l.tagName==="P"||l.tagName==="LI"||l.tagName==="ARTICLE")&&o.text++,l.childNodes.length>0&&a(l)}};a(t);var f=n/r,l=n/o.text;console.log("long text nodes ",s),console.log("total text length ",n),console.log("links text length ",r),console.log("text to links ratio ",f.toFixed(2)),console.log("text to tags ratio ",l.toFixed(2)),console.log("tags img %s, text nodes %d",o.img,o.text),console.log("longest text ",i);var c=0;i>1e3?(c+=10,console.log(" + longest text part 10")):i>500?(console.log(" + longest text part 0.3"),c+=.3):(c-=.3,console.log(" - longest text part 0.3")),c+=s*.7,console.log("+ long text nodes ",s*1.5),console.log("score=",c),o.img>1&&(console.log(" + images 0.6"),c+=.6),f<5?(console.log(" - textToLinks 0.5"),c-=.5):(console.log(" + textToLinks 0.2"),c+=.2);var h=n*f;while(h>0)h-=5e3,c+=.25;var p=r/f;while(r>0)r-=1e3,c-=.5;console.log(" Final score ",c);var d=new Image;d.src="http://localhost/?articleScore="+c}(document); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment