diff --git a/static/assets/JSON/apps.json b/static/assets/JSON/apps.json index 8c0fd3d..c0170fa 100644 --- a/static/assets/JSON/apps.json +++ b/static/assets/JSON/apps.json @@ -36,8 +36,8 @@ }, { "name": "Movies/TV", - "image": "https://i.pinimg.com/736x/ea/8d/11/ea8d11f1ffc6355b8a440106ce61d0f3.jpg", - "target": "//movie-web-me.vercel.app/#/search/movie" + "image": "https://avatars.githubusercontent.com/u/121455091", + "target": "https://movie-web.app/" }, { "name": "Paramount+", diff --git a/static/assets/JSON/cheats.json b/static/assets/JSON/cheats.json index e5eaf7b..97ef19a 100644 --- a/static/assets/JSON/cheats.json +++ b/static/assets/JSON/cheats.json @@ -1,7 +1,7 @@ [ { "name": "Blooket", - "target": "/assets/misc/cheats/blooket.html", + "target": "/cdn/cheats/blooket.html", "image": "https://media.discordapp.net/attachments/1118495479802630174/1158062820097802331/latest.png?ex=651ae18c&is=6519900c&hm=544b7a8eb56236327b7bcabfce4b688428d59a63c8e07bcb2aab3ff81c916286&=" }, { @@ -11,12 +11,12 @@ }, { "name": "Wordle", - "target": "/assets/misc/cheats/wordle.html", + "target": "/cdn/cheats/wordle.html", "image": "/cdn/images/wordle.png" }, { "name": "Prodigy", - "target": "/assets/misc/cheats/prodigy.html", + "target": "/cdn/cheats/prodigy.html", "image": "https://webcdn.prodigygame.com/common/images/socialshare.png" }, { @@ -26,7 +26,7 @@ }, { "name": "Quizlet", - "target": "/assets/misc/cheats/quizlet.html", + "target": "/cdn/cheats/quizlet.html", "image": "https://assets.quizlet.com/a/j/dist/app/i/brandmark/1024.38e7be0a829de8f.png" }, { diff --git a/static/assets/JSON/games.json b/static/assets/JSON/games.json index 01f4a89..47bfa1f 100644 --- a/static/assets/JSON/games.json +++ b/static/assets/JSON/games.json @@ -233,7 +233,7 @@ }, { "name": "Friday Night Funkin'", - "target": "/assets/misc/fridaynightfunkin/index.html", + "target": "/cdn/fridaynightfunkin/index.html", "image": "/cdn/images/fnf.png" }, { @@ -243,7 +243,7 @@ }, { "name": "Geometry Dash", - "target": "/assets/misc/geometrydash/index.html", + "target": "/cdn/geometrydash/index.html", "image": "https://upload.wikimedia.org/wikipedia/en/3/35/Geometry_Dash_Logo.PNG" }, { diff --git a/static/assets/js/apps.js b/static/assets/js/apps.js index 1f6a922..62ceaf9 100644 --- a/static/assets/js/apps.js +++ b/static/assets/js/apps.js @@ -1,5 +1,4 @@ -import { createViewPage, isValidURL } from './utils.js'; -import PolarisError from './error.js'; +import { createViewPage, isValidURL, PolarisError } from './utils.js'; import effects from './effects.js'; const load = () => fetch('/api/apps').then(res => res.json()).then(apps => { diff --git a/static/assets/js/cheats.js b/static/assets/js/cheats.js index 064824f..c55df8d 100644 --- a/static/assets/js/cheats.js +++ b/static/assets/js/cheats.js @@ -1,5 +1,4 @@ -import { createViewPage, isValidURL } from './utils.js'; -import PolarisError from './error.js'; +import { createViewPage, isValidURL, PolarisError } from './utils.js'; import effects from './effects.js'; const load = () => fetch('/api/cheats') diff --git a/static/assets/js/games.js b/static/assets/js/games.js index c9f8043..a7fb7e7 100644 --- a/static/assets/js/games.js +++ b/static/assets/js/games.js @@ -1,5 +1,4 @@ -import { createViewPage, isValidURL } from './utils.js'; -import PolarisError from './error.js'; +import { createViewPage, isValidURL, PolarisError } from './utils.js'; import effects from './effects.js'; const load = () => { diff --git a/static/assets/js/main.js b/static/assets/js/main.js index 6e96d0e..1843d53 100644 --- a/static/assets/js/main.js +++ b/static/assets/js/main.js @@ -1,6 +1,5 @@ +import { createViewPage, isValidURL, getVH, CrossTabCommunication, PolarisError } from './utils.js'; import loadEasterEggs from './eastereggs.js'; -import { createViewPage, isValidURL, getVH, CrossTabCommunication } from './utils.js'; -import PolarisError from './error.js'; import Settings from './settings.js'; import Search from './search.js'; import Cheats from './cheats.js'; @@ -17,8 +16,8 @@ ctcClient.on('open', (connection) => { }); }); -setTimeout(() => { - ctcClient.brodcast('a'); +setInterval(() => { + ctcClient.brodcast('hello from ' + location.href); }, 1000);*/ onbeforeunload = (e) => { diff --git a/static/assets/js/settings.js b/static/assets/js/settings.js index f5bc45b..6ac6a83 100644 --- a/static/assets/js/settings.js +++ b/static/assets/js/settings.js @@ -1,6 +1,6 @@ import Dexie from 'https://unpkg.com/dexie@latest/dist/modern/dexie.mjs'; -import { isScrollable, storage, indexedDBExporter, cookie, EventEmitter } from './utils.js'; -import PolarisError from './error.js'; + +import { isScrollable, storage, indexedDBExporter, cookie, EventEmitter, PolarisError } from './utils.js'; import Theme from './themes.js'; const settingsStorage = storage('settings'); diff --git a/static/assets/js/utils.js b/static/assets/js/utils.js index 3d91111..a3d4f1f 100644 --- a/static/assets/js/utils.js +++ b/static/assets/js/utils.js @@ -1,6 +1,7 @@ import indexedDBExporter from './utils/indexeddb.js'; import CrossTabCommunication from './utils/ctc.js'; import EventEmitter from './utils/events.js'; +import PolarisError from './utils/error.js'; import cookie from './utils/cookie.js'; /** @@ -163,7 +164,8 @@ export default { EventEmitter, cookie, uuid, - CrossTabCommunication + CrossTabCommunication, + PolarisError }; export { @@ -180,5 +182,6 @@ export { EventEmitter, cookie, uuid, - CrossTabCommunication + CrossTabCommunication, + PolarisError }; \ No newline at end of file diff --git a/static/assets/js/utils/ctc.js b/static/assets/js/utils/ctc.js index 35c537f..0815a6c 100644 --- a/static/assets/js/utils/ctc.js +++ b/static/assets/js/utils/ctc.js @@ -5,26 +5,27 @@ class CrossTabCommunication extends EventEmitter { constructor() { super(); - this.registrationData = sessionStorage.getItem('ctc_registration') ? JSON.parse(sessionStorage.getItem('ctc_registration')) : {}; + this.registrationData = localStorage.getItem('ctc_registration') ? JSON.parse(localStorage.getItem('ctc_registration')) : {}; + this.openConnections = []; this.id = uuid(); this.registrationData[this.id] = { location: location.href }; - sessionStorage.setItem('ctc_registration', JSON.stringify(this.registrationData)); - sessionStorage.setItem('ctc_' + this.id, 'open'); + localStorage.setItem('ctc_registration', JSON.stringify(this.registrationData)); + localStorage.setItem('ctc_' + this.id, 'open'); window.addEventListener('beforeunload', (e) => { - this.registrationData = sessionStorage.getItem('ctc_registration') ? JSON.parse(sessionStorage.getItem('ctc_registration')) : {}; + this.registrationData = localStorage.getItem('ctc_registration') ? JSON.parse(localStorage.getItem('ctc_registration')) : {}; - if (!Object.keys(this.registrationData).length < 1) { - sessionStorage.setItem('ctc_registration', JSON.stringify(this.registrationData)); - const storage = sessionStorage; + if (!Object.keys(this.registrationData).length < 0) { + localStorage.setItem('ctc_registration', JSON.stringify(this.registrationData)); + const storage = localStorage; - sessionStorage.clear(); + localStorage.clear(); - for (let i = 0; i < Object.keys(storage).filter(data => !data.startsWith('ctc') && data === 'ctc_registration').length; i++) sessionStorage.setItem(Object.keys(storage)[i], storage[Object.keys(storage)[Object.keys(storage)[i]]]); + for (let i = 0; i < Object.keys(storage).filter(data => !data.startsWith('ctc') && data === 'ctc_registration').length; i++) localStorage.setItem(Object.keys(storage)[i], storage[Object.keys(storage)[Object.keys(storage)[i]]]); } }); @@ -44,7 +45,7 @@ class CrossTabCommunication extends EventEmitter { * @param {string} remoteID The remote client id * @returns {boolean} */ - exists = (remoteID) => Object.keys(sessionStorage).includes('ctc_' + remoteID); + exists = (remoteID) => Object.keys(localStorage).includes('ctc_' + remoteID); /** * Check if a channel exists @@ -52,7 +53,7 @@ class CrossTabCommunication extends EventEmitter { * @param {'public' | 'private'} type The type of channel * @returns {boolean} */ - channelExists = (remoteID, type) => Boolean(sessionStorage.getItem(type === 'private' ? 'ctc_connection' + this.id + '>' + remoteID : 'ctc_' + remoteID)) + channelExists = (remoteID, type) => Boolean(localStorage.getItem(type === 'private' ? 'ctc_connection' + this.id + '>' + remoteID : 'ctc_' + remoteID)) /** * Listen for messages on a channel @@ -63,15 +64,15 @@ class CrossTabCommunication extends EventEmitter { listen = (remoteID, type) => { if (this.channelExists(remoteID, type)) { const channel = type === 'private' ? 'ctc_connection' + this.id + '>' + remoteID : 'ctc_' + remoteID; - var prev = sessionStorage.getItem(channel); + var prev = localStorage.getItem(channel); const events = new EventEmitter(); const listener = setInterval(() => { - if (sessionStorage.getItem(channel)) { - if (prev !== sessionStorage.getItem(channel)) { - prev = sessionStorage.getItem(channel); + if (localStorage.getItem(channel)) { + if (prev !== localStorage.getItem(channel)) { + prev = localStorage.getItem(channel); - events.emit('message', sessionStorage.getItem(channel)); + events.emit('message', localStorage.getItem(channel)); } } else { clearInterval(listener); @@ -86,7 +87,11 @@ class CrossTabCommunication extends EventEmitter { events.emit('disconnect'); } }; - } else throw new Error('Invalid channel'); + } else { + console.log(remoteID, type); + + throw new Error('Invalid channel'); + } } /** @@ -96,7 +101,8 @@ class CrossTabCommunication extends EventEmitter { */ connect = (remoteID) => { if (this.exists(remoteID)) { - sessionStorage.setItem('ctc_' + remoteID, 'ctc:connection:' + this.id); + localStorage.setItem('ctc_' + remoteID, 'ctc:connection:' + this.id); + localStorage.setItem('ctc_connection' + this.id + '>' + remoteID, 'p[em'); const channel = 'ctc_connection' + this.id + '>' + remoteID; const listener = this.listen(remoteID, 'private'); @@ -105,7 +111,7 @@ class CrossTabCommunication extends EventEmitter { listener.on('message', (message) => { if (message === 'ctc:disconnect') { - sessionStorage.setItem(channel, ''); + localStorage.setItem(channel, ''); events.emit('disconnect'); clearInterval(listener); @@ -114,7 +120,7 @@ class CrossTabCommunication extends EventEmitter { return; } - events.emit('message', sessionStorage.getItem(channel)); + events.emit('message', localStorage.getItem(channel)); }); listener.on('disconnect', () => { @@ -126,13 +132,13 @@ class CrossTabCommunication extends EventEmitter { return { ...events, send: (data) => { - if (connected) sessionStorage.setItem(channel, data); + if (connected) localStorage.setItem(channel, data); else throw new Error('Not connected to channel'); }, disconnect: () => { if (connected) { listener.disconnect(); - sessionStorage.setItem(channel, 'ctc:disconnect'); + localStorage.setItem(channel, 'ctc:disconnect'); } else throw new Error('Not connected to channel'); } }; @@ -153,7 +159,7 @@ class CrossTabCommunication extends EventEmitter { listener.on('message', (message) => { if (message === 'ctc:disconnect') { - sessionStorage.setItem(channel, ''); + localStorage.setItem(channel, ''); events.emit('disconnect'); clearInterval(listener); @@ -162,7 +168,7 @@ class CrossTabCommunication extends EventEmitter { return; } - events.emit('message', sessionStorage.getItem(channel)); + events.emit('message', localStorage.getItem(channel)); }); listener.on('disconnect', () => { @@ -174,13 +180,13 @@ class CrossTabCommunication extends EventEmitter { return { ...events, send: (data) => { - if (connected) sessionStorage.setItem(channel, data); + if (connected) localStorage.setItem(channel, data); else throw new Error('Not connected to channel'); }, disconnect: () => { if (connected) { listener.disconnect(); - sessionStorage.setItem(channel, 'ctc:disconnect'); + localStorage.setItem(channel, 'ctc:disconnect'); } else throw new Error('Not connected to channel'); }, /** @@ -199,9 +205,11 @@ class CrossTabCommunication extends EventEmitter { } brodcast = (message) => { - this.registrationData = sessionStorage.getItem('ctc_registration') ? JSON.parse(sessionStorage.getItem('ctc_registration')) : {}; + this.registrationData = localStorage.getItem('ctc_registration') ? JSON.parse(localStorage.getItem('ctc_registration')) : {}; - Object.keys(this.registrationData).forEach(remoteClient => this.connect(remoteClient).send(message)); + Object.keys(this.registrationData) + .filter(data => data !== this.id) + .forEach(remoteClient => this.connect(remoteClient).send(message)); } } diff --git a/static/assets/js/error.js b/static/assets/js/utils/error.js similarity index 98% rename from static/assets/js/error.js rename to static/assets/js/utils/error.js index c5397c2..ac723c5 100644 --- a/static/assets/js/error.js +++ b/static/assets/js/utils/error.js @@ -1,7 +1,7 @@ class PolarisError { constructor(e) { console.log(e); - + let notificationContainer = document.querySelector('.notifications'); if (!notificationContainer) { @@ -48,3 +48,4 @@ window.console.error = (...e) => new PolarisError(e); window.onmessageerror = (...e) => new PolarisError(e); export default PolarisError; +export { PolarisError };