Spaces:
Running
Running
Download script.js from qq5378673/url-ninja-loader: direct link, hf CLI and curl.
- Browser
- Download file 2.37 kB
-
https://huggingface.co/spaces/qq5378673/url-ninja-loader/resolve/main/script.js
- Command line
-
hf download hf://spaces/qq5378673/url-ninja-loader/script.js
-
curl -L -o script.js https://huggingface.co/spaces/qq5378673/url-ninja-loader/resolve/main/script.js
2.37 kB
| document.addEventListener('DOMContentLoaded', () => { | |
| const params = new URLSearchParams(window.location.search); | |
| const encoded = params.get('c'); | |
| const statusMessage = document.getElementById('status-message'); | |
| const errorBox = document.getElementById('error-box'); | |
| const errorMessage = document.getElementById('error-message'); | |
| const loader = document.querySelector('.loader-wrapper'); | |
| const iframe = document.getElementById('embedFrame'); | |
| if (encoded) { | |
| try { | |
| // Base64 decode | |
| const trueurl = atob(encoded); | |
| // Validate URL | |
| if (trueurl.match(/^(http|https):\/\/[^ "]+$/)) { | |
| statusMessage.textContent = "验证成功,准备传送..."; | |
| setTimeout(() => { | |
| statusMessage.textContent = "正在进入目标站点..."; | |
| setTimeout(() => { | |
| loader.classList.add('hidden'); | |
| iframe.src = trueurl; | |
| iframe.classList.remove('hidden'); | |
| // Attempt to bind mouse wheel for better UX | |
| bindMouseWheel(iframe); | |
| }, 1500); | |
| }, 1500); | |
| } else { | |
| showError("无效的链接格式"); | |
| } | |
| } catch (e) { | |
| showError("解码失败,请检查链接是否正确"); | |
| console.error("Decoding error:", e); | |
| } | |
| } else { | |
| showError("缺少必要参数"); | |
| } | |
| function showError(message) { | |
| statusMessage.classList.add('hidden'); | |
| errorMessage.textContent = message; | |
| errorBox.classList.remove('hidden'); | |
| } | |
| function bindMouseWheel(iframe) { | |
| // Try to prevent scroll jank in iframe | |
| try { | |
| const doc = iframe.contentDocument || iframe.contentWindow.document; | |
| doc.addEventListener('wheel', (e) => { | |
| if (e.ctrlKey) return; // Allow zoom | |
| e.preventDefault(); | |
| window.scrollBy(0, e.deltaY > 0 ? 80 : -80); | |
| }, { passive: false }); | |
| } catch (e) { | |
| // Cross-origin error expected | |
| console.log("Cross-origin iframe detected, mouse wheel binding skipped"); | |
| } | |
| } | |
| }); |