From c06630d2b1b73bd7045108ee9fc94149e6d1c583 Mon Sep 17 00:00:00 2001 From: MotorTruck1221 Date: Sat, 13 Apr 2024 04:05:55 -0600 Subject: [PATCH] Full Build --- src/public/js/bare.js.min.js | 1 + src/public/js/controls.js.min.js | 1 + src/public/js/games.js.min.js | 1 + src/public/js/index.js.min.js | 1 + src/public/js/keyBinds.js.min.js | 1 + src/public/js/notify.js.min.js | 1 + src/public/js/omnibox.js.min.js | 1 + src/public/js/pages.js.min.js | 1 + src/public/js/register.js.min.js | 1 + src/public/js/search.js.min.js | 1 + src/public/js/settings.js.min.js | 1 + src/public/js/tabs.js.min.js | 1 + src/public/js/transports.js.min.js | 1 + src/public/js/updates.js.min.js | 1 + src/public/js/utils.js.min.js | 1 + 15 files changed, 15 insertions(+) create mode 100644 src/public/js/bare.js.min.js create mode 100644 src/public/js/controls.js.min.js create mode 100644 src/public/js/games.js.min.js create mode 100644 src/public/js/index.js.min.js create mode 100644 src/public/js/keyBinds.js.min.js create mode 100644 src/public/js/notify.js.min.js create mode 100644 src/public/js/omnibox.js.min.js create mode 100644 src/public/js/pages.js.min.js create mode 100644 src/public/js/register.js.min.js create mode 100644 src/public/js/search.js.min.js create mode 100644 src/public/js/settings.js.min.js create mode 100644 src/public/js/tabs.js.min.js create mode 100644 src/public/js/transports.js.min.js create mode 100644 src/public/js/updates.js.min.js create mode 100644 src/public/js/utils.js.min.js diff --git a/src/public/js/bare.js.min.js b/src/public/js/bare.js.min.js new file mode 100644 index 00000000..f0ec7b89 --- /dev/null +++ b/src/public/js/bare.js.min.js @@ -0,0 +1 @@ +function bareInit(){localforage.config({driver:localforage.INDEXEDDB,name:"Ruby",version:1,storeName:"ruby_config",description:"Ruby Config for things in sw"}),localforage.setItem("bare",window.location.origin+"/bare/"),localStorage.setItem("bare","/bare/"),uninstallAllSW2()}function bareChange(e){localforage.config({driver:localforage.INDEXEDDB,name:"Ruby",version:1,storeName:"ruby_config",description:"Ruby Config for things in sw"}),localforage.setItem("bare",e).then((function(e){""===e&&(e=window.location.origin+"/bare/",localforage.setItem("bare",e),localStorage.setItem("bare",e)),e.endsWith("/")||(e+="/",localforage.setItem("bare",e),localStorage.setItem("bare",e)),e.startsWith("http://")||e.startsWith("https://")||"/bare/"===e||"/bare"===e||(e="https://"+e,localforage.setItem("bare",e),localStorage.setItem("bare",e)),"/bare/"!==e&&"/bare"!==e||(e=window.location.origin+e,localforage.setItem("bare",e),localStorage.setItem("bare",e)),setBareTransport(localStorage.getItem("bare")),setItems()})).catch((function(e){console.log(e)}))}function updateSw(){navigator.serviceWorker.getRegistrations().then((function(e){for(let t of e)t.update()}))}function uninstallAllSW(){navigator.serviceWorker.getRegistrations().then((function(e){for(let t of e)t.unregister()})).then((function(){window.location.reload()}))}function uninstallAllSW2(){navigator.serviceWorker.getRegistrations().then((function(e){for(let t of e)t.unregister()})).then((function(){regSW()}))} \ No newline at end of file diff --git a/src/public/js/controls.js.min.js b/src/public/js/controls.js.min.js new file mode 100644 index 00000000..b99822ac --- /dev/null +++ b/src/public/js/controls.js.min.js @@ -0,0 +1 @@ +function settingsPage(e){!0===e&&(document.getElementById("settings-container").classList.remove("dnone"),setPage("settings")),!1===e&&document.getElementById("settings-container").classList.add("dnone")}function gamesPage(e){!0===e&&(document.getElementById("games-container").classList.remove("dnone"),setPage("games"),fetchGames()),!1===e&&document.getElementById("games-container").classList.add("dnone")}function refreshPage(){let e=getCurrentTab(),t=document.querySelector(`[data-iframe-id="${e}"]`);try{t.contentWindow.location.reload()}catch(e){}}function previousPage(){let e=getCurrentTab(),t=document.querySelector(`[data-iframe-id="${e}"]`);try{t.contentWindow.history.back()}catch(e){}}function nextPage(){let e=getCurrentTab(),t=document.querySelector(`[data-iframe-id="${e}"]`);try{t.contentWindow.history.forward()}catch(e){}}function popout(){let e=getCurrentTab(),t=document.querySelector(`[data-iframe-id="${e}"]`);try{let e=t.src;window.open(e,"_blank").focus()}catch(e){}}function updateURLBar(e){let t=getCurrentTab(),n=(document.querySelector(`[data-iframe-id="${t}"]`),localStorage.getItem("proxy"));e=e.replace(window.location.origin,""),"uv"===n&&(e=e.replace(__uv$config.prefix,""),e=__uv$config.decodeUrl(e)),"dynamic"===n&&(e=e.replace(__dynam$ic.prefix,""),e=__dynam$ic.decodeUrl(e)),"rammerhead"===n&&(e=""),"a`owt8bnalk"===e&&(e=""),updateSearch(e)}function fullscreen(){let e=getCurrentTab(),t=document.querySelector(`[data-iframe-id="${e}"]`);try{"full"===localStorage.getItem("fullScreen")&&t.requestFullscreen(),"page"===localStorage.getItem("fullScreen")&&(t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.width="100%",t.style.height="100%",t.style.zIndex="9998",t.style.transition="all 0.5s ease-in-out",document.getElementById("exit-iframe").classList.remove("dnone"),document.addEventListener("keydown",(function(e){"Escape"===e.key&&exitIframe()})))}catch(e){}}function searchBar(e){const t=document.getElementById("uv-form");document.getElementById("uv-address").value=e,t.dispatchEvent(new Event("submit")),resetOmniBox()}function updateSearch(e){document.getElementById("search-input").value=e}function isIframeLoaded(){let e=getCurrentTab(),t=document.querySelector(`[data-iframe-id="${e}"]`);addRightClickToIframe(e),updateTabDetail("Loading...","loading.gif"),t.addEventListener("load",(function(){addRightClickToIframe(e),updateTabDetail(t.contentWindow.document.title,t.contentWindow.document.querySelector('link[rel="icon"]')?proxyOtherStuff(t.contentWindow.document.querySelector('link[rel="icon"]').href):"favicon.ico",e),updateURLBar(t.contentWindow.location.href),addToHistory(t.contentWindow.location.href,t.contentWindow.document.title,t.contentWindow.document.querySelector('link[rel="icon"]')?proxyOtherStuff(t.contentWindow.document.querySelector('link[rel="icon"]').href):"favicon.ico")}))}function exitIframe(){iframe.style.position="",iframe.style.top="",iframe.style.left="",iframe.style.width="",iframe.style.height="",iframe.style.zIndex="",iframe.style.transition="",document.getElementById("exit-iframe").classList.add("dnone")}function historySidebar(){document.getElementById("history").classList.remove("dnone"),setPage("history")}function closeHistorySidebar(){document.getElementById("history").classList.add("dnone")}function addToHistory(e,t,n){document.getElementById("history");let o=document.getElementById("history-content"),i=document.createElement("div");i.setAttribute("id","history-item");let r=document.createElement("a");r.setAttribute("id","history-link"),r.setAttribute("onclick",`handoffToTABS('${e}')`);let a=document.createElement("p");a.innerText=t;let l=document.createElement("img");l.setAttribute("src",n);let d=document.createElement("li");if(d.setAttribute("id","history-delete"),d.setAttribute("onclick",`deleteHistoryItem(${o.childElementCount})`),d.classList.add("fa-solid","fa-trash"),r.appendChild(l),r.appendChild(a),i.appendChild(r),o.appendChild(i),i.appendChild(d),null===localStorage.getItem("history")){let o=[];o.push({url:e,title:t,favicon:n}),localStorage.setItem("history",JSON.stringify({history:o}))}else{let o=JSON.parse(localStorage.getItem("history")).history;o.push({url:e,title:t,favicon:n,id:o.length}),localStorage.setItem("history",JSON.stringify({history:o}))}}function restoreHistory(){document.getElementById("history");let e=document.getElementById("history-content");null!==localStorage.getItem("history")&&JSON.parse(localStorage.getItem("history")).history.forEach((function(t){let n=document.createElement("div");n.setAttribute("id","history-item");let o=document.createElement("a");o.setAttribute("id","history-link"),o.setAttribute("onclick",`handoffToTABS('${t.url}')`);let i=document.createElement("p");i.innerText=t.title;let r=document.createElement("img");r.setAttribute("src",t.favicon);let a=document.createElement("li");a.setAttribute("id","history-delete"),a.setAttribute("onclick",`deleteHistoryItem(${t.id})`),a.classList.add("fa-solid","fa-trash"),o.appendChild(r),o.appendChild(i),n.appendChild(o),n.appendChild(a),e.appendChild(n)}))}function deleteHistoryItem(e){if(null===localStorage.getItem("history"))return;let t=JSON.parse(localStorage.getItem("history")).history;t=t.filter((t=>t.id!=e)),localStorage.setItem("history",JSON.stringify({history:t})),document.getElementById("history-content").innerHTML="",restoreHistory()}function historySidebarKeybinds(){document.addEventListener("keydown",(function(e){e.altKey&&"h"===e.key&&(document.getElementById("history").classList.contains("dnone")?historySidebar():home(closeHistorySidebar()))})),console.log("history keybinds loaded"),restoreHistory(),console.log("history restored")} \ No newline at end of file diff --git a/src/public/js/games.js.min.js b/src/public/js/games.js.min.js new file mode 100644 index 00000000..1a08b29f --- /dev/null +++ b/src/public/js/games.js.min.js @@ -0,0 +1 @@ +async function fetchGames(){console.log("Fetching Games...");let e=await fetch("/games.json"),t=await e.json(),n=document.getElementById("games-container");n.innerHTML='\n
\n \n

Games

\n
\n \n \n ';let o=document.createElement("div");o.setAttribute("id","tile-container"),n.appendChild(o),t.forEach((e=>{let t=e.name.toLowerCase().replace(/\s/g,"-");if("true"===e.cdn&&(o.innerHTML+=`\n
\n ${e.name}\n
\n

${e.name}

\n
\n `),"true"===e.proxy){let t=proxyOtherStuff(e.url);o.innerHTML+=`\n
\n ${e.name}\n
\n

${e.name}

\n
\n `}}))}function showGame(e){let t=document.getElementById("game-iframe");document.getElementById("exit-game").removeAttribute("class","dnone"),t.removeAttribute("class","dnone"),t.src=e,document.body.scrollTop=0,localStorage.setItem("scrollPosition",document.documentElement.scrollTop||document.body.scrollTop),document.documentElement.scrollTop=0,document.body.style.overflow="hidden",t.focus()}function exitGame(){let e=document.getElementById("game-iframe");document.getElementById("exit-game").setAttribute("class","dnone"),e.setAttribute("class","dnone"),e.src="",document.documentElement.scrollTop=localStorage.getItem("scrollPosition"),localStorage.removeItem("scrollPosition"),document.body.style.overflow="auto"} \ No newline at end of file diff --git a/src/public/js/index.js.min.js b/src/public/js/index.js.min.js new file mode 100644 index 00000000..86ab03d1 --- /dev/null +++ b/src/public/js/index.js.min.js @@ -0,0 +1 @@ +"use strict";const form=document.getElementById("uv-form"),address=document.getElementById("uv-address"),error=document.getElementById("uv-error"),errorCode=document.getElementById("uv-error-code");function proxyOtherStuff(e){switch(localStorage.getItem("proxy")){case"uv":default:return __uv$config.prefix+__uv$config.encodeUrl(e);case"dynamic":return __dynam$ic.prefix+__dynam$ic.encodeUrl(e);case"rammerhead":window.location.origin;async function r(){return await RammerheadEncode(e)}r()}}form.addEventListener("submit",(e=>{e.preventDefault();const r=search(address.value,localStorage.getItem("searchEngine"));switch(updateSearch(r),address.value="",localStorage.getItem("proxy")){case"uv":default:handoffToTABS(__uv$config.prefix+__uv$config.encodeUrl(r));break;case"dynamic":handoffToTABS(__dynam$ic.prefix+__dynam$ic.encodeUrl(r));break;case"rammerhead":window.location.origin;async function a(){const e=await RammerheadEncode(r);handoffToTABS(e)}a()}})); \ No newline at end of file diff --git a/src/public/js/keyBinds.js.min.js b/src/public/js/keyBinds.js.min.js new file mode 100644 index 00000000..0ac635f5 --- /dev/null +++ b/src/public/js/keyBinds.js.min.js @@ -0,0 +1 @@ +tabKeybinds(),passwordKeybinds(),historySidebarKeybinds(),devToolsKeybinds(),initRightClick(); \ No newline at end of file diff --git a/src/public/js/notify.js.min.js b/src/public/js/notify.js.min.js new file mode 100644 index 00000000..b2d3af97 --- /dev/null +++ b/src/public/js/notify.js.min.js @@ -0,0 +1 @@ +function notifyBeta(o,t,r){Swal.fire({title:"NOTICE",text:`${o} is currently in beta and may not work as expected.`,icon:"warning",showCancelButton:!0,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",color:"var(--text-color)",background:"var(--bg-color)",confirmButtonText:"Continue"}).then((e=>{e.isConfirmed?Swal.fire({title:"OK!",text:`You are now using ${o}.`,icon:"success",color:"var(--text-color)",background:"var(--bg-color)"}).then((()=>{t()})):Swal.fire({title:"Defaulting...",text:"Defaulting to previously selected option",color:"var(--text-color)",background:"var(--bg-color)"}).then((()=>{try{r()}catch{console.log("No default function found")}}))}))}function notifyWithConfirm(o,t,r,e){Swal.fire({title:"NOTICE",text:`${o} ${t}`,icon:"warning",showCancelButton:!0,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",color:"var(--text-color)",background:"var(--bg-color)",confirmButtonText:"Continue"}).then((t=>{t.isConfirmed?Swal.fire({title:"OK!",text:`You are now using ${o}.`,icon:"success",color:"var(--text-color)",background:"var(--bg-color)"}).then((()=>{r()})):Swal.fire({title:"Defaulting...",text:"Defaulting to previously selected option",color:"var(--text-color)",background:"var(--bg-color)"}).then((()=>{try{e()}catch{console.log("No default function found")}}))}))}function promptCloakingNotify(o,t){Swal.fire({title:"About Blank/Blob Cloaking",text:"Select Between the two options",icon:"warning",showCancelButton:!0,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",color:"var(--text-color)",background:"var(--bg-color)",confirmButtonText:"About:Blank",cancelButtonText:"Blob"}).then((r=>{r.isConfirmed?Swal.fire({title:"About Blank",text:"About Blank Cloaking is now enabled.",icon:"success",color:"var(--text-color)",background:"var(--bg-color)"}).then((()=>{o()})):Swal.fire({title:"Blob",text:"Blob Cloaking is now enabled",color:"var(--text-color)",background:"var(--bg-color)",icon:"success"}).then((()=>{try{t()}catch{console.log("No default function found")}}))}))}function settingsImportExportChoice(o,t){Swal.fire({title:"Import/Export",text:"Select Between the two options",icon:"warning",showCancelButton:!0,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",color:"var(--text-color)",background:"var(--bg-color)",confirmButtonText:"Export",cancelButtonText:"Import"}).then((r=>{r.isConfirmed?Swal.fire({title:"Export",text:"Exporting settings...",icon:"success",color:"var(--text-color)",background:"var(--bg-color)"}).then((()=>{o()})):Swal.fire({title:"Import",text:"Importing settings...",color:"var(--text-color)",background:"var(--bg-color)",icon:"success"}).then((()=>{try{t()}catch{console.log("No default function found")}}))}))}function passwordPrompt(){Swal.fire({title:"Password",input:"password",inputLabel:"Enter the password you want to set",inputPlaceholder:"Enter the password you want to set",showCancelButton:!0,confirmButtonText:"Submit",color:"var(--text-color)",background:"var(--bg-color)",confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",inputValidator:o=>{if(!o)return"You need to write something!"}}).then((o=>{o.isConfirmed?Swal.fire({title:"Password",text:`The password you set is: ${o.value} (Use ALT + L to lock)`,icon:"success",color:"var(--text-color)",background:"var(--bg-color)"}).then((()=>{localStorage.setItem("password",o.value)})):Swal.fire({title:"Password",text:"Cancelled",icon:"error",color:"var(--text-color)",background:"var(--bg-color)"})}))}function passwordIsThere(){Swal.fire({title:"Password",text:"Password is already set! Would you like to change it?",icon:"error",color:"var(--text-color)",background:"var(--bg-color)",showCancelButton:!0,confirmButtonText:"Change",cancelButtonText:"Cancel",confirmButtonColor:"#3085d6",cancelButtonColor:"#d33"}).then((o=>{o.isConfirmed?passwordPrompt():Swal.fire({title:"Password",text:"Password has not been changed",icon:"error",color:"var(--text-color)",background:"var(--bg-color)"})}))}function passwordLock(){if(null===localStorage.getItem("password"))return Swal.fire({title:"Password",text:"No password set!",icon:"error",color:"var(--text-color)",background:"var(--bg-color)",showCancelButton:!0,confirmButtonText:"Set a password",cancelButtonText:"Cancel",confirmButtonColor:"#3085d6",cancelButtonColor:"#d33"}).then((o=>{o.isConfirmed&&passwordPrompt()}));localStorage.setItem("unlocked",!1),Swal.fire({title:"Password",input:"password",inputLabel:"Enter your password",inputPlaceholder:"Enter your password",showCancelButton:!1,confirmButtonText:"Submit",color:"var(--text-color)",background:"var(--bg-color)",confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",customClass:"password-lock",inputValidator:o=>{if(!o)return"You need to write something!"}}).then((o=>{localStorage.setItem("unlocked",!1),o.isConfirmed&&o.value===localStorage.getItem("password")?Swal.fire({title:"Password",text:"Correct Password!",icon:"success",color:"var(--text-color)",background:"var(--bg-color)"}).then((()=>{localStorage.setItem("unlocked",!0)})):Swal.fire({title:"Password",text:"Incorrect Password!",icon:"error",color:"var(--text-color)",background:"var(--bg-color)"}).then((()=>{localStorage.setItem("unlocked",!1),passwordLock()}))}))} \ No newline at end of file diff --git a/src/public/js/omnibox.js.min.js b/src/public/js/omnibox.js.min.js new file mode 100644 index 00000000..55f81342 --- /dev/null +++ b/src/public/js/omnibox.js.min.js @@ -0,0 +1 @@ +async function omniBox(e){let t;t=e.startsWith("http:")||e.startsWith("https:")?[[],[]]:await fetch(`/search/?q=${e}`).then((e=>e.json())).catch((e=>console.log("OmniBox Error ignoring..."))),document.getElementById("omnibox-list").innerHTML="",document.getElementById("uv-form").style.marginTop="120px",document.getElementById("omnibox").removeAttribute("class","dnone");try{await t[1].forEach((e=>{document.getElementById("omnibox-list").innerHTML+=`\n
  • ${e}
  • \n
    \n `}))}catch(e){t=[[],[]]}0==t[1].length&&(document.getElementById("omnibox-list").innerHTML="",document.getElementById("uv-form").style.marginTop="20px",document.getElementById("omnibox").setAttribute("class","dnone"))}function omniBoxSelect(e){document.getElementById("uv-address").value=e,document.getElementById("uv-form").style.marginTop="20px",document.getElementById("omnibox").setAttribute("class","dnone"),document.getElementById("omnibox-list").innerHTML="",document.getElementById("uv-address").focus(),document.getElementById("uv-form").dispatchEvent(new Event("submit"))}function resetOmniBox(){document.getElementById("uv-form").style.marginTop="20px",document.getElementById("omnibox").setAttribute("class","dnone"),document.getElementById("omnibox-list").innerHTML=""} \ No newline at end of file diff --git a/src/public/js/pages.js.min.js b/src/public/js/pages.js.min.js new file mode 100644 index 00000000..48c1de94 --- /dev/null +++ b/src/public/js/pages.js.min.js @@ -0,0 +1 @@ +function setPage(e){localStorage.setItem("currentPage",e)}window.addEventListener("load",(()=>{switch(localStorage.getItem("currentPage")){case"settings":settingsPage(!0);break;case"games":gamesPage(!0);break;case"history":historySidebar()}})); \ No newline at end of file diff --git a/src/public/js/register.js.min.js b/src/public/js/register.js.min.js new file mode 100644 index 00000000..790e7376 --- /dev/null +++ b/src/public/js/register.js.min.js @@ -0,0 +1 @@ +function regSW(){"serviceWorker"in navigator&&(navigator.serviceWorker.ready.then((async e=>{setDefaultTransport()})),navigator.serviceWorker.register("/sw.js",{scope:"/"}))}"serviceWorker"in navigator&&(navigator.serviceWorker.ready.then((async e=>{console.log("Service Worker Ready"),setDefaultTransport()})),navigator.serviceWorker.register("/sw.js",{scope:"/"})); \ No newline at end of file diff --git a/src/public/js/search.js.min.js b/src/public/js/search.js.min.js new file mode 100644 index 00000000..af38e2d8 --- /dev/null +++ b/src/public/js/search.js.min.js @@ -0,0 +1 @@ +"use strict";function search(t,n){try{return new URL(t).toString()}catch(t){}try{const n=new URL(`http://${t}`);if(n.hostname.includes("."))return n.toString()}catch(t){}return n.replace("%s",encodeURIComponent(t))} \ No newline at end of file diff --git a/src/public/js/settings.js.min.js b/src/public/js/settings.js.min.js new file mode 100644 index 00000000..068a7771 --- /dev/null +++ b/src/public/js/settings.js.min.js @@ -0,0 +1 @@ +function bare(e){e.endsWith("/")||(e+="/"),e.startsWith("http://")||e.startsWith("https://")||"/bare/"===e||"/bare"===e||(e="https://"+e),"/bare/"!==e&&"/bare"!==e?fetch(e).then((function(t){if(200!==t.status)return!1;bareChange(e),localStorage.setItem("bare",e)})).catch((function(e){console.log("Fetch Error :-S",e),bareChange("/bare/")})):bareChange(e)}function setTitle(e){localStorage.setItem("title",e),document.title=e}function favicon(e){localStorage.setItem("favicon",e),document.getElementById("favicon").href=e}function theme(e){localStorage.setItem("theme",e),document.documentElement.className=e}function searchSettings(e){localStorage.setItem("searchEngine",e)}function proxyChange(e){const t=function(){localStorage.setItem("proxy",e)},o=function(){setItems()};"dynamic"===e&¬ifyBeta("Dynamic",t,o),"rammerhead"===e?notifyWithConfirm("Rammerhead","is a server based proxy so it MAY run slower, as well as breaking the URL bar of the browser. Are you sure you want to use Rammerhead?",t,o):t()}function aboutBlank(){window.location.replace("https://google.com");const e=window.open();e.document.body.style.margin="0",e.document.body.style.height="100vh";const t=e.document.createElement("iframe");t.style.border="none",t.style.width="100%",t.style.height="100%",t.style.margin="0";const o=window.location.href;t.src=o,e.document.body.appendChild(t)}function jsBLOB(){const e=`\n \n \n \n \n \n \n \n \n \n `;window.location.replace("https://google.com");const t=new Blob([e],{type:"text/html"}),o=URL.createObjectURL(t);window.open(o,"_blank")}function promptCloaking(){promptCloakingNotify(aboutBlank,jsBLOB)}function fullScreenChange(e){localStorage.setItem("fullScreen",e)}function setItems(){let e=document.getElementById("titleInput"),t=document.getElementById("faviconInput"),o=document.getElementById("themeSelect"),a=document.getElementById("searchInput"),n=document.getElementById("proxySelect"),r=document.getElementById("fullscreenSelect"),l=document.getElementById("wispInput"),s=document.getElementById("bareInput"),c=document.getElementById("transportSelect"),i=localStorage.getItem("title"),m=localStorage.getItem("favicon"),g=localStorage.getItem("theme"),u=localStorage.getItem("searchEngine"),p=localStorage.getItem("proxy"),d=localStorage.getItem("fullScreen"),h=localStorage.getItem("wispUrl"),f=localStorage.getItem("bare"),I=localStorage.getItem("transports");e.value=i,t.value=m,o.value=g,a.value=u,n.value=p,r.value=d,l.value=h,s.value=f,c.value=I,bareOrWisp(I),document.documentElement.className=localStorage.getItem("theme"),document.title=i,document.getElementById("favicon").href=m}function reset(){localStorage.clear(),bareChange(window.location.origin+"/bare/"),setTitle("Ruby"),favicon("/favicon.ico"),theme("default"),searchSettings("https://www.google.com/search?q=%s"),proxyChange("uv"),fullScreenChange("page"),setDefaultTransport(),setItems(),uninstallAllSW()}function exportSettings(){let e={title:localStorage.getItem("title"),favicon:localStorage.getItem("favicon"),theme:localStorage.getItem("theme"),search:localStorage.getItem("searchEngine"),proxy:localStorage.getItem("proxy"),fullscreen:localStorage.getItem("fullScreen"),bare:localStorage.getItem("bare"),password:localStorage.getItem("password"),transports:localStorage.getItem("transports"),wispUrl:localStorage.getItem("wispUrl")},t=document.createElement("a"),o=new Blob([JSON.stringify(e)],{type:"text/plain"}),a=URL.createObjectURL(o);t.href=a,t.download="ruby_settings.json",t.click(),URL.revokeObjectURL(a),t.remove()}function importSettings(){let e=document.createElement("input");e.type="file",e.accept=".json",e.onchange=function(){let t=e.files[0],o=new FileReader;o.readAsText(t),o.onload=function(){let e=JSON.parse(o.result);localStorage.setItem("title",e.title),localStorage.setItem("favicon",e.favicon),localStorage.setItem("theme",e.theme),localStorage.setItem("searchEngine",e.search),localStorage.setItem("proxy",e.proxy),localStorage.setItem("fullScreen",e.fullscreen),localStorage.setItem("bare",e.bare),localStorage.setItem("password",e.password),localStorage.setItem("transports",e.transports),changeWisp(e.wispUrl),setItems(),console.log("Imported settings"),window.location.reload()}},e.click()}function importExportSettings(){settingsImportExportChoice(exportSettings,importSettings)}function password(){localStorage.getItem("password")?passwordIsThere():passwordPrompt()}function passwordKeybinds(){document.addEventListener("keydown",(function(e){e.altKey&&"l"===e.key&&passwordLock()})),console.log("Password Keybind initalized")}function changeWisp(e){e.startsWith("http://")?e=e.replace("http://","ws://"):e.startsWith("https://")&&(e=e.replace("https://","wss://")),localStorage.setItem("wispUrl",e),setTransports()}function transportChange(e){function t(){const e=localStorage.getItem("transports");setTransports(e),bareOrWisp(e),setItems()}return"epoxy"===e?notifyWithConfirm("Epoxy","is a less stable. Are you sure you want to use Epoxy?",(function(){localStorage.setItem("transports","epoxy"),setTransports("epoxy"),bareOrWisp("epoxy")}),t):"bare"===e?notifyWithConfirm("Bare","is a less secure option then the others. Are you sure you want to use Bare?",(function(){localStorage.setItem("transports","bare"),setTransports("bare"),bareOrWisp("bare")}),t):(localStorage.setItem("transports",e),setTransports(e),void bareOrWisp(e))}function bareOrWisp(e){const t=document.getElementsByClassName("wisp")[0],o=document.getElementsByClassName("bare")[0];"bare"===e?(t.classList.add("dnone"),o.classList.remove("dnone")):(o.classList.add("dnone"),t.classList.remove("dnone"))}function init(){let e=localStorage.getItem("init");null==e||"false"===e?(localStorage.setItem("init",!0),localStorage.setItem("title","Ruby"),localStorage.setItem("favicon","/favicon.ico"),localStorage.setItem("theme","default"),localStorage.setItem("searchEngine","https://www.google.com/search?q=%s"),localStorage.setItem("proxy","uv"),localStorage.setItem("bare",window.location.origin+"/bare/"),localStorage.setItem("fullScreen","page"),localStorage.setItem("transports","libcurl"),localStorage.setItem("wispUrl",("https:"===location.protocol?"wss":"ws")+"://"+location.host+"/wisp/"),setItems()):("false"===localStorage.getItem("unlocked")&&passwordLock(),setItems())}localforage.config({driver:localforage.INDEXEDDB,name:"Ruby",version:1,storeName:"ruby_config",description:"Ruby Config for things in sw"}),init(); \ No newline at end of file diff --git a/src/public/js/tabs.js.min.js b/src/public/js/tabs.js.min.js new file mode 100644 index 00000000..6514fa24 --- /dev/null +++ b/src/public/js/tabs.js.min.js @@ -0,0 +1 @@ +let el=document.querySelector(".chrome-tabs"),chromeTabs=new ChromeTabs,tabs=[],deletedTabs=[];function showIframe(e){document.querySelector(`[data-iframe-id="${e}"]`).classList.remove("dnone")}function getCurrentTab(){return chromeTabs.activeTabEl.getAttribute("data-tab-id")}function hideIframe(e){let t;if(e)t=e;else try{t=chromeTabs.activeTabEl.getAttribute("data-tab-id")}catch(e){t=null}if(null!=t){let e;try{e=document.querySelector(`[data-iframe-id="${t}"]`)}catch(t){e=null}null!=e&&e.classList.add("dnone")}}function tabAdded(e){let t=tabs.length+deletedTabs.length;console.log(t),e.tabEl.setAttribute("data-tab-id",t),tabs.push({id:t,title:"Search",favicon:"favicon.ico"}),hideIframe()}function tabRemoved(e){let t=e.tabEl.getAttribute("data-tab-id");tabs=tabs.filter((e=>e.id!=t));let a=document.querySelector(`[data-iframe-id="${t}"]`);a&&a.remove(),deletedTabs.push(t)}function handoffToTABS(e){let t=chromeTabs.activeTabEl.getAttribute("data-tab-id"),a=document.querySelector(`[data-iframe-id="${t}"]`);a&&a.remove();let i=document.createElement("iframe");i.setAttribute("src",e),i.setAttribute("id","iframe");let o=chromeTabs.activeTabEl.getAttribute("data-tab-id");i.setAttribute("data-iframe-id",o),document.body.appendChild(i),addRightClickToIframe(o),isIframeLoaded(),document.getElementById("uv-form").style.marginTop="20px",document.getElementById("omnibox").setAttribute("class","dnone"),document.getElementById("omnibox-list").innerHTML=""}function restoreTabs(){chromeTabs.removeTab(chromeTabs.activeTabEl);let e=localStorage.getItem("tabs");e=JSON.parse(e),e.forEach((e=>{chromeTabs.addTab({title:e.title,favicon:e.favicon})}));let t=localStorage.getItem("iframes");t=JSON.parse(t),t.forEach((e=>{let t=document.createElement("iframe");t.setAttribute("src",e.src),t.setAttribute("data-iframe-id",e.id),t.setAttribute("id","iframe"),t.classList.add("dnone"),document.body.appendChild(t),chromeTabs.addTab({title:"Search",favicon:"favicon.ico"}),chromeTabs.removeTab(chromeTabs.activeTabEl)}))}function tabKeybinds(){console.log("tab keybinds initalized"),document.addEventListener("keydown",(function(e){e.altKey&&"t"===e.key&&chromeTabs.addTab({title:"Search",favicon:"favicon.ico"}),e.altKey&&"w"===e.key&&chromeTabs.removeTab(chromeTabs.activeTabEl)}))}function updateTabDetail(e,t,a){let i=a||chromeTabs.activeTabEl.getAttribute("data-tab-id");const o=document.querySelector(`.chrome-tab[data-tab-id="${i}"] .chrome-tab-title`),c=document.querySelector(`.chrome-tab[data-tab-id="${i}"] .chrome-tab-favicon`);""!=e&&null!=e||(e="Search"),""!=t&&null!=t||(t="favicon.ico"),o&&c?(o.innerHTML=e,c.style.backgroundImage=`url(${t})`):console.log("tabTitle is null")}function init(){chromeTabs.removeTab(chromeTabs.activeTabEl),chromeTabs.addTab({title:"Search",favicon:"favicon.ico"})}chromeTabs.init(el),document.getElementById("add-tab").addEventListener("click",(function(e){chromeTabs.addTab({title:"Search",favicon:"favicon.ico"})})),el.addEventListener("tabAdd",(function({detail:e}){tabAdded(e)})),el.addEventListener("tabRemove",(function({detail:e}){tabRemoved(e)})),el.addEventListener("activeTabChange",(function({detail:e}){let t=e.tabEl.getAttribute("data-tab-id"),a=document.querySelector(`[data-iframe-id="${t}"]`);document.querySelectorAll("[data-iframe-id]").forEach((e=>{e.classList.add("dnone"),updateURLBar("")})),a&&(showIframe(t),updateURLBar(a.contentWindow.location.href),updateTabDetail(a.contentWindow.document.title,a.contentWindow.document.querySelector('link[rel="icon"]')?proxyOtherStuff(a.contentWindow.document.querySelector('link[rel="icon"]').href):"favicon.ico",t))})),init(); \ No newline at end of file diff --git a/src/public/js/transports.js.min.js b/src/public/js/transports.js.min.js new file mode 100644 index 00000000..559f8176 --- /dev/null +++ b/src/public/js/transports.js.min.js @@ -0,0 +1 @@ +const wispUrl=localStorage.getItem("wispUrl")||("https:"===location.protocol?"wss":"ws")+"://"+location.host+"/wisp/";function setTransports(t){switch(t){case"libcurl":setLibcurlTransport();break;case"epoxy":setEpoxyTransport();break;case"bare":setBareTransport(localStorage.getItem("bare"));break;default:!function(){switch(localStorage.getItem("transports")){case"libcurl":default:setLibcurlTransport();break;case"epoxy":setEpoxyTransport();break;case"bare":setBareTransport(localStorage.getItem("bare"))}}()}}function setLibcurlTransport(){BareMux.SetTransport("CurlMod.LibcurlClient",{wisp:localStorage.getItem("wispUrl")||wispUrl})}function setDefaultTransport(){localStorage.getItem("transports")?setTransports():(localStorage.setItem("transports","libcurl"),setLibcurlTransport())}function refreshEpoxyTransport(){setTransports()}function setEpoxyTransport(){BareMux.SetTransport("EpxMod.EpoxyClient",{wisp:localStorage.getItem("wispUrl")||wispUrl})}function setBareTransport(t){BareMux.SetTransport("BareMod.BareClient",t)} \ No newline at end of file diff --git a/src/public/js/updates.js.min.js b/src/public/js/updates.js.min.js new file mode 100644 index 00000000..53749dd1 --- /dev/null +++ b/src/public/js/updates.js.min.js @@ -0,0 +1 @@ +function getLatestRelease(){fetch("/version/").then((e=>e.json())).then((e=>{const t=localStorage.getItem("version");t==e.version&&null!=t&&null!=t||(localStorage.setItem("updated",!0),localStorage.setItem("version",e.version))}))}getLatestRelease(); \ No newline at end of file diff --git a/src/public/js/utils.js.min.js b/src/public/js/utils.js.min.js new file mode 100644 index 00000000..b482f683 --- /dev/null +++ b/src/public/js/utils.js.min.js @@ -0,0 +1 @@ +function home(){localStorage.setItem("currentPage","/")} \ No newline at end of file