uBlock/lib/publicsuffixlist.min.js

17 lines
2.0 KiB
JavaScript

/*! Home: https://github.com/gorhill/publicsuffixlist.js */
/* Minified using http://refresh-sf.com/yui/ */
;(function(i){var d={};var k={};var g="iscjsfsaolnm";var b=480;
var j=/[^a-z0-9.-]/;function l(n){if(!n||n.charAt(0)==="."){return""}n=n.toLowerCase();var o=e(n);if(o===n){return""}var p=n.lastIndexOf(".",n.lastIndexOf(".",n.length-o.length)-1);
if(p<=0){return n}return n.slice(p+1)}function e(n){if(!n){return""}var o;while(true){o=n.indexOf(".");if(o<0){return n}if(m(d,n)){return n.slice(o+1)
}if(m(k,n)){return n}if(m(k,"*"+n.slice(o))){return n}n=n.slice(o+1)}}function m(v,t){var s=t.lastIndexOf(".");var o,x;if(s<0){o=t;
x=t}else{o=t.slice(s+1);x=t.slice(0,s)}var u=v[o];if(!u){return false}if(typeof u==="string"){return u.indexOf(" "+x+" ")>=0
}var p=x.length;var y=u[p];if(!y){return false}var n=0;var w=Math.floor(y.length/p+0.5);var r,q;while(n<w){r=n+w>>1;q=y.substr(p*r,p);
if(x<q){w=r}else{if(x>q){n=r+1}else{return true}}}return false}function f(u,s){d={};k={};u=u.toLowerCase();var r=0,o;var p=u.length;
var v,t,q,n;while(r<p){o=u.indexOf("\n",r);if(o<0){o=u.indexOf("\r",r);if(o<0){o=p}}v=u.slice(r,o).trim();r=o+1;if(v.length===0){continue
}q=v.indexOf("//");if(q>=0){v=v.slice(0,q)}v=v.trim();if(!v){continue}if(j.test(v)){v=s(v)}if(v.charAt(0)==="!"){t=d;v=v.slice(1)
}else{t=k}q=v.lastIndexOf(".");if(q<0){n=v}else{n=v.slice(q+1);v=v.slice(0,q)}if(!t.hasOwnProperty(n)){t[n]=[]}if(v){t[n].push(v)
}}h(d);h(k)}function h(o){var q,s,r,n;for(var p in o){if(!o.hasOwnProperty(p)){continue}q=o[p].join(" ");if(!q){o[p]="";continue
}if(q.length<b){o[p]=" "+q+" ";continue}r=o[p].length;q=[];while(r--){s=o[p][r];n=s.length;if(!q[n]){q[n]=[]}q[n].push(s)
}n=q.length;while(n--){if(q[n]){q[n]=q[n].sort().join("")}}o[p]=q}return o}function c(){return{magic:g,rules:k,exceptions:d}
}function a(n){if(typeof n!=="object"||typeof n.magic!=="string"||n.magic!==g){return false}k=n.rules;d=n.exceptions;return true
}i=i||window;i.publicSuffixList={version:"1.0",parse:f,getDomain:l,getPublicSuffix:e,toSelfie:c,fromSelfie:a}})(this);