-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFIP-1.0.min.js
1 lines (1 loc) · 4.03 KB
/
FIP-1.0.min.js
1
function __convertFileSize(e){var t=Math.floor(Math.log(e)/Math.log(1024));return 1*(e/Math.pow(1024,t)).toFixed(2)+" "+["B","kB","MB","GB","TB"][t]}styleEl=document.createElement("style"),style='img[src]:not(.imgNormal){cursor:pointer}.imgModal{z-index:9999;position:fixed;width:100%;height:100%;top:0;left:0;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;font-family:sans-serif;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;font-weight:400;font-size:18px}.imgModal>.img{max-width:1068px;max-height:537px;min-width:450px;min-height:535px}.imgModal>.img>img{width:100%;height:100%}.imgModal .footer{position:absolute;bottom:5px;left:5px;color:#fff}.imgModal .footer .textHead{display:block;font-weight:700}.imgModal .footer .textHead::after{content:":"}.imgModal .footer span a{color:unset;text-decoration:none}.imgModal .footer span a:hover{text-decoration:underline}.imgModal-backdrop{width:100%;height:100%;position:fixed;top:0;left:0;background:rgba(0,0,0,0.6);z-index:9998}.hide{opacity:0;-webkit-transition:300ms all;transition:300ms all}.show{opacity:1;-webkit-transition:300ms all;transition:300ms all}',styleEl.textContent=style,document.head.appendChild(document.createComment(" Code Injected By FullImagePreview ")),document.head.appendChild(styleEl);const imgs=document.querySelectorAll("img[src]");function closeImagePrew(){[...document.getElementsByClassName("imgModal")].map(e=>{e.classList.remove("show"),e.classList.add("hide"),setTimeout(()=>{e.remove()},350)}),[...document.getElementsByClassName("imgModal-backdrop")].map(e=>{e.classList.remove("show"),e.classList.add("hide"),setTimeout(()=>{e.remove()},350)}),document.body.style.overflow=""}[...imgs].map(e=>{e.addEventListener("click",e=>{const t=document.createElement("div");t.classList.add("imgModal"),t.classList.add("hide"),t.innerHTML=`<div class="img">\n <img class="imgNormal" src="${e.target.src}" />\n </div>\n <div class="footer">\n <div class="imageAlt">\n <span class="textHead"> Image Alt </span>\n <span> ${e.target.alt||"underfined"} </span>\n </div>\n <div class="size">\n <span class="textHead"> Size </span>\n <span> ${e.target.width}x${e.target.height} </span>\n </div>\n <div class="imageUrl">\n <span class="textHead"> Image Url </span>\n <span> <a href="${e.target.src}" target="_blank">${e.target.src.length>=120?e.target.src.slice(0,120)+"...":e.target.src}</a> </span>\n </div>\n <div class="imageExt">\n <span class="textHead"> Image Extension </span>\n <span> ${e.target.src.split(/[#?]/)[0].split(".").pop().trim()} </span>\n </div>\n <div class="fileSize">\n <span class="textHead"> File Size </span>\n <span> Calculating.. </span>\n </div>\n </div>`,[...document.body.getElementsByClassName("imgModal")].map(e=>e.remove()),document.body.appendChild(t),t.insertAdjacentHTML("afterEnd",'<div class="imgModal-backdrop"></div>'),document.body.style.overflow="hidden";let a=new XMLHttpRequest;a.onreadystatechange=(()=>{if(4==a.readyState){if(!(a.status>=200&&a.status<=400))throw new Error("XMLHttpRequest Failed\nStatus : "+a.status);if(!document.querySelectorAll(".imgModal .footer .fileSize>span+span")[0])return!1;document.querySelectorAll(".imgModal .footer .fileSize>span+span")[0].innerText=__convertFileSize(a.getResponseHeader("Content-Length"))}}),setTimeout(()=>{t.classList.remove("hide"),t.classList.add("show")},100),a.open("GET",e.target.src,!0),a.send()})}),document.addEventListener("click",e=>{e.target.classList.contains("imgModal")&&closeImagePrew()}),document.addEventListener("keydown",e=>{"Escape"==e.key&&closeImagePrew()});