From 8061f621f24ecccb985e175c193134f2eb79f96d Mon Sep 17 00:00:00 2001 From: GreenyDev Date: Mon, 2 Jan 2023 23:26:39 -0500 Subject: [PATCH 1/2] good luck SSD --- static/options/index.html | 14 +++- .../resources/appModules/database-manager.js | 19 +++++ static/resources/appModules/selectBare.js | 74 +++++++++++++++++++ static/resources/nebulamain.js | 10 +++ static/style/options.css | 34 +++++++++ static/sw.js | 3 + static/uv/uv.config.js | 4 +- static/uv/uv.sw.js | 3 +- 8 files changed, 157 insertions(+), 4 deletions(-) create mode 100644 static/resources/appModules/database-manager.js create mode 100644 static/resources/appModules/selectBare.js diff --git a/static/options/index.html b/static/options/index.html index b124e22c..ed4f5920 100644 --- a/static/options/index.html +++ b/static/options/index.html @@ -2,6 +2,7 @@ + Nebula @@ -9,7 +10,10 @@ - + + + + @@ -137,6 +141,13 @@

diff --git a/static/resources/appModules/database-manager.js b/static/resources/appModules/database-manager.js new file mode 100644 index 00000000..a2e035a7 --- /dev/null +++ b/static/resources/appModules/database-manager.js @@ -0,0 +1,19 @@ +const dbPromise = Ultraviolet.openDB('keyval-store', 1, { + upgrade(db) { + db.createObjectStore('keyval'); + }, +}); + +self.storage = { + async get(key) { + return (await dbPromise).get('keyval', key); + }, + + async set(key, val) { + return (await dbPromise).put('keyval', val, key); + }, + + async del(key) { + return (await dbPromise).delete('keyval', key); + }, +} \ No newline at end of file diff --git a/static/resources/appModules/selectBare.js b/static/resources/appModules/selectBare.js new file mode 100644 index 00000000..a494d812 --- /dev/null +++ b/static/resources/appModules/selectBare.js @@ -0,0 +1,74 @@ + +const dbPromise = Ultraviolet.openDB('keyval-store', 1, { + upgrade(db) { + db.createObjectStore('keyval'); + }, +}); + +self.storage = { + async get(key) { + return (await dbPromise).get('keyval', key); + }, + + async set(key, val) { + return (await dbPromise).put('keyval', val, key); + }, + + async del(key) { + return (await dbPromise).delete('keyval', key); + }, +} + +function getBareLocation() { + const location = storage.get("bareLocation"); + return location; +} + +function setBareLocation(location) { + if (/^http(s?):\/\//.test(location) || (location.includes('.') && val.substr(0, 1) !== ' ') || location.includes('/bare/')) { + storage.set("bareLocation", location); + return 'Bare is located at: ' + location; + } else { + console.log('Invalid Location provided, please provide a server in the format of http(s)://server.domain.com/'); + return 'Invalid Location provided'; + } +} + +function bareValidator(bareLocation) { + fetch(bareLocation) + .then((res) => res.json()) + .then((data) => { + if (data.project.name === "bare-server-node") { + return true; + } + + return false; + }) +} + + +window.addEventListener("load", () => { + const _loc = document.getElementById('bareLocationInput') + const indicator = document.getElementById('validIndicator') + if (bareValidator(_loc.value) === true) { + indicator.innerText = 'Connected to server: ' + _loc.value + indicator.style.color = '#42f851' + } else if (bareValidator(_loc.value) === false) { + indicator.innerText = 'Could not connect to server: ' + _loc.value + indicator.style.color = '#f45145bd' + } + + document.getElementById('bareLocationInput').addEventListener('keydown', function (event) { + if (event.key === 'Enter') { + if (bareValidator(_loc.value) === true) { + indicator.innerText = 'Connected to server: ' + _loc.value + indicator.style.color = '#42f851' + setBareLocation(_loc.value) + } else if (bareValidator(_loc.value) === false) { + indicator.innerText = 'Could not connect to server: ' + _loc.value + indicator.style.color = '#f45145bd' + } + } + }); + +}); \ No newline at end of file diff --git a/static/resources/nebulamain.js b/static/resources/nebulamain.js index 79fea68e..1e9363fb 100644 --- a/static/resources/nebulamain.js +++ b/static/resources/nebulamain.js @@ -19,6 +19,12 @@ function closeNav() { window.addEventListener("load", () => { // Register the service workers for Osana and Ultraviolet proxy protocols // This is a better method than registering onsubmit because this allows the ability to use proxied links on the main page. + + if (localStorage.getItem("_BareLocation") == undefined || localStorage.getItem("_BareLocation") == null) { + localStorage.setItem("_BareLocation", "/bare/") + } + + navigator.serviceWorker.register("./sw.js", { scope: "/service/", }) @@ -65,7 +71,10 @@ window.addEventListener("load", () => { return time } // initialize the time function + + if (window.location.pathname == "/"){ displayTime() + } // Link evaluation // This functions' purpose is to check a string of text (the argument) @@ -83,6 +92,7 @@ window.addEventListener("load", () => { const proxy = localStorage.getItem("proxy") || "uv" const inpbox = document.querySelector("form") // Display the "loading" indicators on the main page, looks much better than a static/still screen. + inpbox.addEventListener("submit", (event) => { // Prevents the default event tasks event.preventDefault() diff --git a/static/style/options.css b/static/style/options.css index 6a759f68..a8908957 100644 --- a/static/style/options.css +++ b/static/style/options.css @@ -492,4 +492,38 @@ input:checked+label:after { label:active:after { width: 38px; +} + +.bareLocationInput { + border-style: solid !important; + border: var(--input-border-size) solid #5e18eb; + border-width: 0px; + border-radius: 6px; + background-color: #191724; + color: var(--input-text-color); + width: auto; + height: auto; + box-shadow: none !important; + outline: none; + text-align: center; + width: 220px; + font-size: 16px; + font-family: 'Roboto'; + height: 29px; + transition: 0.06s; +} +.bareLocationInput:hover { + border: var(--input-border-size) solid #5e18eb; + border-width: 1px; + border-radius: 6px; + +} + +.bareValidSignal{ + margin-top: -13px; + color: #f45145bd; + font-family: 'Ubuntu', sans-serif; + font-weight: lighter; + font-size: 13px; + text-align: center; } \ No newline at end of file diff --git a/static/sw.js b/static/sw.js index 02f45510..db391859 100644 --- a/static/sw.js +++ b/static/sw.js @@ -1,3 +1,6 @@ +importScripts('./uv/uv.bundle.js'); +importScripts('./resources/appModules/database-manager.js'); +importScripts('./uv/uv.config.js'); importScripts('./uv/uv.sw.js'); importScripts('./osana/osana.worker.js'); diff --git a/static/uv/uv.config.js b/static/uv/uv.config.js index efaadabb..aa1c6bf1 100644 --- a/static/uv/uv.config.js +++ b/static/uv/uv.config.js @@ -1,6 +1,8 @@ + + self.__uv$config = { prefix: '/service/go/', - bare: '/bare/', + bare: self.storage.get("bareLocation"), encodeUrl: Ultraviolet.codec.xor.encode, decodeUrl: Ultraviolet.codec.xor.decode, handler: '/uv/uv.handler.js', diff --git a/static/uv/uv.sw.js b/static/uv/uv.sw.js index 37b1d552..53c74867 100644 --- a/static/uv/uv.sw.js +++ b/static/uv/uv.sw.js @@ -1,5 +1,4 @@ -importScripts('/uv/uv.bundle.js'); -importScripts('/uv/uv.config.js'); + class UVServiceWorker extends EventEmitter { constructor(config = __uv$config) { From dd3470259ca7173999875add55c51e61ee472960 Mon Sep 17 00:00:00 2001 From: GreenyDev Date: Tue, 3 Jan 2023 16:31:37 -0500 Subject: [PATCH 2/2] Finalize BareSwitcher, clean up the edges n whatnot --- static/arc-sw.js | 1 - static/index.html | 3 +- static/options/index.html | 9 +- static/resources/appModules/BareSwitcher.js | 103 +++ .../resources/appModules/database-manager.js | 37 +- static/resources/appModules/selectBare.js | 74 -- static/resources/nebulamain.js | 860 +++++++++--------- static/resources/options.js | 161 ++++ static/style/options.css | 51 +- static/sw.js | 3 - static/uv/uv.config.js | 7 +- static/uv/uv.sw.js | 22 +- 12 files changed, 749 insertions(+), 582 deletions(-) delete mode 100644 static/arc-sw.js create mode 100644 static/resources/appModules/BareSwitcher.js delete mode 100644 static/resources/appModules/selectBare.js create mode 100644 static/resources/options.js diff --git a/static/arc-sw.js b/static/arc-sw.js deleted file mode 100644 index 49d20af1..00000000 --- a/static/arc-sw.js +++ /dev/null @@ -1 +0,0 @@ -!function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=93)}({3:function(t,e,n){"use strict";n.d(e,"a",(function(){return r})),n.d(e,"c",(function(){return o})),n.d(e,"g",(function(){return i})),n.d(e,"j",(function(){return a})),n.d(e,"i",(function(){return d})),n.d(e,"b",(function(){return f})),n.d(e,"k",(function(){return u})),n.d(e,"d",(function(){return p})),n.d(e,"e",(function(){return l})),n.d(e,"f",(function(){return m})),n.d(e,"h",(function(){return v}));var r={images:["bmp","jpeg","jpg","ttf","pict","svg","webp","eps","svgz","gif","png","ico","tif","tiff","bpg","avif","jxl"],video:["mp4","3gp","webm","mkv","flv","f4v","f4p","f4bogv","drc","avi","mov","qt","wmv","amv","mpg","mp2","mpeg","mpe","m2v","m4v","3g2","gifv","mpv","av1","ts","tsv","tsa","m2t","m3u8"],audio:["mid","midi","aac","aiff","flac","m4a","m4p","mp3","ogg","oga","mogg","opus","ra","rm","wav","webm","f4a","pat"],interchange:["json","yaml","xml","csv","toml","ini","bson","asn1","ubj"],archives:["jar","iso","tar","tgz","tbz2","tlz","gz","bz2","xz","lz","z","7z","apk","dmg","rar","lzma","txz","zip","zipx"],documents:["pdf","ps","doc","docx","ppt","pptx","xls","otf","xlsx"],other:["srt","swf"]},o=["js","cjs","mjs","css"],c="arc:",i={COMLINK_INIT:"".concat(c,"comlink:init"),NODE_ID:"".concat(c,":nodeId"),CLIENT_TEARDOWN:"".concat(c,"client:teardown"),CLIENT_TAB_ID:"".concat(c,"client:tabId"),CDN_CONFIG:"".concat(c,"cdn:config"),P2P_CLIENT_READY:"".concat(c,"cdn:ready"),STORED_FIDS:"".concat(c,"cdn:storedFids"),SW_HEALTH_CHECK:"".concat(c,"cdn:healthCheck"),WIDGET_CONFIG:"".concat(c,"widget:config"),WIDGET_INIT:"".concat(c,"widget:init"),WIDGET_UI_LOAD:"".concat(c,"widget:load"),BROKER_LOAD:"".concat(c,"broker:load"),RENDER_FILE:"".concat(c,"inlay:renderFile"),FILE_RENDERED:"".concat(c,"inlay:fileRendered")},a="serviceWorker",d="/".concat("shared-worker",".js"),f="/".concat("dedicated-worker",".js"),u="/".concat("arc-sw-core",".js"),s="".concat("arc-sw",".js"),p=("/".concat(s),"/".concat("arc-sw"),"arc-db"),l="key-val-store",m=2**17,v="".concat("https://warden.arc.io","/mailbox/propertySession");"".concat("https://warden.arc.io","/mailbox/transfers")},93:function(t,e,n){"use strict";n.r(e);var r=n(3);if("undefined"!=typeof ServiceWorkerGlobalScope){var o="https://arc.io"+r.k;importScripts(o)}else if("undefined"!=typeof SharedWorkerGlobalScope){var c="https://arc.io"+r.i;importScripts(c)}else if("undefined"!=typeof DedicatedWorkerGlobalScope){var i="https://arc.io"+r.b;importScripts(i)}}}); \ No newline at end of file diff --git a/static/index.html b/static/index.html index 6b994212..c899396a 100644 --- a/static/index.html +++ b/static/index.html @@ -1,7 +1,8 @@ - + + Nebula diff --git a/static/options/index.html b/static/options/index.html index ed4f5920..5f4d844e 100644 --- a/static/options/index.html +++ b/static/options/index.html @@ -12,8 +12,8 @@ - - + + @@ -187,7 +187,10 @@

db.get('keyval', 'bareLocation')) + .then(value => value || '') +} + +self.storage = { + async get (key) { + return (await dbPromise).get('keyval', key) + }, + + async set (key, val) { + return (await dbPromise).put('keyval', val, key) + }, + + async del (key) { + return (await dbPromise).delete('keyval', key) + } +} + +function setBareLocation (location) { + if ( + /^http(s?):\/\//.test(location) || + (location.includes('.') && val.substr(0, 1) !== ' ') || + location.includes('/bare/') + ) { + storage.set('bareLocation', location) + return 'Bare is located at: ' + location + } else { + console.log( + 'Invalid Location provided, please provide a server in the format of http(s)://server.domain.com/' + ) + return 'Invalid Location provided' + } +} + +function bareValidator (bareLocation) { + try { + // open a request to the bare location + var xmlHttp = new XMLHttpRequest() + xmlHttp.open('GET', bareLocation, false) // false for synchronous request + xmlHttp.send(null) + const _response = xmlHttp.responseText + // turn the response text into json + + const response = JSON.parse(_response) + + if (response.project.name === 'bare-server-node') { + console.log('Bare located at: ' + bareLocation + '') + return true + } else { + console.error('Bare not found at: ' + bareLocation) + return false + } + } catch (error) { + console.error( + 'An error occured while attempting to identify the bare server at: ' + + bareLocation + ) + return false + } +} + +window.addEventListener('load', () => { + console.log('Loaded ') + const _loc = document.getElementById('bareLocationInput') + const indicator = document.getElementById('validIndicator') + + // wait 3 seconds + setTimeout(() => { + if (bareValidator(_loc.value) === true) { + indicator.innerText = 'Connected to server: ' + _loc.value + indicator.style.color = '#42f851' + } else if (bareValidator(_loc.value) === false) { + indicator.innerText = 'Could not connect to server: ' + _loc.value + indicator.style.color = '#f45145bd' + } + }, 1000) + + document + .getElementById('bareLocationInput') + .addEventListener('keydown', function (event) { + if (event.key === 'Enter') { + if (bareValidator(_loc.value) === true) { + indicator.innerText = 'Connected to server: ' + _loc.value + indicator.style.color = '#42f851' + setBareLocation(_loc.value) + } else if (bareValidator(_loc.value) === false) { + _loc.value = '' + indicator.innerText = 'Could not connect to server: ' + _loc.value + indicator.style.color = '#f45145bd' + } + } + }) +}) diff --git a/static/resources/appModules/database-manager.js b/static/resources/appModules/database-manager.js index a2e035a7..847a85be 100644 --- a/static/resources/appModules/database-manager.js +++ b/static/resources/appModules/database-manager.js @@ -1,19 +1,24 @@ +// NOTE - This file is not used in the current version of the app. +// this is just a snippet of code that I am keeping for future reference. +// NOTE: THIS FILE MUST BE ACCOMPANIED BY THE ULTRAVIOLET BUNDLE BECAUSE IT CONTAINS THE INDEXEDDB LIBRARY + + const dbPromise = Ultraviolet.openDB('keyval-store', 1, { - upgrade(db) { - db.createObjectStore('keyval'); - }, -}); + upgrade (db) { + db.createObjectStore('keyval') + } +}) self.storage = { - async get(key) { - return (await dbPromise).get('keyval', key); - }, - - async set(key, val) { - return (await dbPromise).put('keyval', val, key); - }, - - async del(key) { - return (await dbPromise).delete('keyval', key); - }, -} \ No newline at end of file + async get (key) { + return (await dbPromise).get('keyval', key) + }, + + async set (key, val) { + return (await dbPromise).put('keyval', val, key) + }, + + async del (key) { + return (await dbPromise).delete('keyval', key) + } +} diff --git a/static/resources/appModules/selectBare.js b/static/resources/appModules/selectBare.js deleted file mode 100644 index a494d812..00000000 --- a/static/resources/appModules/selectBare.js +++ /dev/null @@ -1,74 +0,0 @@ - -const dbPromise = Ultraviolet.openDB('keyval-store', 1, { - upgrade(db) { - db.createObjectStore('keyval'); - }, -}); - -self.storage = { - async get(key) { - return (await dbPromise).get('keyval', key); - }, - - async set(key, val) { - return (await dbPromise).put('keyval', val, key); - }, - - async del(key) { - return (await dbPromise).delete('keyval', key); - }, -} - -function getBareLocation() { - const location = storage.get("bareLocation"); - return location; -} - -function setBareLocation(location) { - if (/^http(s?):\/\//.test(location) || (location.includes('.') && val.substr(0, 1) !== ' ') || location.includes('/bare/')) { - storage.set("bareLocation", location); - return 'Bare is located at: ' + location; - } else { - console.log('Invalid Location provided, please provide a server in the format of http(s)://server.domain.com/'); - return 'Invalid Location provided'; - } -} - -function bareValidator(bareLocation) { - fetch(bareLocation) - .then((res) => res.json()) - .then((data) => { - if (data.project.name === "bare-server-node") { - return true; - } - - return false; - }) -} - - -window.addEventListener("load", () => { - const _loc = document.getElementById('bareLocationInput') - const indicator = document.getElementById('validIndicator') - if (bareValidator(_loc.value) === true) { - indicator.innerText = 'Connected to server: ' + _loc.value - indicator.style.color = '#42f851' - } else if (bareValidator(_loc.value) === false) { - indicator.innerText = 'Could not connect to server: ' + _loc.value - indicator.style.color = '#f45145bd' - } - - document.getElementById('bareLocationInput').addEventListener('keydown', function (event) { - if (event.key === 'Enter') { - if (bareValidator(_loc.value) === true) { - indicator.innerText = 'Connected to server: ' + _loc.value - indicator.style.color = '#42f851' - setBareLocation(_loc.value) - } else if (bareValidator(_loc.value) === false) { - indicator.innerText = 'Could not connect to server: ' + _loc.value - indicator.style.color = '#f45145bd' - } - } - }); - -}); \ No newline at end of file diff --git a/static/resources/nebulamain.js b/static/resources/nebulamain.js index 1e9363fb..a68f9a8a 100644 --- a/static/resources/nebulamain.js +++ b/static/resources/nebulamain.js @@ -9,148 +9,181 @@ // Navigation controls for smaller devices // Executed in the inline HTML -function openNav() { - document.getElementById("sidenav").style.width = "260px" +function openNav () { + document.getElementById('sidenav').style.width = '260px' } -function closeNav() { - document.getElementById("sidenav").style.width = "0px" +function closeNav () { + document.getElementById('sidenav').style.width = '0px' } -window.addEventListener("load", () => { +window.addEventListener('load', () => { // Register the service workers for Osana and Ultraviolet proxy protocols // This is a better method than registering onsubmit because this allows the ability to use proxied links on the main page. - if (localStorage.getItem("_BareLocation") == undefined || localStorage.getItem("_BareLocation") == null) { - localStorage.setItem("_BareLocation", "/bare/") + const dbPromise = Ultraviolet.openDB('keyval-store', 1, { + upgrade (db) { + db.createObjectStore('keyval') + } + }) + self.storage = { + async get (key) { + return (await dbPromise).get('keyval', key) + }, + + async set (key, val) { + console.log('please wait') + return (await dbPromise).put('keyval', val, key) + }, + + async del (key) { + return (await dbPromise).delete('keyval', key) + } + } + + function getBareLocation () { + return dbPromise + .then(db => db.get('keyval', 'bareLocation')) + .then(value => value || '') } - - navigator.serviceWorker.register("./sw.js", { - scope: "/service/", + getBareLocation().then(bareLocation => { + + console.log('Bare Location: ' + bareLocation) + if (bareLocation === '') { + console.log('No bare location found, automatically setting to default') + storage.set('bareLocation', '/bare/') + + } + + // if bare location is not only whitespace + // if (bareLocation.trim() !== '') { + + }) + + navigator.serviceWorker.register('./sw.js', { + scope: '/service/' }) // Get's the current day using the Date function built in. // A dependency for displaying time - displayTime(void) - function getDayName(dateStr, locale) { + function getDayName (dateStr, locale) { var date = new Date(dateStr) - return date.toLocaleDateString(locale, { weekday: "long" }) + return date.toLocaleDateString(locale, { weekday: 'long' }) } // The main function to show the time on the main page // needs to be initialized by a call (only one) // Dependent on getDayName function - function displayTime() { + function displayTime () { var date = new Date() var h = date.getHours() // 0 - 23 var m = date.getMinutes() // 0 - 59 var s = date.getSeconds() // 0 - 59 - var session = "AM" - h = h == 12 ? 24 : h; + var session = 'AM' + h = h == 12 ? 24 : h if (h == 0) { h = 12 } else if (h >= 12) { h = h - 12 - session = "PM" + session = 'PM' } - h = h < 10 ? "0" + h : h - m = m < 10 ? "0" + m : m - s = s < 10 ? "0" + s : s + h = h < 10 ? '0' + h : h + m = m < 10 ? '0' + m : m + s = s < 10 ? '0' + s : s // Repeat itself every second setTimeout(displayTime, 1000) // Get today's date var today = new Date() - var dd = String(today.getDate()).padStart(2, "0") - var mm = String(today.getMonth() + 1).padStart(2, "0") //January is 0! + var dd = String(today.getDate()).padStart(2, '0') + var mm = String(today.getMonth() + 1).padStart(2, '0') //January is 0! var yyyy = today.getFullYear() - today = mm + "/" + dd + "/" + yyyy + today = mm + '/' + dd + '/' + yyyy var time = h + ":" + m - document.getElementById("digitalClock").innerHTML = - getDayName(today, "us-US") + ", " + time + " " + session + "." + document.getElementById('digitalClock').innerHTML = + getDayName(today, 'us-US') + ', ' + time + ' ' + session + '.' return time } // initialize the time function - - if (window.location.pathname == "/"){ + displayTime() - } // Link evaluation // This functions' purpose is to check a string of text (the argument) // it recognizes whether a string is a URL or not, and it returns a true or false value - function isUrl(val = "") { + function isUrl (val = '') { if ( /^http(s?):\/\//.test(val) || - (val.includes(".") && val.substr(0, 1) !== " ") + (val.includes('.') && val.substr(0, 1) !== ' ') ) return true return false } const useNoGG = false - const proxy = localStorage.getItem("proxy") || "uv" - const inpbox = document.querySelector("form") + const proxy = localStorage.getItem('proxy') || 'uv' + const inpbox = document.querySelector('form') // Display the "loading" indicators on the main page, looks much better than a static/still screen. - - inpbox.addEventListener("submit", (event) => { + + inpbox.addEventListener('submit', event => { // Prevents the default event tasks event.preventDefault() - console.log("Connecting to service -> loading") - const loader = document.getElementById("lpoader") - const texts = document.getElementById("connecterText") + console.log('Connecting to service -> loading') + const loader = document.getElementById('lpoader') + const texts = document.getElementById('connecterText') // Adjust size as neccesary const loadConstructer = loader.style const textConstructer = texts.style - loadConstructer.display = "flex" - loadConstructer.justifyContent = "center" + loadConstructer.display = 'flex' + loadConstructer.justifyContent = 'center' // Changing the text over multiple periods of time creates character, and aliveness (is that even a word?) setTimeout(() => { - document.getElementById("connecterText").style.fontSize = "12px" - document.getElementById("connecterText").innerHTML = - "Due to high server load, this may take a while." + document.getElementById('connecterText').style.fontSize = '12px' + document.getElementById('connecterText').innerHTML = + 'Due to high server load, this may take a while.' }, 3200) setTimeout(() => { - document.getElementById("connecterText").style.fontSize = "14px" - document.getElementById("connecterText").innerHTML = + document.getElementById('connecterText').style.fontSize = '14px' + document.getElementById('connecterText').innerHTML = "Hmmm.. Something isn't right.." }, 17000) }) // Form submission - const form = document.querySelector("form") - form.addEventListener("submit", (event) => { + const form = document.querySelector('form') + form.addEventListener('submit', event => { event.preventDefault() // Check if the service worker (commonly called SW) is registered - if (typeof navigator.serviceWorker === "undefined") + if (typeof navigator.serviceWorker === 'undefined') alert( - "An error occured registering your service worker. Please contact support - discord.gg/unblocker" + 'An error occured registering your service worker. Please contact support - discord.gg/unblocker' ) // - if (proxy === "uv" || proxy === "osana") { + if (proxy === 'uv' || proxy === 'osana') { // Re-register the service worker incase it failed to onload navigator.serviceWorker - .register("./sw.js", { - scope: "/service/", + .register('./sw.js', { + scope: '/service/' }) .then(() => { const value = event.target.firstElementChild.value let url = value.trim() - if (!isUrl(url)) url = "https://www.google.com/search?q=" + url - if (!(url.startsWith("https://") || url.startsWith("http://"))) - url = "http://" + url + if (!isUrl(url)) url = 'https://www.google.com/search?q=' + url + if (!(url.startsWith('https://') || url.startsWith('http://'))) + url = 'http://' + url // encode the URL for UltraViolet let redirectTo = - proxy === "uv" + proxy === 'uv' ? __uv$config.prefix + __uv$config.encodeUrl(url) : __osana$config.prefix + __osana$config.codec.encode(url) - const option = localStorage.getItem("nogg") - if (option === "on") { + const option = localStorage.getItem('nogg') + if (option === 'on') { stealthEngine(redirectTo) } else { setTimeout(() => { // If StealthMode is off, this is the enabled option. - const _popout = window.open("/blob", "_self") + const _popout = window.open('/blob', '_self') const blob = _popout.document // Write all of the neccesary page elements, and the Options including the cloak (if enabled) // The blob writing is just the background elements, like the "Nebula is loading your content, please wait" screen. It does not carry proxied content, or even the iframe. @@ -193,25 +226,25 @@ document.addEventListener("visibilitychange", handleTabLeave) `) // inside of the blob, create and append the Iframe element which WILL carry the proxied content. - const iframe = blob.createElement("iframe") + const iframe = blob.createElement('iframe') const style = iframe.style - const img = blob.createElement("link") + const img = blob.createElement('link') const link = location.href // We attach ARC because it supports us, keeping our arc link there would be greatly appreciated :) - const arcSrc = blob.createElement("script") + const arcSrc = blob.createElement('script') arcSrc.setAttribute( - "src", - "https://arc.io/widget.min.js#BgaWcYfi" + 'src', + 'https://arc.io/widget.min.js#BgaWcYfi' ) // Arc requires the Async attribute // Async means not running parallel to other tasks, so it loads seperately to everything else (in a sense) // Aysnchronous and Synchronous are somewhat difficult topics, so we recommend you - arcSrc.setAttribute("async", "") + arcSrc.setAttribute('async', '') blob.head.appendChild(arcSrc) - img.rel = "icon" + img.rel = 'icon' img.href = - "https://static.nebulacdn.xyz/content/images/nebula_logo_619x619.png" - blob.title = "Nebula" + 'https://static.nebulacdn.xyz/content/images/nebula_logo_619x619.png' + blob.title = 'Nebula' // slice the link like some nice fruit :) // Removing the '/' from 'whateverthislinkis.gay/' // ^ @@ -220,10 +253,10 @@ document.addEventListener("visibilitychange", handleTabLeave) iframe.src = currentLink + redirectTo // Style the Iframe to fill the entire screen and remove the bessels. - style.position = "fixed" + style.position = 'fixed' style.top = style.bottom = style.left = style.right = 0 - style.border = style.outline = "none" - style.width = style.height = "100%" + style.border = style.outline = 'none' + style.width = style.height = '100%' // finally, append the iframe to the blob's (window) body blob.body.appendChild(iframe) }, 1000) @@ -233,7 +266,7 @@ document.addEventListener("visibilitychange", handleTabLeave) }) // Stealth engine, a dependency for everything above. - function stealthEngine(encodedURL) { + function stealthEngine (encodedURL) { // Remember that the EncodedURL argument must be pre-encoded, or encoded before the function is called. // This function does not encode the argument at all! @@ -248,37 +281,37 @@ document.addEventListener("visibilitychange", handleTabLeave) setTimeout(() => { // Basically, a checklist to make sure that an error won't occur. // In this if statement, we're checking if an iframe is already being opened, if popups are disabled, and if the user agent IS NOT firefox (firefox sucks, sorry Moz) - if (!inFrame && !navigator.userAgent.includes("Firefox")) { - const popup = open("about:blank", "_blank") + if (!inFrame && !navigator.userAgent.includes('Firefox')) { + const popup = open('about:blank', '_blank') if (!popup || popup.closed) { alert( - "StealthEngine was unable to open a popup. (do you have popups disabled?)" + 'StealthEngine was unable to open a popup. (do you have popups disabled?)' ) } else { const doc = popup.document - const iframe = doc.createElement("iframe") + const iframe = doc.createElement('iframe') const style = iframe.style // Favicon attachment - const img = doc.createElement("link") - const arcSrc = doc.createElement("script") + const img = doc.createElement('link') + const arcSrc = doc.createElement('script') // We attach ARC because it supports us, keeping our arc link there would be greatly appreciated :) - arcSrc.setAttribute("src", "https://arc.io/widget.min.js#BgaWcYfi") - arcSrc.setAttribute("async", "") + arcSrc.setAttribute('src', 'https://arc.io/widget.min.js#BgaWcYfi') + arcSrc.setAttribute('async', '') doc.head.appendChild(arcSrc) const link = location.href - img.rel = "icon" + img.rel = 'icon' img.href = - "https://ssl.gstatic.com/images/branding/product/1x/drive_2020q4_32dp.png" + 'https://ssl.gstatic.com/images/branding/product/1x/drive_2020q4_32dp.png' doc.title = getRandomName() var currentLink = link.slice(0, link.length - 1) iframe.src = currentLink + encodedURL - style.position = "fixed" + style.position = 'fixed' style.top = style.bottom = style.left = style.right = 0 - style.border = style.outline = "none" - style.width = style.height = "100%" + style.border = style.outline = 'none' + style.width = style.height = '100%' doc.body.appendChild(iframe) } @@ -288,202 +321,111 @@ document.addEventListener("visibilitychange", handleTabLeave) }) // Set the option -var option = localStorage.getItem("nogg") - -function toggleNoGG() { - if (option === "on") { - option = "off" - localStorage.setItem("nogg", "off") - } else { - option = "on" - localStorage.setItem("nogg", "on") - } -} -var option2 = localStorage.getItem("ADVcloak") -function toggleClickoff() { - if (option2 === "on") { - option2 = "off" - localStorage.setItem("ADVcloak", "off") - } else { - option2 = "on" - localStorage.setItem("ADVcloak", "on") - } -} - -const storedSetTheme = localStorage.getItem("theme") - -function switchProxy() { - var selecter = document.getElementById("proxySwitcher") - var selectedOption = selecter.value - - localStorage.setItem("proxy", selectedOption) - var storedChoice = localStorage.getItem("proxy") - console.log(selectedOption) -} +var option = localStorage.getItem('nogg') +const storedSetTheme = localStorage.getItem('theme') if (storedSetTheme == null) { - localStorage.setItem("theme", "dark") -} - -function switchTheme() { - var selecter = document.getElementById("themeSwitcher") - var selectedOption = selecter.value - if (selectedOption == "dark") { - changeCSS("--background-primary", "#191724", true) - changeCSS("--navbar-color", "#26233a", true) - changeCSS("--navbar-height", "60px", true) - changeCSS("--navbar-text-color", "#7967dd", true) - changeCSS("--input-text-color", "#e0def4", true) - changeCSS("--input-placeholder-color", "#6e6a86", true) - changeCSS("--input-background-color", "#1f1d2e", true) - changeCSS("--input-placeholder-color", "white", true) - changeCSS("--input-border-color", "#eb6f92", true) - changeCSS("--input-border-size", "1.3px", true) - changeCSS("--navbar-link-color", "#e0def4", true) - changeCSS("--navbar-font", '"Roboto"', true) - changeCSS("--navbar-logo-filter", "invert(0%)", true) - changeCSS("--text-color-primary", "#e0def4", true) - localStorage.setItem("theme", "dark") - } - if (selectedOption == "light") { - changeCSS("--background-primary", "#d8d8d8", true) - changeCSS("--navbar-color", "#a2a2a2", true) - changeCSS("--navbar-height", "4em", true) - changeCSS("--navbar-text-color", "#000000", true) - changeCSS("--input-text-color", "#e0def4", true) - changeCSS("--input-placeholder-color", "white", true) - changeCSS("--input-background-color", "black", true) - changeCSS("--input-border-color", "#eb6f92", true) - changeCSS("--input-border-size", "1.3px", true) - changeCSS("--navbar-link-color", "#000000", true) - changeCSS("--navbar-font", '"Roboto"', true) - changeCSS("--navbar-logo-filter", "invert(30%)", true) - changeCSS("--text-color-primary", "#303030", true) - localStorage.setItem("theme", "light") - } - if (selectedOption == "custom") { - let response = prompt("Please enter the code for a custom theme:", "") - alert("This feature is not ready yet. Please try again later.") - } -} - -function defaultThemes() {} - -function changeCSS(variable, value, saveBool) { - document.documentElement.style.setProperty(variable, value) - - if (saveBool === true) { - saveCSS(variable, value) - } -} - -function saveCSS(variable, value) { - localStorage.setItem(variable, value) + localStorage.setItem('theme', 'dark') } window.onload = function () { - function setCookie(cname, cvalue, exdays) { + function setCookie (cname, cvalue, exdays) { const d = new Date() d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1000) - let expires = "expires=" + d.toUTCString() - document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/" + let expires = 'expires=' + d.toUTCString() + document.cookie = cname + '=' + cvalue + ';' + expires + ';path=/' } - function getCookie(cname) { - let name = cname + "=" + function getCookie (cname) { + let name = cname + '=' let decodedCookie = decodeURIComponent(document.cookie) - let ca = decodedCookie.split(";") + let ca = decodedCookie.split(';') for (let i = 0; i < ca.length; i++) { let c = ca[i] - while (c.charAt(0) == " ") { + while (c.charAt(0) == ' ') { c = c.substring(1) } if (c.indexOf(name) == 0) { return c.substring(name.length, c.length) } } - return "" + return '' } - function httpGet(theUrl) { + function httpGet (theUrl) { var xmlHttp = new XMLHttpRequest() - xmlHttp.open("GET", theUrl, false) // false for synchronous request + xmlHttp.open('GET', theUrl, false) // false for synchronous request xmlHttp.send(null) return xmlHttp.responseText } - if (httpGet("/verification") == "true") { - if (getCookie("verifiedAccess") == "") { - console.log("COOKIE NOT FOUND - ENTRY NOT PERMITTED") - window.location = "/unv.html" + if (httpGet('/verification') == 'true') { + if (getCookie('verifiedAccess') == '') { + console.log('COOKIE NOT FOUND - ENTRY NOT PERMITTED') + window.location = '/unv.html' } else { - console.log("COOKIE RECOGNIZED - ENTRY PERMITTED ") + console.log('COOKIE RECOGNIZED - ENTRY PERMITTED ') } } - let background = localStorage.getItem("--background-primary") - let navbar = localStorage.getItem("--navbar-color") - let navbarHeight = localStorage.getItem("--navbar-height") - let navbarText = localStorage.getItem("--navbar-text-color") - let inputText = localStorage.getItem("--input-text-color") - let inputPlaceholder = localStorage.getItem("--input-placeholder-color") - let inputBackground = localStorage.getItem("--input-background-color") - let inputBorder = localStorage.getItem("--input-border-color") - let inputBorderSize = localStorage.getItem("--input-border-size") - let navbarFont = localStorage.getItem("--navbar-font") - let navbarLink = localStorage.getItem("--navbar-link-color") - let navbarLogoFilter = localStorage.getItem("--navbar-logo-filter") - let textColorPrimary = localStorage.getItem("--text-color-primary") - changeCSS("--background-primary", background) - changeCSS("--navbar-color", navbar) - changeCSS("--navbar-height", navbarHeight) - changeCSS("--navbar-text-color", navbarText) - changeCSS("--input-text-color", inputText) - changeCSS("--input-placeholder-color", inputPlaceholder) - changeCSS("--input-background-color", inputBackground) - changeCSS("--input-border-color", inputBorder) - changeCSS("--input-border-size", inputBorderSize) - changeCSS("--navbar-link-color", navbarLink) - changeCSS("--navbar-font", navbarFont) - changeCSS("--navbar-logo-filter", navbarLogoFilter) - changeCSS("--text-color-primary", textColorPrimary) + let background = localStorage.getItem('--background-primary') + let navbar = localStorage.getItem('--navbar-color') + let navbarHeight = localStorage.getItem('--navbar-height') + let navbarText = localStorage.getItem('--navbar-text-color') + let inputText = localStorage.getItem('--input-text-color') + let inputPlaceholder = localStorage.getItem('--input-placeholder-color') + let inputBackground = localStorage.getItem('--input-background-color') + let inputBorder = localStorage.getItem('--input-border-color') + let inputBorderSize = localStorage.getItem('--input-border-size') + let navbarFont = localStorage.getItem('--navbar-font') + let navbarLink = localStorage.getItem('--navbar-link-color') + let navbarLogoFilter = localStorage.getItem('--navbar-logo-filter') + let textColorPrimary = localStorage.getItem('--text-color-primary') + changeCSS('--background-primary', background) + changeCSS('--navbar-color', navbar) + changeCSS('--navbar-height', navbarHeight) + changeCSS('--navbar-text-color', navbarText) + changeCSS('--input-text-color', inputText) + changeCSS('--input-placeholder-color', inputPlaceholder) + changeCSS('--input-background-color', inputBackground) + changeCSS('--input-border-color', inputBorder) + changeCSS('--input-border-size', inputBorderSize) + changeCSS('--navbar-link-color', navbarLink) + changeCSS('--navbar-font', navbarFont) + changeCSS('--navbar-logo-filter', navbarLogoFilter) + changeCSS('--text-color-primary', textColorPrimary) +} + +function changeCSS (variable, value, saveBool) { + document.documentElement.style.setProperty(variable, value) + + if (saveBool === true) { + saveCSS(variable, value) + } } -// Resets themes -function resetViews() { - changeCSS("--background-primary", "#191724", true) - changeCSS("--navbar-color", "#26233a", true) - changeCSS("--navbar-height", "60px", true) - changeCSS("--navbar-text-color", "rgb(121 103 221)", true) - changeCSS("--navbar-link-color", "#e0def4", true) - changeCSS("--navbar-font", '"Roboto"', true) - changeCSS("--input-text-color", "#e0def4", true) - changeCSS("--input-placeholder-color", "#6e6a86", true) - changeCSS("--input-background-color", "#1f1d2e", true) - changeCSS("--input-placeholder-color", "white", true) - changeCSS("--input-border-color", "#eb6f92", true) - changeCSS("--input-border-size", "1.3px", true) - return "All views reset" +function saveCSS (variable, value) { + localStorage.setItem(variable, value) } // Extra logging for support -function log() { +function log () { setTimeout( console.log.bind( console, - "%cWelcome To Nebula", - "background: #3F51B5;color:#FFF;padding:5px;border-radius: 5px;line-height: 26px; font-size:30px;" + '%cWelcome To Nebula', + 'background: #3F51B5;color:#FFF;padding:5px;border-radius: 5px;line-height: 26px; font-size:30px;' ) ) setTimeout( console.log.bind( console, "%c If you are seeing this, Nebula's main script has succesfully loaded!", - "background: green;color:#FFF;padding:5px;border-radius: 5px;line-height: 26px; font-size:12px;" + 'background: green;color:#FFF;padding:5px;border-radius: 5px;line-height: 26px; font-size:12px;' ) ) setTimeout( console.log.bind( console, - "%cIf you encounter an error, contact our support team on discord. Copy and paste the information below and send it in the ticket", - "background: red;color:#FFF;padding:5px;border-radius: 5px;line-height: 26px; font-size:12px;" + '%cIf you encounter an error, contact our support team on discord. Copy and paste the information below and send it in the ticket', + 'background: red;color:#FFF;padding:5px;border-radius: 5px;line-height: 26px; font-size:12px;' ) ) let enabledCookies = navigator.cookieEnabled @@ -497,235 +439,246 @@ function log() { let browserName let diagnosticDomain = window.location.href if (userAgent.match(/chrome|chromium|crios/i)) { - browserName = "chrome" + browserName = 'chrome' } else if (userAgent.match(/firefox|fxios/i)) { - browserName = "firefox" + browserName = 'firefox' } else if (userAgent.match(/safari/i)) { - browserName = "safari" + browserName = 'safari' } else if (userAgent.match(/opr\//i)) { - browserName = "opera" + browserName = 'opera' } else if (userAgent.match(/edg/i)) { - browserName = "edge" + browserName = 'edge' } else { - browserName = "No browser detection" + browserName = 'No browser detection' } setTimeout( console.log.bind( console, `%cInformation: \n URL: ${diagnosticDomain} \n BrowserName: ${browserName} \n IsOnline: ${online} \n agent: ${userAgent}, `, - "background: gray;color:#FFF;padding:3px;border-radius: 0px;line-height: 26px; font-size:6px;" + 'background: gray;color:#FFF;padding:3px;border-radius: 0px;line-height: 26px; font-size:6px;' ) ) } log() - -// Notification Banners -// "Saved" notification -function saveIc() { - console.log("Checked") - var notification = ` -
-
- Success! Your settings have been saved! -
-
- ` - document.getElementById("notifhere").innerHTML = notification - setTimeout(() => { - var NotificationOBJ = document.getElementById("notifhere") - }, 2000) -} -// The "You have unsaved changes" banner. You can remove this but it isn't recommended -function unsavedChanges() { - var notification = ` -
-
- Danger! You have unsaved changes! -
-
- ` - document.getElementById("notifhere").innerHTML = notification - setTimeout(() => { - var NotificationOBJ = document.getElementById("notifhere") - }, 2000) +function switchTheme () { + var selecter = document.getElementById('themeSwitcher') + var selectedOption = selecter.value + if (selectedOption == 'dark') { + changeCSS('--background-primary', '#191724', true) + changeCSS('--navbar-color', '#26233a', true) + changeCSS('--navbar-height', '60px', true) + changeCSS('--navbar-text-color', '#7967dd', true) + changeCSS('--input-text-color', '#e0def4', true) + changeCSS('--input-placeholder-color', '#6e6a86', true) + changeCSS('--input-background-color', '#1f1d2e', true) + changeCSS('--input-placeholder-color', 'white', true) + changeCSS('--input-border-color', '#eb6f92', true) + changeCSS('--input-border-size', '1.3px', true) + changeCSS('--navbar-link-color', '#e0def4', true) + changeCSS('--navbar-font', '"Roboto"', true) + changeCSS('--navbar-logo-filter', 'invert(0%)', true) + changeCSS('--text-color-primary', '#e0def4', true) + localStorage.setItem('theme', 'dark') + } + if (selectedOption == 'light') { + changeCSS('--background-primary', '#d8d8d8', true) + changeCSS('--navbar-color', '#a2a2a2', true) + changeCSS('--navbar-height', '4em', true) + changeCSS('--navbar-text-color', '#000000', true) + changeCSS('--input-text-color', '#e0def4', true) + changeCSS('--input-placeholder-color', 'white', true) + changeCSS('--input-background-color', 'black', true) + changeCSS('--input-border-color', '#eb6f92', true) + changeCSS('--input-border-size', '1.3px', true) + changeCSS('--navbar-link-color', '#000000', true) + changeCSS('--navbar-font', '"Roboto"', true) + changeCSS('--navbar-logo-filter', 'invert(30%)', true) + changeCSS('--text-color-primary', '#303030', true) + localStorage.setItem('theme', 'light') + } + if (selectedOption == 'custom') { + let response = prompt('Please enter the code for a custom theme:', '') + alert('This feature is not ready yet. Please try again later.') + } } + // Adjectives and surnames for a more advanced stealth engine. // Used together to generate random names for the tab name const adjectives = [ - "admiring", - "adoring", - "affectionate", - "agitated", - "amazing", - "angry", - "awesome", - "beautiful", - "blissful", - "bold", - "boring", - "brave", - "busy", - "charming", - "clever", - "cool", - "compassionate", - "competent", - "condescending", - "confident", - "cranky", - "crazy", - "dazzling", - "determined", - "distracted", - "dreamy", - "eager", - "ecstatic", - "elastic", - "elated", - "elegant", - "eloquent", - "epic", - "exciting", - "fervent", - "festive", - "flamboyant", - "focused", - "friendly", - "frosty", - "funny", - "gallant", - "gifted", - "goofy", - "gracious", - "great", - "happy", - "hardcore", - "heuristic", - "hopeful", - "hungry", - "infallible", - "inspiring", - "interesting", - "intelligent", - "jolly", - "jovial", - "keen", - "kind", - "laughing", - "loving", - "lucid", - "magical", - "mystifying", - "modest", - "musing", - "naughty", - "nervous", - "nice", - "nifty", - "nostalgic", - "objective", - "optimistic", - "peaceful", - "pedantic", - "pensive", - "practical", - "priceless", - "quirky", - "quizzical", - "recursing", - "relaxed", - "reverent", - "romantic", - "sad", - "serene", - "sharp", - "silly", - "sleepy", - "stoic", - "strange", - "stupefied", - "suspicious", - "sweet", - "tender", - "thirsty", - "trusting", - "unruffled", - "upbeat", - "vibrant", - "vigilant", - "vigorous", - "wizardly", - "wonderful", - "xenodochial", - "youthful", - "zealous", - "zen", + 'admiring', + 'adoring', + 'affectionate', + 'agitated', + 'amazing', + 'angry', + 'awesome', + 'beautiful', + 'blissful', + 'bold', + 'boring', + 'brave', + 'busy', + 'charming', + 'clever', + 'cool', + 'compassionate', + 'competent', + 'condescending', + 'confident', + 'cranky', + 'crazy', + 'dazzling', + 'determined', + 'distracted', + 'dreamy', + 'eager', + 'ecstatic', + 'elastic', + 'elated', + 'elegant', + 'eloquent', + 'epic', + 'exciting', + 'fervent', + 'festive', + 'flamboyant', + 'focused', + 'friendly', + 'frosty', + 'funny', + 'gallant', + 'gifted', + 'goofy', + 'gracious', + 'great', + 'happy', + 'hardcore', + 'heuristic', + 'hopeful', + 'hungry', + 'infallible', + 'inspiring', + 'interesting', + 'intelligent', + 'jolly', + 'jovial', + 'keen', + 'kind', + 'laughing', + 'loving', + 'lucid', + 'magical', + 'mystifying', + 'modest', + 'musing', + 'naughty', + 'nervous', + 'nice', + 'nifty', + 'nostalgic', + 'objective', + 'optimistic', + 'peaceful', + 'pedantic', + 'pensive', + 'practical', + 'priceless', + 'quirky', + 'quizzical', + 'recursing', + 'relaxed', + 'reverent', + 'romantic', + 'sad', + 'serene', + 'sharp', + 'silly', + 'sleepy', + 'stoic', + 'strange', + 'stupefied', + 'suspicious', + 'sweet', + 'tender', + 'thirsty', + 'trusting', + 'unruffled', + 'upbeat', + 'vibrant', + 'vigilant', + 'vigorous', + 'wizardly', + 'wonderful', + 'xenodochial', + 'youthful', + 'zealous', + 'zen' ], surnames = [ - "albattani", - "allen", - "almeida", - "antonelli", - "agnesi", - "archimedes", - "ardinghelli", - "aryabhata", - "austin", - "babbage", - "banach", - "banzai", - "bardeen", - "bartik", - "bassi", - "beaver", - "bell", - "benz", - "bhabha", - "bhaskara", - "black", - "blackburn", - "blackwell", - "bohr", - "booth", - "borg", - "bose", - "bouman", - "boyd", - "brahmagupta", - "brattain", - "brown", - "buck", - "burnell", - "cannon", - "carson", - "cartwright", - "carver", - "cerf", - "chandrasekhar", + 'albattani', + 'allen', + 'almeida', + 'antonelli', + 'agnesi', + 'archimedes', + 'ardinghelli', + 'aryabhata', + 'austin', + 'babbage', + 'banach', + 'banzai', + 'bardeen', + 'bartik', + 'bassi', + 'beaver', + 'bell', + 'benz', + 'bhabha', + 'bhaskara', + 'black', + 'blackburn', + 'blackwell', + 'bohr', + 'booth', + 'borg', + 'bose', + 'bouman', + 'boyd', + 'brahmagupta', + 'brattain', + 'brown', + 'buck', + 'burnell', + 'cannon', + 'carson', + 'cartwright', + 'carver', + 'cerf', + 'chandrasekhar' ] // Random number generator // Dependency of getRandomName function -function getRandomNumber(min, max) { +function getRandomNumber (min, max) { return Math.floor(Math.random() * (max - min) + min) } // Random name generator -function getRandomName() { +function getRandomName () { const random1 = getRandomNumber(0, adjectives.length) const random2 = getRandomNumber(0, surnames.length) const adjective = adjectives[random1] const surname = surnames[random2] // Connect the adjective and surname together to create a random name - const randomName = adjective + "-" + surname + const randomName = adjective + '-' + surname // Return it so it can be called later as a variable for the Tab Name. return randomName } // Check if the Browser variable is undefined // This is unused as of now but it could be used for better cloaking in the future, specifically with activeTab -if (typeof browser === "undefined") { +if (typeof browser === 'undefined') { // Initialize the browser variable var browser = chrome } @@ -733,39 +686,38 @@ browser = chrome // Clickoff cloaking // This function is called as a callback during the event listener -function handleTabLeave() { +function handleTabLeave () { var link = document.querySelector("link[rel~='icon']") - if (localStorage.getItem("ADVcloak") == "on") { - if (document.title == "Nebula") { + if (localStorage.getItem('ADVcloak') == 'on') { + if (document.title == 'Nebula') { if (!link) { - link = document.createElement("link") - link.rel = "icon" - document.getElementsByTagName("head")[0].appendChild(link) + link = document.createElement('link') + link.rel = 'icon' + document.getElementsByTagName('head')[0].appendChild(link) } link.href = - "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQo7AE3IF34XPGyseQjkXIOsWXpkZiLlMjSAwySjcJSPAwlv3hnGKi1&usqp=CAU" - document.title = "Google" - } else if (document.title == "Google") { - document.title = "Nebula" + 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQo7AE3IF34XPGyseQjkXIOsWXpkZiLlMjSAwySjcJSPAwlv3hnGKi1&usqp=CAU' + document.title = 'Google' + } else if (document.title == 'Google') { + document.title = 'Nebula' if (!link) { - link = document.createElement("link") - link.rel = "icon" - document.getElementsByTagName("head")[0].appendChild(link) + link = document.createElement('link') + link.rel = 'icon' + document.getElementsByTagName('head')[0].appendChild(link) } link.href = - "https://camo.githubusercontent.com/b565ae2e136e0ac6023e7099288a62382de7c2b8cdce86a8b90449b86649434c/68747470733a2f2f6e6562756c6170726f78792e6e6562756c612e62696f2f696d616765732f6c6f676f2e706e67" + 'https://camo.githubusercontent.com/b565ae2e136e0ac6023e7099288a62382de7c2b8cdce86a8b90449b86649434c/68747470733a2f2f6e6562756c6170726f78792e6e6562756c612e62696f2f696d616765732f6c6f676f2e706e67' } else { return false } } } // Create and Add the event listener -document.addEventListener("visibilitychange", handleTabLeave) - +document.addEventListener('visibilitychange', handleTabLeave) const stealthStored = localStorage.getItem('nogg') -function link(_link) { - if (stealthStored == "on") { +function link (_link) { + if (stealthStored == 'on') { let inFrame try { inFrame = window !== top @@ -773,33 +725,35 @@ function link(_link) { inFrame = true } setTimeout(() => { - if (!inFrame && !navigator.userAgent.includes("Firefox")) { - const popup = open("about:blank", "_blank") + if (!inFrame && !navigator.userAgent.includes('Firefox')) { + const popup = open('about:blank', '_blank') if (!popup || popup.closed) { - alert("Popups are disabled!") + alert('Popups are disabled!') } else { const doc = popup.document - const iframe = doc.createElement("iframe") + const iframe = doc.createElement('iframe') const style = iframe.style - const img = doc.createElement("link") + const img = doc.createElement('link') const link = location.href - img.rel = "icon" + img.rel = 'icon' img.href = - "https://ssl.gstatic.com/images/branding/product/1x/drive_2020q4_32dp.png" + 'https://ssl.gstatic.com/images/branding/product/1x/drive_2020q4_32dp.png' doc.title = getRandomName() var currentLink = _link.slice(0, _link.length - 1) iframe.src = - location.origin + "/service/go/" + __uv$config.encodeUrl(currentLink) - style.position = "fixed" + location.origin + + '/service/go/' + + __uv$config.encodeUrl(currentLink) + style.position = 'fixed' style.top = style.bottom = style.left = style.right = 0 - style.border = style.outline = "none" - style.width = style.height = "100%" + style.border = style.outline = 'none' + style.width = style.height = '100%' doc.body.appendChild(iframe) } } }, 0200) } else { location.href = - "service/go/" + __uv$config.encodeUrl("https://radon.games/") + 'service/go/' + __uv$config.encodeUrl('https://radon.games/') } } diff --git a/static/resources/options.js b/static/resources/options.js new file mode 100644 index 00000000..725c2235 --- /dev/null +++ b/static/resources/options.js @@ -0,0 +1,161 @@ +// OPTIONS + +const storedSetTheme = localStorage.getItem('theme') + +function switchProxy () { + var selecter = document.getElementById('proxySwitcher') + var selectedOption = selecter.value + + localStorage.setItem('proxy', selectedOption) + var storedChoice = localStorage.getItem('proxy') + console.log(selectedOption) +} +function switchTheme () { + var selecter = document.getElementById('themeSwitcher') + var selectedOption = selecter.value + if (selectedOption == 'dark') { + changeCSS('--background-primary', '#191724', true) + changeCSS('--navbar-color', '#26233a', true) + changeCSS('--navbar-height', '60px', true) + changeCSS('--navbar-text-color', '#7967dd', true) + changeCSS('--input-text-color', '#e0def4', true) + changeCSS('--input-placeholder-color', '#6e6a86', true) + changeCSS('--input-background-color', '#1f1d2e', true) + changeCSS('--input-placeholder-color', 'white', true) + changeCSS('--input-border-color', '#eb6f92', true) + changeCSS('--input-border-size', '1.3px', true) + changeCSS('--navbar-link-color', '#e0def4', true) + changeCSS('--navbar-font', '"Roboto"', true) + changeCSS('--navbar-logo-filter', 'invert(0%)', true) + changeCSS('--text-color-primary', '#e0def4', true) + localStorage.setItem('theme', 'dark') + } + if (selectedOption == 'light') { + changeCSS('--background-primary', '#d8d8d8', true) + changeCSS('--navbar-color', '#a2a2a2', true) + changeCSS('--navbar-height', '4em', true) + changeCSS('--navbar-text-color', '#000000', true) + changeCSS('--input-text-color', '#e0def4', true) + changeCSS('--input-placeholder-color', 'white', true) + changeCSS('--input-background-color', 'black', true) + changeCSS('--input-border-color', '#eb6f92', true) + changeCSS('--input-border-size', '1.3px', true) + changeCSS('--navbar-link-color', '#000000', true) + changeCSS('--navbar-font', '"Roboto"', true) + changeCSS('--navbar-logo-filter', 'invert(30%)', true) + changeCSS('--text-color-primary', '#303030', true) + localStorage.setItem('theme', 'light') + } + if (selectedOption == 'custom') { + let response = prompt('Please enter the code for a custom theme:', '') + alert('This feature is not ready yet. Please try again later.') + } +} + +// onload event +window.onload = function () { + let background = localStorage.getItem('--background-primary') + let navbar = localStorage.getItem('--navbar-color') + let navbarHeight = localStorage.getItem('--navbar-height') + let navbarText = localStorage.getItem('--navbar-text-color') + let inputText = localStorage.getItem('--input-text-color') + let inputPlaceholder = localStorage.getItem('--input-placeholder-color') + let inputBackground = localStorage.getItem('--input-background-color') + let inputBorder = localStorage.getItem('--input-border-color') + let inputBorderSize = localStorage.getItem('--input-border-size') + let navbarFont = localStorage.getItem('--navbar-font') + let navbarLink = localStorage.getItem('--navbar-link-color') + let navbarLogoFilter = localStorage.getItem('--navbar-logo-filter') + let textColorPrimary = localStorage.getItem('--text-color-primary') + changeCSS('--background-primary', background) + changeCSS('--navbar-color', navbar) + changeCSS('--navbar-height', navbarHeight) + changeCSS('--navbar-text-color', navbarText) + changeCSS('--input-text-color', inputText) + changeCSS('--input-placeholder-color', inputPlaceholder) + changeCSS('--input-background-color', inputBackground) + changeCSS('--input-border-color', inputBorder) + changeCSS('--input-border-size', inputBorderSize) + changeCSS('--navbar-link-color', navbarLink) + changeCSS('--navbar-font', navbarFont) + changeCSS('--navbar-logo-filter', navbarLogoFilter) + changeCSS('--text-color-primary', textColorPrimary) +} + +function changeCSS (variable, value, saveBool) { + document.documentElement.style.setProperty(variable, value) + + if (saveBool === true) { + saveCSS(variable, value) + } +} + +function saveCSS (variable, value) { + localStorage.setItem(variable, value) +} + +function resetViews () { + changeCSS('--background-primary', '#191724', true) + changeCSS('--navbar-color', '#26233a', true) + changeCSS('--navbar-height', '60px', true) + changeCSS('--navbar-text-color', 'rgb(121 103 221)', true) + changeCSS('--navbar-link-color', '#e0def4', true) + changeCSS('--navbar-font', '"Roboto"', true) + changeCSS('--input-text-color', '#e0def4', true) + changeCSS('--input-placeholder-color', '#6e6a86', true) + changeCSS('--input-background-color', '#1f1d2e', true) + changeCSS('--input-placeholder-color', 'white', true) + changeCSS('--input-border-color', '#eb6f92', true) + changeCSS('--input-border-size', '1.3px', true) + return 'All views reset' +} +function saveIc () { + console.log('Checked') + var notification = ` +
+
+ Success! Your settings have been saved! +
+
+ ` + document.getElementById('notifhere').innerHTML = notification + setTimeout(() => { + var NotificationOBJ = document.getElementById('notifhere') + }, 2000) +} + +function unsavedChanges () { + var notification = ` +
+
+ Danger! You have unsaved changes! +
+
+ ` + document.getElementById('notifhere').innerHTML = notification + setTimeout(() => { + var NotificationOBJ = document.getElementById('notifhere') + }, 2000) +} + +var option = localStorage.getItem('nogg') + +function toggleNoGG () { + if (option === 'on') { + option = 'off' + localStorage.setItem('nogg', 'off') + } else { + option = 'on' + localStorage.setItem('nogg', 'on') + } +} +var option2 = localStorage.getItem('ADVcloak') +function toggleClickoff () { + if (option2 === 'on') { + option2 = 'off' + localStorage.setItem('ADVcloak', 'off') + } else { + option2 = 'on' + localStorage.setItem('ADVcloak', 'on') + } +} diff --git a/static/style/options.css b/static/style/options.css index a8908957..7babb768 100644 --- a/static/style/options.css +++ b/static/style/options.css @@ -494,36 +494,37 @@ label:active:after { width: 38px; } -.bareLocationInput { +.bareLocationInput { border-style: solid !important; - border: var(--input-border-size) solid #5e18eb; - border-width: 0px; - border-radius: 6px; - background-color: #191724; - color: var(--input-text-color); - width: auto; - height: auto; - box-shadow: none !important; - outline: none; - text-align: center; - width: 220px; - font-size: 16px; - font-family: 'Roboto'; - height: 29px; + border: var(--input-border-size) solid #5e18eb; + border-width: 0px; + border-radius: 6px; + background-color: #191724; + color: var(--input-text-color); + width: auto; + height: auto; + box-shadow: none !important; + outline: none; + text-align: center; + width: 220px; + font-size: 16px; + font-family: 'Roboto'; + height: 29px; transition: 0.06s; } -.bareLocationInput:hover { - border: var(--input-border-size) solid #5e18eb; - border-width: 1px; - border-radius: 6px; - + +.bareLocationInput:hover { + border: var(--input-border-size) solid #5e18eb; + border-width: 1px; + border-radius: 6px; + } -.bareValidSignal{ +.bareValidSignal { margin-top: -13px; - color: #f45145bd; - font-family: 'Ubuntu', sans-serif; - font-weight: lighter; - font-size: 13px; + color: #f45145bd; + font-family: 'Ubuntu', sans-serif; + font-weight: lighter; + font-size: 13px; text-align: center; } \ No newline at end of file diff --git a/static/sw.js b/static/sw.js index db391859..02f45510 100644 --- a/static/sw.js +++ b/static/sw.js @@ -1,6 +1,3 @@ -importScripts('./uv/uv.bundle.js'); -importScripts('./resources/appModules/database-manager.js'); -importScripts('./uv/uv.config.js'); importScripts('./uv/uv.sw.js'); importScripts('./osana/osana.worker.js'); diff --git a/static/uv/uv.config.js b/static/uv/uv.config.js index aa1c6bf1..95ab7d83 100644 --- a/static/uv/uv.config.js +++ b/static/uv/uv.config.js @@ -1,12 +1,11 @@ - - self.__uv$config = { prefix: '/service/go/', - bare: self.storage.get("bareLocation"), + bare: '', encodeUrl: Ultraviolet.codec.xor.encode, decodeUrl: Ultraviolet.codec.xor.decode, handler: '/uv/uv.handler.js', bundle: '/uv/uv.bundle.js', config: '/uv/uv.config.js', sw: '/uv/uv.sw.js', -}; \ No newline at end of file +}; + diff --git a/static/uv/uv.sw.js b/static/uv/uv.sw.js index 53c74867..b0cdc00e 100644 --- a/static/uv/uv.sw.js +++ b/static/uv/uv.sw.js @@ -1,10 +1,28 @@ +importScripts('/uv/uv.bundle.js'); +importScripts('/uv/uv.config.js'); class UVServiceWorker extends EventEmitter { constructor(config = __uv$config) { super(); - if (!config.bare) config.bare = '/bare/'; - this.addresses = typeof config.bare === 'string' ? [ new URL(config.bare, location) ] : config.bare.map(str => new URL(str, location)); + +const dbPromise = Ultraviolet.openDB('keyval-store', 1, { + upgrade(db) { + db.createObjectStore('keyval'); + }, +}); + +function getBareLocation() { + return dbPromise.then(db => db.get('keyval', 'bareLocation')).then(value => value || ''); +} +getBareLocation().then(bareLocation => { + if (!config.bare) config.bare = bareLocation; + this.addresses = Array.isArray(config.bare) + ? config.bare.map(str => new URL(str, location)) + : typeof config.bare === 'string' + ? [new URL(config.bare, location)] + : []; +}); this.headers = { csp: [ 'cross-origin-embedder-policy',