-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsavr-save.js
1 lines (1 loc) · 1.39 KB
/
savr-save.js
1
javascript:(function(){const hosts=["http://localhost:8080/savr","http://127.0.0.1:8080/savr"],path="/static/savr-remote.js";let currentHostIndex=0;function runWithSimpleProgress(){window.location.href=`${hosts[currentHostIndex]}/save?url=${window.location.href}`}function fetchAndRunScript(){const t=`${hosts[currentHostIndex]}${path}`,n=document.createElement("script");n.type="text/javascript",n.src=t,document.head.append(n),n.onload=()=>{if("undefined"!=typeof savr&&"function"==typeof savr.startSSE){const t=window.location.href;savr.startSSE(hosts[currentHostIndex],t)}else showErrorPopup("Error: startSSE function not found in loaded script")},n.onerror=()=>{currentHostIndex<hosts.length-1?(currentHostIndex++,fetchAndRunScript()):showErrorPopup(`Error: Could not load script from ${t}`)},document.body.appendChild(n)}function showErrorPopup(t){const n=document.createElement("div");n.innerHTML=`\n <div style="padding: 10px; background: rgba(255, 0, 0, 0.8); color: white; border-radius: 5px; text-align: center;">\n ${t}\n </div>`,n.style.cssText="\n position: fixed;\n top: 20px;\n left: 50%;\n transform: translateX(-50%);\n z-index: 9999;\n ",document.body.appendChild(n),setTimeout((()=>{n.style.transition="opacity 1s ease-out",n.style.opacity="0",setTimeout((()=>n.remove()),1e3)}),2e3)}fetchAndRunScript();}());