forked from eligrey/hotlink.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hotlink.min.js
2 lines (2 loc) · 1.74 KB
/
hotlink.min.js
1
2
/*! @source http://purl.eligrey.com/github/hotlink.js/blob/master/hotlink.js */
var hotlink=(function(n,s){var d="http://www.w3.org/1999/xhtml",j="http://purl.eligrey.com/hotlink",b=s.documentElement,g=n.navigator.userAgent,f=~g.indexOf("Gecko/"),p=~g.indexOf("MSIE"),y=n.opera,t=function(i){if(i.click){i.click()}else{var B=s.createEvent("Event");B.initEvent("click",true,true);i.dispatchEvent(B)}},z=function(i,B){return i.appendChild(B)},h=function(B,i,C){return(C||s).createElementNS(B,i)},u=function(B,i,D){var C=B.getAttribute(i);if(arguments.length===3){if(D===false){B.removeAttribute(i)}else{B.setAttribute(i,D)}}return C},a=function(H){var J=H.parentNode,C=J.insertBefore(h(j,"img"),H),F=z(C,h(d,"iframe")),I=h(d,"a",F.contentDocument),B=u(H,"data-src",false),D=+u(H,"width",false),L=+u(H,"height",false),K,G,E;if(f||y){D+=16;L+=16}K=H.attributes;G=K.length;while(G--){E=K[G];u(C,E.name,E.value);u(H,E.name,false)}J.removeChild(H);F.style.verticalAlign="bottom";F.style.width=D+"px";F.style.height=L+"px";F.scrolling="no";F.style.border=0;I.rel="noreferrer";I.href=B;if(f||p){F.src=B}t(I)},m=false,c=[],r=false,e=function(i){if(m){if(r){a(i)}else{u(i,"src",u(i,"data-src",false))}}else{c.push(i)}},q=z(b,h(d,"iframe")),l=h(d,"a",q.contentDocument),v="about:blank",k=function(){m=true;r=q.contentDocument.referrer==="";var C=0,B=c.length;for(;C<B;C++){e(c[C])}},x=h(d,"style"),o=s.querySelectorAll("img[data-src]"),w=o.length,A;while(w--){A=o[w];if(A.namespaceURI===d){e(A)}}z(x,s.createTextNode("@namespace'"+j+"';img{display:inline-block;vertical-align:bottom}"));z(b,x);q.style.visibility="hidden";q.style.height=q.style.border=0;l.rel="noreferrer";if(f||p){v="/robots.txt"}l.href=v;q.addEventListener("load",k,false);if(f||p){q.src=l.href}t(l);return e}(self,document));