mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-23 02:42:41 +01:00
18 lines
1.7 KiB
JavaScript
18 lines
1.7 KiB
JavaScript
/*! Home: https://github.com/gorhill/publicsuffixlist.js */
|
|
;(function(f){var b={};var h={};var a=480;
|
|
var g=/[^a-z0-9.-]/;function i(k){if(!k||k.charAt(0)==="."){return""}k=k.toLowerCase();var l=c(k);if(l===k){return""
|
|
}var m=k.lastIndexOf(".",k.lastIndexOf(".",k.length-l.length)-1);if(m<=0){return k}return k.slice(m+1)
|
|
}function c(k){if(!k){return""}var l;while(true){l=k.indexOf(".");if(l<0){return k}if(j(b,k)){return k.slice(l+1)
|
|
}if(j(h,k)){return k}if(j(h,"*"+k.slice(l))){return k}k=k.slice(l+1)}}function j(t,r){var q=r.lastIndexOf(".");
|
|
var m,v;if(q<0){m=r;v=r}else{m=r.slice(q+1);v=r.slice(0,q)}var s=t[m];if(!s){return false}if(typeof s==="string"){return s.indexOf(" "+v+" ")>=0
|
|
}var n=v.length;var w=s[n];if(!w){return false}var k=0;var u=Math.floor(w.length/n+0.5);var p,o;while(k<u){p=k+u>>1;
|
|
o=w.substr(n*p,n);if(v<o){u=p}else{if(v>o){k=p+1}else{return true}}}return false}function d(r,p){b={};
|
|
h={};r=r.toLowerCase();var o=0,l;var m=r.length;var s,q,n,k;while(o<m){l=r.indexOf("\n",o);if(l<0){l=m
|
|
}s=r.slice(o,l);o=l+1;if(s.length===0){continue}n=s.indexOf("//");if(n>=0){s=s.slice(0,n)}s=s.trim();
|
|
if(!s){continue}if(g.test(s)){s=p(s)}if(s.charAt(0)==="!"){q=b;s=s.slice(1)}else{q=h}n=s.lastIndexOf(".");
|
|
if(n<0){k=s}else{k=s.slice(n+1);s=s.slice(0,n)}if(!q[k]){q[k]=[]}if(s){q[k].push(s)}}e(b);e(h)}function e(m){var o,q,p,k;
|
|
for(var n in m){if(!m.hasOwnProperty(n)){continue}o=m[n].join(" ");if(!o){m[n]="";continue}if(o.length<a){m[n]=" "+o+" ";
|
|
continue}p=m[n].length;o=[];while(p--){q=m[n][p];k=q.length;if(!o[k]){o[k]=[]}o[k].push(q)}k=o.length;
|
|
while(k--){if(o[k]){o[k]=o[k].sort().join("")}}m[n]=o}return m}f.publicSuffixList={version:"1.0",parse:d,getDomain:i,getPublicSuffix:c}
|
|
})(this);
|