add UV, break dynamic
This commit is contained in:
+2
-1
@@ -1,2 +1,3 @@
|
||||
**/node_modules
|
||||
**/package-lock.json
|
||||
**/package-lock.json
|
||||
**.DS_Store
|
||||
@@ -1,11 +1,12 @@
|
||||
import { createBareServer } from '@tomphttp/bare-server-node';
|
||||
import http from 'node:http';
|
||||
import express from 'express';
|
||||
import path from 'node:path';
|
||||
import mime from 'mime';
|
||||
import cors from 'cors';
|
||||
import url from 'url';
|
||||
|
||||
import url from 'node:url';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import http from 'node:http';
|
||||
|
||||
const app = express();
|
||||
const server = http.createServer();
|
||||
@@ -16,7 +17,6 @@ const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
|
||||
|
||||
let navbar = fs.readFileSync('./templates/navbar.html', 'utf-8');
|
||||
|
||||
|
||||
fs.readdirSync('./pages').forEach(file => {
|
||||
let fileData = fs.readFileSync('./pages/' + file, 'utf-8');
|
||||
fileData = fileData.replace('<body>', '<body> ' + navbar);
|
||||
@@ -59,7 +59,6 @@ server.on('upgrade', (req, socket, head) => {
|
||||
else socket.end();
|
||||
});
|
||||
|
||||
|
||||
server.on('listening', () => {
|
||||
console.log(`Polaris started! http://localhost:${port}`);
|
||||
});
|
||||
|
||||
+12
-11
@@ -5,24 +5,25 @@
|
||||
"main": "index.js",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"start": "node index.js"
|
||||
"start": "node index.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/polarisdevs/Polaris.git"
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/polarisdevs/Polaris.git"
|
||||
},
|
||||
"keywords": [
|
||||
"games",
|
||||
"unblocked",
|
||||
"proxy"
|
||||
"games",
|
||||
"unblocked",
|
||||
"proxy"
|
||||
],
|
||||
"author": "Polaris Developments",
|
||||
"license": "GNU-3.0-or-later",
|
||||
"homepage": "https://github.com/polarisdevs/Polaris#readme",
|
||||
"dependencies": {
|
||||
"@tomphttp/bare-server-node": "*",
|
||||
"cors": "*",
|
||||
"express": "*",
|
||||
"mime": "*"
|
||||
"@tomphttp/bare-server-node": "*",
|
||||
"cors": "*",
|
||||
"easyviolet": "github:Russell2259/Easyviolet",
|
||||
"express": "*",
|
||||
"mime": "*"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,6 @@
|
||||
{
|
||||
"name": "GeForce Now",
|
||||
"image": "/assets/img/gnow.png",
|
||||
"source": "/service/hvtrs8%2F-pna%7B.eedopcgnmw%2Ccmm-mcln%2F#/layout/games"
|
||||
"source": "/service/hvtrs8%2F-lmgkn%2Cntgq.lvkdka%2Ccmm-ut%2Fqepvkcg%2Fjvvrq8'2D-nmekl%250Clteq%2Cltkfkc%250Camo--v3%2Fnoeil%2Fkdgnvidigr%3Dppedeprgd%5Dntific%3Dvrwe%24cmnvezt%3FIlivicl%24tjeoe%3FNmip%26noaane%3Fel-WS%24ppoopv%3Dqeneat%5Daacmult%24kgy%3Fe%7BJjbEckOkJKUxI3NkJ%3B.gyHzXSK6KnT3OkaiNCH0%602vl%60knkKjmiOTG1MDK0LDK1LjWxMDCyMTOxOiKsKm%3B0KjmiOTG1MDK0LDK1LjWzLDewLjWyMCKsKmT4aCK6OT%5B5LjOwOza0MSuicWD0KjmxLji2OjG3OzS5NCHqfGiiMiK3OGLjLDnkXC2zOjWyNTPkXm%5BtMTi0Xi20LzLmLmOw%5BmKzL2WidQ%2C4hesdLB1iVIol50Pzi8%5BeGfEELJ%60o7NtssdqG%3BdrGkg%24cnignv_kd%3F3304721%3B2030346711"
|
||||
}
|
||||
]
|
||||
@@ -1,4 +1,5 @@
|
||||
import PolarisError from './error.js';
|
||||
import { workerLoaded, loadWorker, chosenProxy } from './wpm.js';
|
||||
|
||||
const tiltEffectSettings = {
|
||||
max: 8, // max tilt rotation (degrees (deg))
|
||||
@@ -16,7 +17,10 @@ const load = () => {
|
||||
el.innerHTML = `<img src="${app.image}"><h3>${app.name}</h3>`;
|
||||
document.querySelector('.apps').appendChild(el);
|
||||
|
||||
el.addEventListener('click', () => {
|
||||
if (app.source.startsWith('/service')) app.source = `/${chosenProxy}${app.source}`;
|
||||
|
||||
el.addEventListener('click', async () => {
|
||||
if (!workerLoaded) await loadWorker();
|
||||
localStorage.setItem('frameData', JSON.stringify({
|
||||
type: 'app',
|
||||
app
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import PolarisError from './error.js';
|
||||
import { workerLoaded, loadWorker, chosenProxy } from './wpm.js';
|
||||
|
||||
const tiltEffectSettings = {
|
||||
max: 8, // max tilt rotation (degrees (deg))
|
||||
@@ -46,7 +47,10 @@ function renderGames(gamesToRender) {
|
||||
el.innerHTML = `<img loading="lazy" src="${game.image}"><h3>${game.name}</h3>`;
|
||||
gamesContainer.appendChild(el);
|
||||
|
||||
el.addEventListener('click', () => {
|
||||
if (game.source.startsWith('/service')) game.source = `/${chosenProxy}${game.source}`;
|
||||
|
||||
el.addEventListener('click', async () => {
|
||||
if (!workerLoaded) await loadWorker();
|
||||
localStorage.setItem('frameData', JSON.stringify({
|
||||
type: 'game',
|
||||
game
|
||||
|
||||
@@ -14,7 +14,6 @@ const Settings = {
|
||||
onbeforeunload = (e) => {
|
||||
if (localStorage.getItem('prevent_close') === 'true') {
|
||||
e.preventDefault();
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
@@ -27,7 +26,7 @@ window.onhashchange = () => {
|
||||
};
|
||||
|
||||
if (window.self === window.top) {
|
||||
setTimeout(() => {
|
||||
setTimeout(async () => {
|
||||
Settings.load();
|
||||
|
||||
if (location.pathname === '/games') Games.load();
|
||||
@@ -50,12 +49,5 @@ if (location.pathname === '/') {
|
||||
}).catch(e => new PolarisError('Failed to load featured game.'));
|
||||
}
|
||||
|
||||
// Create 37 snow divs
|
||||
/*for (let i = 0; i < 37; i++) {
|
||||
const snowDiv = document.createElement("div");
|
||||
snowDiv.classList.add("snow");
|
||||
document.body.appendChild(snowDiv);
|
||||
}*/
|
||||
|
||||
const Polaris = { Settings, Games, Apps, Frame, PolarisError };
|
||||
export default Polaris;
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Stands for Web Prxxy Manager because the keywork Prxxy is usually blocked */
|
||||
import { workerLoaded, loadWorker, chosenProxy } from './wpm.js';
|
||||
|
||||
const load = () => {
|
||||
let xor = {
|
||||
@@ -11,16 +11,8 @@ const load = () => {
|
||||
return decodeURIComponent(str).split('').map((e, i) => i % key ? String.fromCharCode(e.charCodeAt(0) ^ key) : e).join('');
|
||||
}
|
||||
};
|
||||
|
||||
let workerLoaded = false;
|
||||
let loadWorker = async () => await navigator.serviceWorker.register('./sw.js', {
|
||||
scope: '/service/',
|
||||
});
|
||||
|
||||
(async () => {
|
||||
await loadWorker();
|
||||
workerLoaded = true;
|
||||
})();
|
||||
window.xor = xor;
|
||||
|
||||
const form = document.querySelector('#wpf');
|
||||
const query = document.querySelector('#query');
|
||||
@@ -35,7 +27,7 @@ const load = () => {
|
||||
((!query.value.startsWith('http://') && !query.value.startsWith('https://')) ? 'https://' + query.value : query.value) :
|
||||
'https://www.google.com/search?q=' + encodeURIComponent(query.value);
|
||||
|
||||
location.href = `/service/${xor.encode(url)}`;
|
||||
location.href = `/${chosenProxy}/service/${xor.encode(url)}`;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import Theme from './themes.js';
|
||||
import PolarisError from './error.js';
|
||||
import Search from './Search.js';
|
||||
|
||||
const isScrollable = (element) => {
|
||||
return element.scrollWidth > element.clientWidth || element.scrollHeight > element.clientHeight;
|
||||
};
|
||||
const isScrollable = (element) => element.scrollWidth > element.clientWidth || element.scrollHeight > element.clientHeight;
|
||||
|
||||
class Settings {
|
||||
constructor() {
|
||||
@@ -20,19 +19,14 @@ class Settings {
|
||||
if (document.querySelector('#title').value) {
|
||||
this.set('cloak_title', document.querySelector('#title').value);
|
||||
document.title = document.querySelector('#title').value;
|
||||
} else {
|
||||
document.title = 'Polaris';
|
||||
}
|
||||
} else document.title = 'Polaris';
|
||||
});
|
||||
|
||||
document.querySelector('#domain').addEventListener('input', () => {
|
||||
if (document.querySelector('#domain').value) {
|
||||
this.set('cloak_website', document.querySelector('#domain').value);
|
||||
|
||||
document.querySelector('link[rel="shortcut icon"]').href = 'https://www.google.com/s2/favicons?domain=' + document.querySelector('#domain').value;
|
||||
} else {
|
||||
document.querySelector('link[rel="shortcut icon"]').href = '/favicon.ico';
|
||||
}
|
||||
} else document.querySelector('link[rel="shortcut icon"]').href = '/favicon.ico';
|
||||
});
|
||||
|
||||
if (this.get('cloak_title')) {
|
||||
@@ -44,65 +38,50 @@ class Settings {
|
||||
document.querySelector('#domain').value = this.get('cloak_website');
|
||||
document.querySelector('link[rel="shortcut icon"]').href = 'https://www.google.com/s2/favicons?domain=' + this.get('cloak_website');
|
||||
}
|
||||
} else fetch('/assets/JSON/cloaks.json')
|
||||
.then(res => res.json())
|
||||
.then(cloaks => {
|
||||
if (cloaks[this.get('cloak')]) {
|
||||
document.title = cloaks[this.get('cloak')].title;
|
||||
document.querySelector('link[rel="shortcut icon"]').href = cloaks[this.get('cloak')].icon;
|
||||
} else if (this.get('cloak') !== 'none') new PolarisError(`The cloak ${this.get('cloak')} does not exist`);
|
||||
});
|
||||
} else fetch('/assets/JSON/cloaks.json').then(res => res.json()).then(cloaks => {
|
||||
if (cloaks[this.get('cloak')]) {
|
||||
document.title = cloaks[this.get('cloak')].title;
|
||||
document.querySelector('link[rel="shortcut icon"]').href = cloaks[this.get('cloak')].icon;
|
||||
} else if (this.get('cloak') !== 'none') new PolarisError(`The cloak ${this.get('cloak')} does not exist`);
|
||||
});
|
||||
}
|
||||
|
||||
fetch('/assets/JSON/cloaks.json')
|
||||
.then(res => res.json())
|
||||
.then(cloaks => {
|
||||
document.querySelector('#cloak_select').addEventListener('change', () => {
|
||||
if (document.querySelector('#cloak_select').value == 'custom') {
|
||||
fetch('/assets/JSON/cloaks.json').then(res => res.json()).then(cloaks => {
|
||||
document.querySelector('#cloak_select').addEventListener('change', () => {
|
||||
if (document.querySelector('#cloak_select').value == 'custom') {
|
||||
this.set('cloak', document.querySelector('#cloak_select').value);
|
||||
document.querySelector('#custom_cloak').classList.remove('hidden');
|
||||
|
||||
document.querySelector('#title').addEventListener('input', () => {
|
||||
if (document.querySelector('#title').value) {
|
||||
this.set('cloak_title', document.querySelector('#title').value);
|
||||
document.title = document.querySelector('#title').value;
|
||||
} else document.title = 'Polaris';
|
||||
});
|
||||
|
||||
document.querySelector('#domain').addEventListener('input', () => {
|
||||
if (document.querySelector('#domain').value) {
|
||||
this.set('cloak_website', document.querySelector('#domain').value);
|
||||
document.querySelector('link[rel="shortcut icon"]').href = 'https://www.google.com/s2/favicons?domain=' + document.querySelector('#domain').value;
|
||||
} else document.querySelector('link[rel="shortcut icon"]').href = '/favicon.ico';
|
||||
});
|
||||
} else if (document.querySelector('#cloak_select').value == 'none') {
|
||||
this.set('cloak', document.querySelector('#cloak_select').value);
|
||||
|
||||
document.title = 'Polaris';
|
||||
document.querySelector('link[rel="shortcut icon"]').href = '/favicon.ico';
|
||||
document.querySelector('#custom_cloak').classList.add('hidden');
|
||||
} else {
|
||||
if (cloaks[document.querySelector('#cloak_select').value]) {
|
||||
document.title = cloaks[document.querySelector('#cloak_select').value].title;
|
||||
document.querySelector('link[rel="shortcut icon"]').href = cloaks[document.querySelector('#cloak_select').value].icon;
|
||||
this.set('cloak', document.querySelector('#cloak_select').value);
|
||||
} else new PolarisError(`The cloak ${document.querySelector('#cloak_select').value} does not exist`);
|
||||
|
||||
document.querySelector('#custom_cloak').classList.remove('hidden');
|
||||
|
||||
document.querySelector('#title').addEventListener('input', () => {
|
||||
if (document.querySelector('#title').value) {
|
||||
this.set('cloak_title', document.querySelector('#title').value);
|
||||
document.title = document.querySelector('#title').value;
|
||||
} else {
|
||||
document.title = 'Polaris';
|
||||
}
|
||||
});
|
||||
|
||||
document.querySelector('#domain').addEventListener('input', () => {
|
||||
if (document.querySelector('#domain').value) {
|
||||
this.set('cloak_website', document.querySelector('#domain').value);
|
||||
|
||||
document.querySelector('link[rel="shortcut icon"]').href = 'https://www.google.com/s2/favicons?domain=' + document.querySelector('#domain').value;
|
||||
} else {
|
||||
document.querySelector('link[rel="shortcut icon"]').href = '/favicon.ico';
|
||||
}
|
||||
});
|
||||
} else if (document.querySelector('#cloak_select').value == 'none') {
|
||||
this.set('cloak', document.querySelector('#cloak_select').value);
|
||||
|
||||
document.title = 'Polaris';
|
||||
document.querySelector('link[rel="shortcut icon"]').href = '/favicon.ico';
|
||||
|
||||
document.querySelector('#custom_cloak').classList.add('hidden');
|
||||
}
|
||||
else {
|
||||
if (cloaks[document.querySelector('#cloak_select').value]) {
|
||||
document.title = cloaks[document.querySelector('#cloak_select').value].title;
|
||||
document.querySelector('link[rel="shortcut icon"]').href = cloaks[document.querySelector('#cloak_select').value].icon;
|
||||
|
||||
this.set('cloak', document.querySelector('#cloak_select').value);
|
||||
} else {
|
||||
new PolarisError(`The cloak ${document.querySelector('#cloak_select').value} does not exist`);
|
||||
}
|
||||
|
||||
document.querySelector('#custom_cloak').classList.add('hidden');
|
||||
}
|
||||
});
|
||||
document.querySelector('#custom_cloak').classList.add('hidden');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
document.querySelector('#reset_panic').addEventListener('click', (e) => {
|
||||
this.set('panic_key', '');
|
||||
@@ -116,24 +95,17 @@ class Settings {
|
||||
window.onkeydown = (e) => {
|
||||
if (document.querySelector('#panic_key') == document.activeElement) {
|
||||
document.querySelector('#panic_key').value = e.key;
|
||||
|
||||
this.set('panic_key', document.querySelector('#panic_key').value);
|
||||
} else {
|
||||
if (e.key == this.get('panic_key')) {
|
||||
if (this.get('panic_url')) {
|
||||
window.location.href = this.get('panic_url');
|
||||
} else {
|
||||
new PolarisError('A panic key was used but no url was found.');
|
||||
}
|
||||
if (this.get('panic_url')) window.location.href = this.get('panic_url');
|
||||
else new PolarisError('A panic key was used but no url was found.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
document.querySelector('#themes').querySelectorAll('button').forEach(el => {
|
||||
el.onclick = () => {
|
||||
Theme.set(el.innerText.toLocaleLowerCase());
|
||||
}
|
||||
el.onclick = () => Theme.set(el.innerText.toLocaleLowerCase());
|
||||
});
|
||||
|
||||
if (window.location.hash.slice(1)) {
|
||||
@@ -168,33 +140,26 @@ class Settings {
|
||||
sessionStorage.setItem('settings-open', false);
|
||||
} else {
|
||||
document.querySelector('.sidebar').classList.add('active');
|
||||
|
||||
sessionStorage.setItem('settings-open', true);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
if (isScrollable(document.querySelector('.sidebar'))) {
|
||||
document.querySelector('.scroll').classList.add('active');
|
||||
}
|
||||
if (isScrollable(document.querySelector('.sidebar'))) document.querySelector('.scroll').classList.add('active');
|
||||
|
||||
document.querySelector('.scroll').addEventListener('click', () => {
|
||||
document.querySelector('.sidebar').scrollTop = document.querySelector('.sidebar').scrollHeight;
|
||||
});
|
||||
|
||||
document.querySelector('.sidebar').addEventListener('scroll', () => {
|
||||
if (document.querySelector('.sidebar').scrollTop + document.querySelector('.sidebar').clientHeight >= document.querySelector('.sidebar').scrollHeight - 1) {
|
||||
document.querySelector('.scroll').classList.remove('active');
|
||||
} else {
|
||||
document.querySelector('.scroll').classList.add('active');
|
||||
}
|
||||
if (document.querySelector('.sidebar').scrollTop + document.querySelector('.sidebar').clientHeight >= document.querySelector('.sidebar').scrollHeight - 1) document.querySelector('.scroll').classList.remove('active');
|
||||
else document.querySelector('.scroll').classList.add('active');
|
||||
});
|
||||
};
|
||||
|
||||
set = (name, value) => {
|
||||
if (!localStorage.getItem('settings')) {
|
||||
localStorage.setItem('settings', JSON.stringify({}));
|
||||
} else {
|
||||
if (!localStorage.getItem('settings')) localStorage.setItem('settings', JSON.stringify({}));
|
||||
else {
|
||||
try {
|
||||
JSON.parse(localStorage.getItem('settings'));
|
||||
} catch (e) {
|
||||
@@ -208,9 +173,8 @@ class Settings {
|
||||
};
|
||||
|
||||
get = (name) => {
|
||||
if (!localStorage.getItem('settings')) {
|
||||
localStorage.setItem('settings', JSON.stringify({}));
|
||||
} else {
|
||||
if (!localStorage.getItem('settings')) localStorage.setItem('settings', JSON.stringify({}));
|
||||
else {
|
||||
try {
|
||||
JSON.parse(localStorage.getItem('settings'));
|
||||
} catch (e) {
|
||||
@@ -223,9 +187,8 @@ class Settings {
|
||||
}
|
||||
|
||||
remove = (name) => {
|
||||
if (!localStorage.getItem('settings')) {
|
||||
localStorage.setItem('settings', JSON.stringify({}));
|
||||
} else {
|
||||
if (!localStorage.getItem('settings')) localStorage.setItem('settings', JSON.stringify({}));
|
||||
else {
|
||||
try {
|
||||
JSON.parse(localStorage.getItem('settings'));
|
||||
} catch (e) {
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
let workerLoaded = false;
|
||||
let chosenProxy = 'uv'; // 'dynamic';
|
||||
|
||||
let loadWorker = async () => {
|
||||
let allWorkers = await navigator.serviceWorker.getRegistrations();
|
||||
allWorkers.forEach(worker => worker.unregister());
|
||||
await navigator.serviceWorker.register(`/${chosenProxy}-sw.js`, {
|
||||
scope: `/${chosenProxy}/service`,
|
||||
});
|
||||
}
|
||||
|
||||
(async () => {
|
||||
await loadWorker();
|
||||
workerLoaded = true;
|
||||
})();
|
||||
|
||||
export {
|
||||
workerLoaded,
|
||||
loadWorker,
|
||||
chosenProxy
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
// See documentation for more information
|
||||
|
||||
self.__dynamic$config = {
|
||||
prefix: '/service/',
|
||||
prefix: '/dynamic/service/',
|
||||
encoding: 'xor',
|
||||
mode: 'production',
|
||||
logLevel: 0,
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
importScripts('/uv/uv.bundle.js');
|
||||
importScripts('/uv/uv.config.js');
|
||||
importScripts('/uv/uv.sw.js');
|
||||
|
||||
const sw = new UVServiceWorker();
|
||||
|
||||
self.addEventListener('fetch', (event) => event.respondWith(sw.fetch(event)));
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,13 @@
|
||||
// This file overwrites the stock UV config.js
|
||||
|
||||
self.__uv$config = {
|
||||
prefix: "/uv/service/",
|
||||
bare: "/bare/",
|
||||
encodeUrl: Ultraviolet.codec.xor.encode,
|
||||
decodeUrl: Ultraviolet.codec.xor.decode,
|
||||
handler: "/uv/uv.handler.js",
|
||||
client: "/uv/uv.client.js",
|
||||
bundle: "/uv/uv.bundle.js",
|
||||
config: "/uv/uv.config.js",
|
||||
sw: "/uv/uv.sw.js",
|
||||
};
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user