Finalize BareSwitcher, clean up the edges n whatnot

This commit is contained in:
GreenyDev 2023-01-03 16:31:37 -05:00
parent 8061f621f2
commit dd3470259c
12 changed files with 761 additions and 594 deletions

View file

@ -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)}}});

File diff suppressed because one or more lines are too long

View file

@ -12,8 +12,8 @@
<!-- Embed -->
<script src="../uv/uv.bundle.js"></script>
<script src="../resources/appModules/selectBare.js"></script>
<script src="../resources/appModules/BareSwitcher.js"></script>
<script src="../resources/options.js"></script>
<meta name="theme-color" content="#5a189a">
<meta property=og:title content=Nebula>
<meta property="og:type" content="website" />
@ -187,7 +187,10 @@ if (cloakStored == "on") {
}
themeSelector.value = themeStored
proxySel.value = proxyStored
document.getElementById("bareLocationInput").value = localStorage.getItem("_BareLocation")
getBareLocation().then(bareLocation => {
document.getElementById("bareLocationInput").value = bareLocation;
});
</script>
</body>

View file

@ -0,0 +1,103 @@
// 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')
}
})
function getBareLocation () {
return dbPromise
.then(db => 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'
}
}
})
})

View file

@ -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 get (key) {
return (await dbPromise).get('keyval', key)
},
async set(key, val) {
return (await dbPromise).put('keyval', val, key);
},
async set (key, val) {
return (await dbPromise).put('keyval', val, key)
},
async del(key) {
return (await dbPromise).delete('keyval', key);
},
async del (key) {
return (await dbPromise).delete('keyval', key)
}
}

View file

@ -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'
}
}
});
});

File diff suppressed because it is too large Load diff

161
static/resources/options.js Normal file
View file

@ -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 = `
<div class="notification-container" id="notification-container">
<div class="notification notification-success">
<strong>Success!</strong> Your settings have been saved!
</div>
</div>
`
document.getElementById('notifhere').innerHTML = notification
setTimeout(() => {
var NotificationOBJ = document.getElementById('notifhere')
}, 2000)
}
function unsavedChanges () {
var notification = `
<div class="notification-container" id="notification-container">
<div class="notification notification-danger" id="notification-container">
<strong>Danger!</strong> You have unsaved changes!
</div>
</div>
`
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')
}
}

View file

@ -496,34 +496,35 @@ label:active:after {
.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;
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;
}

View file

@ -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');

View file

@ -1,8 +1,6 @@
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',
@ -10,3 +8,4 @@ self.__uv$config = {
config: '/uv/uv.config.js',
sw: '/uv/uv.sw.js',
};

View file

@ -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',