text: !function(e,n){"use strict";class t{constructor(){this.ROOT=window.location.host,this.DEBUG_IMAGES=["https://matthijskamstra.github.io/monkee-z/assets/img/debug/146-500x500.jpg","https://matthijskamstra.github.io/monkee-z/assets/img/debug/500x500.jpg","https://matthijskamstra.github.io/monkee-z/assets/img/debug/1031-500x500.jpg"];let t=this;window.document.addEventListener("DOMContentLoaded",function(e){n.console.groupCollapsed("🔧 Monkee-Wrench - v0.0.4"),n.console.log("Monkee Wrench is a JavaScript tool to replace missing (background)images, and show broken links"),n.console.log('Use by focussing the browser and press "m"'),n.console.log("Or use "+window.location.href+"?monkeewrench"),n.console.log("WIP documentation https://matthijskamstra.github.io/monkee-z/wrench/"),n.console.groupEnd(),t.init()})}init(){let t=this;window.onkeydown=function(e){t.getkey(e)};let e=new URLSearchParams(window.location.search);var n=e.get("monkeewrench");this.buildSnackbar(),null!=n&&(this.buildIcon(),this.validateElementsOnPage(),window.onkeydown=null)}getkey(e){"m"==e.key&&(this.buildIcon(),this.validateElementsOnPage(),window.onkeydown=null)}validateElementsOnPage(){var t=window.document.getElementsByTagName("img");this.snackbarInfo("Checking images");let n=0;for(var e=t.length;n<e;){var s=n++;this.snackbarInfo("Check image "+s);let e=t[s];var i=e.src,a=e.width,s=e.height;this.UrlExists(i)||(this.snackbarInfo("Replacing image: "+i),e.dataset.monkeeWrenchImageReplace="true",e.src=this.DEBUG_IMAGES[0],this.addImageLabel(e),null!=e.getAttribute("width")&&null!=e.getAttribute("height")&&(e.style.width=a+"px",e.style.display="block",e.style.width="500px",e.style.height="250px",e.style.objectFit="cover",e.style.height=Math.round(e.width*(s/a))+"px"))}var o=window.document.getElementsByTagName("*");this.snackbarInfo("Checking background-images");let l=0;for(var r=o.length;l<r;){var d=l++;let e=o[d];var c=f.replace(f.replace(f.replace(f.replace(e.style.backgroundImage,"'",""),'"',""),"url(",""),")","");""!=e.style.backgroundImage&&(this.snackbarInfo("Check background-image "+d),e.dataset.monkeeWrenchCheck="true"),this.UrlExists(c)||(this.snackbarInfo("Replacing background-image: "+c),e.dataset.monkeeWrenchCheck="true",e.dataset.monkeeWrenchBgImageReplace="true",e.style.backgroundImage="url("+this.DEBUG_IMAGES[1]+")",this.addBGImageLabel(e))}var h=window.document.getElementsByTagName("video");this.snackbarInfo("Checking video");let g=0;for(var m=h.length;g<m;){let e=h[g++];e.dataset.monkeeWrenchCheck="true";var p=e.poster;this.UrlExists(p)||(this.snackbarInfo("Replacing video: "+p),e.dataset.monkeeWrenchPosterImageReplace="true",e.poster=this.DEBUG_IMAGES[2])}var u=window.document.getElementsByTagName("a");this.snackbarInfo("Checking links");let k=0;for(var b=u.length;k<b;){let e=u[k++];e.dataset.monkeeWrenchCheck="true";var y=e.href;let t=e.getAttribute("href");e.id;null==e.getAttribute("name")&&(""!=t&&"#"!=t&&null!=t||(this.snackbarInfo("Checking empty links"),e.dataset.monkeWrenchEmptyLink="true",e.innerHTML="🔧 "+e.innerHTML),null!=t&&-1==t.indexOf("javascript")&&-1==t.indexOf("mailto:")&&-1==t.indexOf("tel:")&&(!t.startsWith("/")&&-1==t.indexOf(this.ROOT)||this.UrlExists(y)||(this.snackbarInfo("Checking dead links "+y),e.dataset.monkeeWrenchDeadlink="true",e.innerHTML="❌ "+e.innerHTML)))}this.isSnackbarVisible(!1)}buildSnackbar(){this.snackbar=window.document.createElement("div"),this.snackbar.innerHTML="some text",this.snackbar.id="snackbar",this.snackbar.setAttribute("style","visibility: hidden;min-width: 250px;transform: translate(-50%,0);background-color: #333;color: #fff;text-align: center;border-radius: 2px;padding: 16px; position: fixed;z-index: 1;left: 50%;bottom: 30px;"),window.document.body.appendChild(this.snackbar)}snackbarInfo(e){this.isSnackbarVisible(!0),this.snackbar.innerHTML=e}isSnackbarVisible(e){this.snackbar.style.visibility=(e=null==e?!0:e)?"visible":"hidden"}buildIcon(){let e=window.document.createElement("div");e.innerHTML="🔧",e.className="btn btn-outline-dark",e.title="Monkee Wrench is used",e.setAttribute("style","position: fixed;bottom: 10px;left: 10px;");let t=this;e.onclick=function(){t.validateElementsOnPage()},window.document.body.appendChild(e)}addImageLabel(e){let t=window.document.createElement("div");t.innerHTML="🔧 img",t.style.position="absolute",t.style.bottom="0px",t.style.right="50%",t.style.backgroundColor="yellow",t.style.fontSize="8px",t.style.padding="0px",t.style.paddingLeft="5px",t.style.paddingRight="5px",t.style.textTransform="uppercase",t.style.transform="translate(50%)",t.style.borderRadius="1px",t.style.opacity="0.5",e.parentElement.appendChild(t)}addBGImageLabel(e){let t=window.document.createElement("div");t.innerHTML="🔧 bg-img",t.style.position="absolute",t.style.bottom="0px",t.style.right="50%",t.style.backgroundColor="yellow",t.style.fontSize="8px",t.style.padding="0px",t.style.paddingLeft="5px",t.style.paddingRight="5px",t.style.textTransform="uppercase",t.style.transform="translate(50%)",t.style.borderRadius="1px",t.style.opacity="0.5",e.appendChild(t),e.style.position="relative"}UrlExists(e){let t=new XMLHttpRequest;return t.open("HEAD",e,!1),t.send(),404!=t.status}isUrlValid(e,t){let n=new XMLHttpRequest;n.open("GET",e,!0);let s=this;n.onload=function(){var e;200<=n.status&&n.status<400?(e=n.responseText,console.log("src/MonkeeWrench.hx:334:","json: "+e),t.apply(s,[])):console.log("src/MonkeeWrench.hx:339:","oeps: status: "+n.status+" // json: "+n.responseText)},n.onerror=function(){console.log("src/MonkeeWrench.hx:345:","error")},n.send()}static main(){new t}}class f{static replace(e,t,n){return e.split(t).join(n)}}(e.MonkeeWrench=t).VERSION="0.0.4",t.DEBUG=!1,t.main()}("undefined"!=typeof exports?exports:"undefined"!=typeof window?window:"undefined"!=typeof self?self:this,window);