diff --git a/dist/favicon.min.js b/dist/favicon.min.js new file mode 100644 index 0000000..a014737 --- /dev/null +++ b/dist/favicon.min.js @@ -0,0 +1 @@ +async function favicon(a,b){function c(a){return new Promise(function(b,c){var d,e=new Image;e.onerror=e.onabort=function(){clearTimeout(d),c("error")},e.onload=function(){clearTimeout(d),b("success")},d=setTimeout(function(){e.src="//!!!!/test.jpg",c("timeout")},5000),e.src=a})}const d=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;if(null==a||""==a)throw new Error("No icon provided!");var e=b?b:d.test(a)?"base64":"png";var f="ico"==e?"image/x-icon":"image/gif";var g=document.querySelector("link[rel~='icon']");if(g||(g=document.createElement("link"),g.rel="shortcut icon",g.type=f,document.getElementsByTagName("head")[0].appendChild(g)),"base64"!=e){var h=c(a);h.then(function(b){if("success"==b){if(g.href=a,g.href==a)console.log(`Image: ${a}, Set successfully!`);else throw new Error("Favicon was not set!");}else if("timeout"==b)throw new Error(`Image timedout: favicon was not set!`)},function(){throw new Error(`Invalid image: favicon was not set!`)})}else if(d.test(a))if(g.href=a,g.href==a)console.log(`favicon.js: favicon Set successfully!`);else throw new Error("Favicon was not set!")} \ No newline at end of file