add prevent close setting

This commit is contained in:
Russell2259
2024-01-16 20:06:23 -07:00
parent ad68cd22eb
commit 855bf7cff9
20 changed files with 119 additions and 64 deletions
+1 -1
View File
@@ -10,7 +10,7 @@
"dev": "node server dev"
},
"engines": {
"node": "20.x"
"node": "18.x"
},
"author": "Polaris Development Group",
"license": "GNU-3.0-or-later",
+2 -2
View File
@@ -17,7 +17,7 @@ var gitSupported = true;
const routes = (app) => {
app.get('/api/changelog', async (req, res) => {
const changelog = {
version: packageFile.version || 'unknown',
version: packageFile.version + (Number(packageFile.version.split('.')[0]) <= 1 ? ' Beta' : '') || 'unknown',
changelog: JSON.parse(fs.readFileSync(path.join(__dirname, '../static/assets/JSON/changelog.json')))
}
@@ -45,7 +45,7 @@ const routes = (app) => {
changelog.mode = mode === 'dev' ? 'development' : 'production';
res.json(changelog);
});
});
app.get('/api/favicon', async (req, res) => {
try {
+1 -1
View File
@@ -141,4 +141,4 @@ server.on('upgrade', (req, socket, head) => {
else socket.end();
});
server.listen(port, () => console.log(`Polaris running\n\nPort: ${server.address().port}\nVersion: ${packageFile.version || 'Unknown'} ${childProcess.execSync('git rev-parse HEAD').toString().trim().slice(0, 7) || 'Unknown'}\nMode: ${mode === 'dev' ? 'development' : 'production'}\nNode.js: ${process.version}`));
server.listen(port, () => console.log(`Polaris running\n\nPort: ${server.address().port}\nVersion: ${packageFile.version + (Number(packageFile.version.split('.')[0]) <= 1 ? ' Beta' : '') || 'Unknown'} ${childProcess.execSync('git rev-parse HEAD').toString().trim().slice(0, 7) || 'Unknown'}\nMode: ${mode === 'dev' ? 'development' : 'production'}\nNode.js: ${process.version}`));
+6 -3
View File
@@ -1,14 +1,17 @@
{
"canvas": {
"icon": "https://www.google.com/s2/favicons?domain=https://canvas.instructure.com",
"title": "Dashboard"
"title": "Dashboard",
"clickoff": ""
},
"google": {
"icon": "https://www.google.com/s2/favicons?domain=https://google.com",
"title": "Google"
"title": "Google",
"clickoff": ""
},
"classroom": {
"icon": "https://play-lh.googleusercontent.com/w0s3au7cWptVf648ChCUP7sW6uzdwGFTSTenE178Tz87K_w1P1sFwI6h1CLZUlC2Ug",
"title": "Classes"
"title": "Classes",
"clickoff": ""
}
}
+4 -3
View File
@@ -545,6 +545,7 @@ input:checked+.slider:before {
}
.container {
width: calc(50vw - 155px);
background-color: var(--background-color);
box-shadow: 0vh 0.75vh 1.5vh 0vh var(--shadow-color);
margin-left: 15vh;
@@ -559,6 +560,7 @@ input:checked+.slider:before {
}
.container.centered {
width: auto;
position: absolute;
top: 50%;
left: 50%;
@@ -580,13 +582,12 @@ h1.nomargin {
}
img.featured {
width: 100%;
height: 100%;
height: 52.5vh;
width: 40vw;
object-fit: cover;
overflow: hidden;
display: inline;
margin-top: 2vh;
height: auto;
cursor: pointer;
border: solid;
border-width: 0.5vh;
+10 -1
View File
@@ -5,8 +5,17 @@ const load = () => fetch('/api/apps').then(res => res.json()).then(apps => {
apps.forEach(app => {
const el = document.createElement('div');
el.classList = 'app';
el.innerHTML = `<img src='${app.image}'><h3>${app.name}</h3>`;
document.querySelector('.apps').appendChild(el);
const image = document.createElement('img');
image.src = app.image;
image.loading = 'lazy';
image.onerror = () => image.src = '/assets/img/logo.png';
el.appendChild(image);
const name = document.createElement('h3');
name.textContent = app.name;
el.appendChild(name);
effects.hoverTilt({
max: 8,
+10 -1
View File
@@ -6,8 +6,17 @@ const load = () => fetch('/api/cheats')
.then(cheats => cheats.forEach(cheat => {
const el = document.createElement('div');
el.classList = 'game';
el.innerHTML = `<img src='${cheat.image}'><h3>${cheat.name}</h3>`;
document.querySelector('.cheats').appendChild(el);
const image = document.createElement('img');
image.src = cheat.image;
image.loading = 'lazy';
image.onerror = () => image.src = '/assets/img/logo.png';
el.appendChild(image);
const name = document.createElement('h3');
name.textContent = cheat.name;
el.appendChild(name);
effects.hoverTilt({
max: 8,
+5 -5
View File
@@ -66,7 +66,7 @@ easterEggs.push({
phrase: 'smurf',
run: () => {
return new Promise((resolve, reject) => {
const audio = new Audio('/assets/misc/smurf.mp3');
const audio = new Audio('/assets/misc/media/smurf.mp3');
audio.play();
audio.onplay = () => {
@@ -116,7 +116,7 @@ easterEggs.push({
type: 'keybind',
phrase: 'ham',
run: () => new Promise((resolve, reject) => {
const audio = new Audio('/assets/misc/ringtone.mp3');
const audio = new Audio('/assets/misc/media/ringtone.mp3');
audio.loop = true;
audio.play();
@@ -248,7 +248,7 @@ easterEggs.push({
type: 'keybind',
phrase: 'bruh',
run: () => new Promise((resolve, reject) => {
const audio = new Audio('/assets/misc/bruh.mp3');
const audio = new Audio('/assets/misc/media/bruh.mp3');
audio.play();
const trollFace = document.createElement('img');
@@ -320,7 +320,7 @@ easterEggs.push({
clicks = 0;
clickTime = 0;
const audio = new Audio('/assets/misc/rickroll.mp3');
const audio = new Audio('/assets/misc/media/rickroll.mp3');
audio.play();
audio.onplay = () => {
@@ -367,7 +367,7 @@ easterEggs.push({
z-index: 2147483646;`;
document.body.appendChild(overlay);
const audio = new Audio('/assets/misc/skelly.mp3');
const audio = new Audio('/assets/misc/media/skelly.mp3');
audio.play();
audio.onplay = () => {
+20 -2
View File
@@ -35,8 +35,17 @@ const load = () => {
games.popular.forEach(game => {
const popularEl = document.createElement('div');
popularEl.classList = 'game';
popularEl.innerHTML = `<img loading='lazy' src='${game.image}'><h3>${game.name}</h3>`;
document.querySelector('.popular-games').appendChild(popularEl);
const image = document.createElement('img');
image.src = game.image;
image.loading = 'lazy';
image.onerror = () => image.src = '/assets/img/logo.png';
popularEl.appendChild(image);
const name = document.createElement('h3');
name.textContent = game.name;
popularEl.appendChild(name);
popularEl.addEventListener('click', async () => {
document.body.style.opacity = '0.7';
@@ -66,9 +75,18 @@ const load = () => {
games.all.forEach(game => {
const el = document.createElement('div');
el.classList = 'game';
el.innerHTML = `<img loading="lazy" src="${game.image}"><h3>${game.name}</h3>`;
document.querySelector('.games').appendChild(el);
const image = document.createElement('img');
image.src = game.image;
image.loading = 'lazy';
image.onerror = () => image.src = '/assets/img/logo.png';
el.appendChild(image);
const name = document.createElement('h3');
name.textContent = game.name;
el.appendChild(name);
effects.hoverTilt({
max: 8,
perspective: 1000,
+13 -6
View File
@@ -1,4 +1,4 @@
import { createViewPage, isValidURL, getVH, CrossTabCommunication, PolarisError } from './utils.js';
import { createViewPage, isValidURL, getVH, CrossTabCommunication, PolarisError, storage } from './utils.js';
import { loadSettings, loadSidebarInterface } from './settings.js';
import loadEasterEggs from './eastereggs.js';
import Search from './search.js';
@@ -21,15 +21,17 @@ ctcClient.on('open', (connection) => {
ctcClient.brodcast('hello from ' + location.href);
}, 1000);*/
onbeforeunload = (e) => {
const settingsStorage = storage('settings');
window.addEventListener('beforeunload', (e) => {
document.body.style.opacity = '0.7';
if (localStorage.getItem('prevent_close') === 'true') {
if (settingsStorage.get('prevent_close')) {
e.preventDefault();
return e;
}
}
});
/*await navigator.serviceWorker.register('/assets/js/offline.js', {
scope: '/'
@@ -37,10 +39,15 @@ onbeforeunload = (e) => {
window.addEventListener('DOMContentLoaded', () => setTimeout(() => document.body.style.opacity = 1, 1000));
document.querySelectorAll('a').forEach(hyperlink => hyperlink.addEventListener('click', (e) => {
document.querySelectorAll('a').forEach(hyperlink => hyperlink.addEventListener('click', async (e) => {
if (hyperlink.dataset.action === 'no_redirect') e.preventDefault();
else if (hyperlink.href && !hyperlink.target && new URL(hyperlink.href).pathname !== location.pathname) {
else if (hyperlink.href && hyperlink.target !== '_blank' && new URL(hyperlink.href).pathname !== location.pathname) {
e.preventDefault();
/*if (new URL(hyperlink.href).host === location.host) {
new DOM(await (await fetch(hyperlink.href)).text());
}*/
document.body.style.opacity = '0.7';
setTimeout(() => window.location.href = hyperlink.href, 500);
+7
View File
@@ -6,9 +6,12 @@ import Theme from './themes.js';
const settingsStorage = storage('settings');
const loadSidebarInterface = () => {
if (settingsStorage.get('prevent_close')) document.querySelector('#prevent_close').checked = Boolean(settingsStorage.get('prevent_close'));
if (settingsStorage.get('panic_key')) document.querySelector('#panic_key').value = settingsStorage.get('panic_key');
if (settingsStorage.get('panic_url')) document.querySelector('#panic_url').value = settingsStorage.get('panic_url');
document.querySelector('#prevent_close').addEventListener('change', () => settingsStorage.set('prevent_close', document.querySelector('#prevent_close').checked));
if (settingsStorage.get('cloak')) {
document.querySelector('#cloak_select').value = settingsStorage.get('cloak');
@@ -352,6 +355,10 @@ const loadSettings = () => {
else new PolarisError('A panic key was used but no url was found.');
}
}
/*if (new URLSearchParams(location.search).get('clickoff')) {
}*/
};
export default { loadSettings, loadSidebarInterface };
+29 -33
View File
@@ -14,25 +14,27 @@ class CrossTabCommunication extends EventEmitter {
// Worker stuff
this.worker.worker.addEventListener('message', async ({ data: message }) => {
if (this.worker.handlers[message.action]) this.worker.respond(message.transactionID, await this.worker.handlers[message.action](message.data));
if (message.action === 'ready') await this.worker.response(this.worker.send('init', {
});
this.worker.handleRequest('init', (message) => {
return {
id: this.id
}));
};
});
this.worker.handleRequest('localstorage', (data) => localStorage[data.action](...data.params));
this.worker.handleRequest('eval', (data) => eval(data));
localStorage.setItem('ctc_' + this.id, 'open');
window.addEventListener('beforeunload', (e) => {
this.registrar.registrationData = localStorage.getItem('ctc_registration') ? JSON.parse(localStorage.getItem('ctc_registration')) : {};
delete this.registrar.registrationData[this.id];
this.registrar.registrationData = {
...this.registrar.registrationData,
...localStorage.getItem('ctc_registration') ? JSON.parse(localStorage.getItem('ctc_registration')) : {}
};
localStorage.setItem('ctc_registration', JSON.stringify(this.registrar.registrationData));
console.log('a');
});
Object.keys(localStorage).forEach(key => {
@@ -40,14 +42,11 @@ class CrossTabCommunication extends EventEmitter {
this.registrationData = localStorage.getItem('ctc_registration') ? JSON.parse(localStorage.getItem('ctc_registration')) : {};
if (key.includes('>')) {
if (!Object.keys(this.registrationData).includes(key.replace('ctc_', '').split('>')[0]) || Object.keys(this.registrationData).includes(key.replace('ctc_', '').split('>')[1])) {
if (!Object.keys(this.registrationData).includes(key.replace('ctc_', '').split('>')[0]) || Object.keys(this.registrationData).includes(key.replace('ctc_', '').split('>')[1])) delete this.registrationData[Object.keys(this.registrationData)[key]];
else if (!Object.keys(this.registrationData).includes(key.replace('ctc_', '').split('>')[1])) delete this.registrationData[Object.keys(this.registrationData)[key]];
} else if (!Object.keys(this.registrationData).includes(key.replace('ctc_', ''))) delete this.registrationData[Object.keys(this.registrationData)[key]];
} else if (!Object.keys(this.registrationData).includes(key.replace('ctc_', '').split('>')[1])) {
}
} else if (!Object.keys(this.registrationData).includes(key.replace('ctc_', ''))) {
}
}
});
}
@@ -311,25 +310,24 @@ class Worker extends EventEmitter {
if (this.handlers[message.action]) this.respond(message.transactionID, await this.handlers[message.action](message.data));
});
this.handleRequest('init', () => new Promise((resolve, reject) => {
/**
* @type {number}
*/
this.id = message.id;
this.response(this.send('init'))
.then(message => {
/**
* @type {number}
*/
this.id = message.id;
console.log(this.id);
console.log(this.id);
this.listen(this.id, 'public')
.then((listener) => listener.on('message', (message) => {
if (message.startsWith('ctc:connection:')) {
const connection = this.interfaceConnection(message.replace('ctc:connection:', ''));
this.listen(this.id, 'public')
.then((listener) => listener.on('message', (message) => {
if (message.startsWith('ctc:connection:')) {
const connection = this.interfaceConnection(message.replace('ctc:connection:', ''));
this.emit('open', connection);
}
}));
}));
this.send('ready');
this.emit('open', connection);
}
}));
});
}
localStorage = {
@@ -401,8 +399,6 @@ class Worker extends EventEmitter {
* @returns {{ on: (event: 'message' | 'disconnect', callback: (...any) => any) => {}, once: (event: 'message' | 'disconnect', callback: (...any) => any) => {}, addEventListener: (event: 'message' | 'disconnect', callback: (...any) => any) => {}, disconnect: () => {} }}
*/
listen = async (remoteID, type) => {
console.log(await this.localStorage.getItem(type === 'private' ? 'ctc_connection' + this.id + '>' + remoteID : 'ctc_' + remoteID));
if (await this.channelExists(remoteID, type)) {
const channel = type === 'private' ? 'ctc_connection' + this.id + '>' + remoteID : 'ctc_' + remoteID;
var prev = await this.localStorage.getItem(channel);
@@ -452,7 +448,7 @@ class Worker extends EventEmitter {
/**
* Get a response
* @param {string} transactionID The transaction id
* @returns {any}
* @returns {Promise}
*/
response = (transactionID) => new Promise((resolve, reject) => {
const listener = this.on('message', (message) => {
+1 -3
View File
@@ -2,6 +2,4 @@ import { Worker } from './ctc.js';
const worker = new Worker();
addEventListener('message', ({ data: message }) => worker.emit('message', message));
console.log(await worker.localStorage.getItem('settings'));
addEventListener('message', ({ data: message }) => worker.emit('message', message));
+1 -1
View File
@@ -19,7 +19,7 @@
<div class="container centered">
<h1 class="title">Proxy</h1>
<text class="proxyDescription">You can search anything.</text>
<text class="proxyDescription">Access the World Wide Web with no restrictions</text>
<form id="wpf">
<input class="proxyinput" type="text" id="query" placeholder="URL or Search Query" />
+9 -2
View File
@@ -54,12 +54,19 @@
<option value="dynamic" disabled>Dynamic</option>
</select>
<h3>Prevent close</h3>
<h2>Export/Import Data</h2>
<div class="switch">
<input type="checkbox" id="prevent_close">
<span class="slider"></span>
</div>
<h3 style="margin-top: 0px;">Export/Import Data</h3>
<small id="export_error"></small>
<br>
<div>
<button class="settings-button nomargin" id="export">Export</button>
<button class="settings-button nomargin" id="import">Import</button>