30 lines
No EOL
7.2 KiB
JavaScript
30 lines
No EOL
7.2 KiB
JavaScript
window.addEventListener("load",function(){setTimeout(()=>{if(window.location.hash){let t=window.location.hash.substring(1),e=document.getElementById(t);e&&e.scrollIntoView({behavior:"smooth",block:"start"})}},135)}),("ontouchstart"in window||navigator.maxTouchPoints>0)&&window.addEventListener("touchstart",function e(){document.body.classList.add("no-hover"),window.removeEventListener("touchstart",e,!1)},!1),(()=>{let t=document.baseURI,e=document.querySelectorAll("a[href]:not(.eel)"),n=window.location.hostname;for(let o=0,i=e.length;o<i;o++){let s=e[o];try{let e=new URL(s.getAttribute("href"),t);if(e.hostname!==n){"_blank"!==s.getAttribute("target")&&s.setAttribute("target","_blank");let e=s.getAttribute("rel")||"";/\bnoopener\b/.test(e)||(e+=" noopener"),/\bnoreferrer\b/.test(e)||(e+=" noreferrer"),s.setAttribute("rel",e.trim())}}catch{}}})(),!async function(){await async function(){return new Promise(function(e){const t=new Image;t.onload=function(){e(1===t.width&&1===t.height)},t.onerror=function(){e(!1)},t.src="data:image/webp;base64,UklGRhYAAABXRUJQVlA4TAoAAAAvAAAAAEX/I/of"})}()||document.querySelectorAll('img[src$=".webp"]').forEach(function(e){e.src=e.src.replace(/\.webp$/i,".jpg")})}(),document.addEventListener("DOMContentLoaded",function(){const e=document.createElement("style");e.textContent=`
|
|
.link-arrow-container {
|
|
position: absolute;
|
|
pointer-events: none;
|
|
z-index: 9999;
|
|
width: 20px;
|
|
height: 20px;
|
|
right: 0px;
|
|
opacity: 0;
|
|
transform: translateX(-5px);
|
|
transition: transform 0.1s ease-out, opacity 0.1s ease-out;
|
|
/* Vertical alignment handled by parent flex settings */
|
|
}
|
|
.link-arrow-container.animate {
|
|
opacity: 1;
|
|
transform: translateX(5px);
|
|
}
|
|
.link-arrow-container svg {
|
|
width: 100%;
|
|
height: 100%;
|
|
fill: currentColor;
|
|
display: block;
|
|
}
|
|
a[href]:not(.no-arrow-padding):not(a[target="_blank"]) {
|
|
position: relative;
|
|
padding-right: 24px;
|
|
display: inline-flex;
|
|
align-items: center;
|
|
}
|
|
`,document.head.appendChild(e);const t=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z"/></svg>`;document.querySelectorAll("a[href]").forEach(e=>{const s=e.getAttribute("href");if(e.getAttribute("target")==="_blank"||s.startsWith("#")||s.startsWith("javascript:"))return;const n=document.createElement("div");n.className="link-arrow-container",n.innerHTML=t,e.appendChild(n)}),document.body.addEventListener("click",function(e){const t=e.target.closest("a[href]");if(!t)return;const n=t.getAttribute("href");if(t.getAttribute("target")==="_blank"||n.startsWith("#")||n.startsWith("javascript:"))return;if(e.ctrlKey||e.metaKey||e.shiftKey)return;const s=t.querySelector(".link-arrow-container");if(!s)return;e.preventDefault(),s.classList.add("animate"),setTimeout(()=>{window.location.href=n},100)}),window.addEventListener("pageshow",function(e){e.persisted&&document.querySelectorAll(".link-arrow-container.animate").forEach(e=>{e.classList.remove("animate")})})}),!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.quicklink={})}(this,function(e){function a(e){return new Promise(function(t,n,s){(s=new XMLHttpRequest).open("GET",e,s.withCredentials=!0),s.onload=function(){200===s.status?t():n()},s.send()})}var o,l=(o=document.createElement("link")).relList&&o.relList.supports&&o.relList.supports("prefetch")?function(e){return new Promise(function(t,n,s){(s=document.createElement("link")).rel="prefetch",s.href=e,s.onload=t,s.onerror=n,document.head.appendChild(s)})}:a,d=window.requestIdleCallback||function(e){var t=Date.now();return setTimeout(function(){e({didTimeout:!1,timeRemaining:function(){return Math.max(0,50-(Date.now()-t))}})},1)},t=new Set,n=new Set,s=!1;function r(e){if(e){if(e.saveData)return new Error("Save-Data is enabled");if(/2g/.test(e.effectiveType))return new Error("network conditions are poor")}return!0}function i(e,o){var c=r(navigator.connection);return c instanceof Error?Promise.reject(new Error("Cannot prefetch, "+c.message)):(n.size>0&&!s&&console.warn("[Warning] You are using both prefetching and prerendering on the same document"),Promise.all([].concat(e).map(function(e){if(!t.has(e))return t.add(e),(o?function(e){return window.fetch?fetch(e,{credentials:"include"}):a(e)}:l)(new URL(e,location.href).toString())})))}function c(e){if(c=r(navigator.connection),c instanceof Error)return Promise.reject(new Error("Cannot prerender, "+c.message));if(!HTMLScriptElement.supports("speculationrules"))return i(e),Promise.reject(new Error("This browser does not support the speculation rules API. Falling back to prefetch."));if(document.querySelector('script[type="speculationrules"]'))return Promise.reject(new Error("Speculation Rules is already defined and cannot be altered."));for(var a,c,d,l=0,u=[].concat(e);l<u.length;l+=1){if(a=u[l],window.location.origin!==new URL(a,window.location.href).origin)return Promise.reject(new Error("Only same origin URLs are allowed: "+a));n.add(a)}return t.size>0&&!s&&console.warn("[Warning] You are using both prefetching and prerendering on the same document"),d=function(e){var t=document.createElement("script");t.type="speculationrules",t.text='{"prerender":[{"source": "list","urls": ["'+Array.from(e).join('","')+'"]}]}';try{document.head.appendChild(t)}catch(e){return e}return!0}(n),!0===d?Promise.resolve():Promise.reject(d)}e.listen=function(e){if(e||(e={}),window.IntersectionObserver){var r,l=function(e){e=e||1;var t=[],n=0;function s(){n<e&&t.length>0&&(t.shift()(),n++)}return[function(e){t.push(e)>1||s()},function(){n--,s()}]}(e.throttle||1/0),f=l[0],u=l[1],p=e.limit||1/0,h=e.origins||[location.hostname],g=e.ignores||[],v=e.delay||0,o=[],b=e.timeoutFn||d,a="function"==typeof e.hrefFn&&e.hrefFn,m=e.prerender||!1;return s=e.prerenderAndPrefetch||!1,r=new IntersectionObserver(function(l){l.forEach(function(l){if(l.isIntersecting)o.push((l=l.target).href),function(e,t){t?setTimeout(e,t):e()}(function(){-1!==o.indexOf(l.href)&&(r.unobserve(l),(s||m)&&n.size<1?c(a?a(l):l.href).catch(function(t){if(!e.onError)throw t;e.onError(t)}):t.size<p&&!m&&f(function(){i(a?a(l):l.href,e.priority).then(u).catch(function(t){u(),e.onError&&e.onError(t)})}))},v);else{var d=o.indexOf((l=l.target).href);d>-1&&o.splice(d)}})},{threshold:e.threshold||0}),b(function(){(e.el||document).querySelectorAll("a").forEach(function(e){h.length&&!h.includes(e.hostname)||function e(t,n){return Array.isArray(n)?n.some(function(n){return e(t,n)}):(n.test||n).call(n,t.href,t)}(e,g)||r.observe(e)})},{timeout:e.timeout||2e3}),function(){t.clear(),r.disconnect()}}},e.prefetch=i,e.prerender=c}),quicklink.listen({origins:[],ignores:[e=>e.includes("caileb.com")&&e.includes("#"),e=>e.includes("gallery.caileb.com"),e=>e.includes("jellyfin.caileb.com"),e=>e.includes("archive.caileb.com"),e=>e.includes("music.caileb.com"),/\/api\/?/,/^api\./,e=>/\.(zip|tar|7z|rar|js|apk|xapk|woff2|tff|otf|pdf|mp3|mp4|wav|exe|msi|bat|deb|rpm|bin|dmg|iso|csv|log|sql|xml|key|odp|ods|pps|ppt|xls|doc|jpg|jpeg|jpe|jif|jfif|jfi|png|gif|webp|tif|psd|raw|arw|cr2|nrw|k25|bmp|dib|heif|heic|ind|indd|indt|jp2|j2k|jpf|jpx|jpm|mj2|svg|ai|eps)$/i.test(e),e=>/^(http|file|ftp|mailto|tel):/i.test(e)]}) |