mirror of
https://github.com/zumbiepig/MineXLauncher.git
synced 2025-06-26 10:05:10 +00:00
MineXLauncher 1.4
This commit is contained in:
28
src/resources/scripts/eagler-launch/1.5.2/main.ts
Normal file
28
src/resources/scripts/eagler-launch/1.5.2/main.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-nocheck
|
||||
window.addEventListener('load', function () {
|
||||
const relayId = Math.floor(Math.random() * 3);
|
||||
window.eaglercraftOpts = {
|
||||
container: 'game_frame',
|
||||
assetsURI: 'assets.epk',
|
||||
serverWorkerURI: 'worker_bootstrap.js',
|
||||
worldsFolder: 'MAIN',
|
||||
servers: [
|
||||
{ serverName: 'BrickMC', serverAddress: 'wss://play.brickmc.net', hideAddress: false },
|
||||
],
|
||||
relays: [
|
||||
{ addr: 'wss://relay.deev.is/', name: 'lax1dude relay #1', primary: relayId == 0 },
|
||||
{ addr: 'wss://relay.lax1dude.net/', name: 'lax1dude relay #2', primary: relayId == 1 },
|
||||
{ addr: 'wss://relay.shhnowisnottheti.me/', name: 'ayunami relay #1', primary: relayId == 2 },
|
||||
],
|
||||
mainMenu: { splashes: ['Darviglet!', 'eaglerenophile!', 'You Eagler!', 'Yeeeeeee!', 'yeee', 'EEEEEEEEE!', 'You Darvig!', 'You Vigg!', ':>', '|>', 'You Yumpster!'], eaglerLogo: false },
|
||||
};
|
||||
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const server = urlParams.get('server');
|
||||
if (server) {
|
||||
window.eaglercraftOpts.joinServer = server;
|
||||
}
|
||||
|
||||
main();
|
||||
});
|
||||
688
src/resources/scripts/eagler-launch/1.8.8/eaglermobile-ef.ts
Normal file
688
src/resources/scripts/eagler-launch/1.8.8/eaglermobile-ef.ts
Normal file
File diff suppressed because one or more lines are too long
1156
src/resources/scripts/eagler-launch/1.8.8/eaglerpocketmobile.ts
Normal file
1156
src/resources/scripts/eagler-launch/1.8.8/eaglerpocketmobile.ts
Normal file
File diff suppressed because it is too large
Load Diff
25
src/resources/scripts/eagler-launch/1.8.8/main.ts
Normal file
25
src/resources/scripts/eagler-launch/1.8.8/main.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-nocheck
|
||||
window.addEventListener('load', () => {
|
||||
const relayId = Math.floor(Math.random() * 3);
|
||||
window.eaglercraftXOpts = {
|
||||
container: 'game_frame',
|
||||
assetsURI: 'assets.epk',
|
||||
servers: [
|
||||
{ addr: 'wss://electronmc.club', name: 'Electron Network' },
|
||||
{ addr: 'wss://play.brickmc.net', name: 'BrickMC' },
|
||||
],
|
||||
relays: [
|
||||
{ addr: 'wss://relay.deev.is/', comment: 'lax1dude relay #1', primary: relayId == 0 },
|
||||
{ addr: 'wss://relay.lax1dude.net/', comment: 'lax1dude relay #2', primary: relayId == 1 },
|
||||
{ addr: 'wss://relay.shhnowisnottheti.me/', comment: 'ayunami relay #1', primary: relayId == 2 },
|
||||
],
|
||||
};
|
||||
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const server = urlParams.get('server');
|
||||
if (server) {
|
||||
window.eaglercraftXOpts.joinServer = server;
|
||||
}
|
||||
main();
|
||||
});
|
||||
29
src/resources/scripts/eagler-launch/1.9.4/main.ts
Normal file
29
src/resources/scripts/eagler-launch/1.9.4/main.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-nocheck
|
||||
window.addEventListener('load', () => {
|
||||
const relayId = Math.floor(Math.random() * 3);
|
||||
window.eaglercraftXOpts = {
|
||||
container: 'game_frame',
|
||||
assetsURI: 'assets.epk',
|
||||
servers: [{ addr: 'wss://eagler.xyz', name: 'TemuzX' }],
|
||||
relays: [
|
||||
{ addr: 'wss://relay.deev.is/', comment: 'lax1dude relay #1', primary: relayId == 0 },
|
||||
{ addr: 'wss://relay.lax1dude.net/', comment: 'lax1dude relay #2', primary: relayId == 1 },
|
||||
{ addr: 'wss://relay.shhnowisnottheti.me/', comment: 'ayunami relay #1', primary: relayId == 2 },
|
||||
],
|
||||
};
|
||||
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const server = urlParams.get('server');
|
||||
const mobile = urlParams.get('mobile');
|
||||
if (server) {
|
||||
window.eaglercraftXOpts.joinServer = server;
|
||||
}
|
||||
if (mobile === 'true') {
|
||||
const script = document.createElement('script');
|
||||
script.src = '/resources/scripts/mobile/eaglerpocketmobile.user.js';
|
||||
document.head.appendChild(script);
|
||||
}
|
||||
|
||||
main();
|
||||
});
|
||||
13
src/resources/scripts/eagler-launch/b1.3/main.ts
Normal file
13
src/resources/scripts/eagler-launch/b1.3/main.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-nocheck
|
||||
window.addEventListener('load', function () {
|
||||
window.minecraftOpts = ['game_frame', 'assets.epk'];
|
||||
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const server = urlParams.get('server');
|
||||
if (server) {
|
||||
window.minecraftOpts.push(s);
|
||||
}
|
||||
|
||||
main();
|
||||
});
|
||||
13
src/resources/scripts/google-tag.ts
Normal file
13
src/resources/scripts/google-tag.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-nocheck
|
||||
const script = document.createElement('script');
|
||||
script.async = true;
|
||||
script.src = 'https://www.googletagmanager.com/gtag/js?id=G-972V2NZ2ZK';
|
||||
document.head.appendChild(script);
|
||||
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(...args: unknown[]) {
|
||||
dataLayer.push(...args);
|
||||
}
|
||||
gtag('js', new Date());
|
||||
gtag('config', 'G-972V2NZ2ZK');
|
||||
@@ -1,29 +1,28 @@
|
||||
let selectedVersion: string | undefined;
|
||||
const launcherVersion = '1.4';
|
||||
|
||||
const theme = {
|
||||
load() {
|
||||
if (window.location.pathname === '/mobile/') {
|
||||
const link = document.createElement('link');
|
||||
link.rel = 'stylesheet';
|
||||
link.href = '/resources/styles/mobile.css';
|
||||
document.head.appendChild(link);
|
||||
}
|
||||
const setTheme = cookie.get('minexlauncher.theme');
|
||||
if (setTheme === null) {
|
||||
theme.set('default');
|
||||
} else if (setTheme !== 'default') {
|
||||
const link = document.createElement('link');
|
||||
link.rel = 'stylesheet';
|
||||
link.href = `/resources/styles/${setTheme}.css`;
|
||||
document.head.appendChild(link);
|
||||
load: function (themeToLoad?: string) {
|
||||
const themeElement = document.getElementById('theme') as HTMLLinkElement;
|
||||
if (themeElement) {
|
||||
if (themeToLoad) {
|
||||
themeElement.href = `/resources/styles/themes/${themeToLoad}.css`;
|
||||
} else {
|
||||
const savedTheme = storage.local.get('theme');
|
||||
if (savedTheme !== null) {
|
||||
themeElement.href = `/resources/styles/themes/${savedTheme}.css`;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
set(setTheme: string) {
|
||||
cookie.set('minexlauncher.theme', setTheme, 30);
|
||||
window.location.reload();
|
||||
set: function (newTheme: string) {
|
||||
storage.local.set('theme', newTheme);
|
||||
theme.load();
|
||||
},
|
||||
};
|
||||
|
||||
const versionSelector = {
|
||||
open() {
|
||||
open: function () {
|
||||
const customOptions = document.querySelector('.custom-options');
|
||||
const customSelect = document.querySelector('.custom-select');
|
||||
if (customOptions && customSelect) {
|
||||
@@ -31,7 +30,7 @@ const versionSelector = {
|
||||
customSelect.classList.add('open');
|
||||
}
|
||||
},
|
||||
close() {
|
||||
close: function () {
|
||||
const customOptions = document.querySelector('.custom-options');
|
||||
const customSelect = document.querySelector('.custom-select');
|
||||
if (customOptions && customSelect) {
|
||||
@@ -39,7 +38,7 @@ const versionSelector = {
|
||||
customSelect.classList.remove('open');
|
||||
}
|
||||
},
|
||||
toggle() {
|
||||
toggle: function () {
|
||||
const customOptions = document.querySelector('.custom-options');
|
||||
const customSelect = document.querySelector('.custom-select');
|
||||
if (customOptions && customSelect) {
|
||||
@@ -50,13 +49,11 @@ const versionSelector = {
|
||||
};
|
||||
|
||||
const game = {
|
||||
play(version?: string) {
|
||||
play: function (version?: string) {
|
||||
if (version) {
|
||||
embed.remove();
|
||||
// @ts-expect-error 123
|
||||
window.top.location.href = version;
|
||||
} else if (selectedVersion) {
|
||||
embed.remove();
|
||||
// @ts-expect-error 123
|
||||
window.top.location.href = selectedVersion;
|
||||
} else {
|
||||
@@ -64,7 +61,7 @@ const game = {
|
||||
return;
|
||||
}
|
||||
},
|
||||
select(path: string, name: string) {
|
||||
select: function (path: string, name?: string) {
|
||||
selectedVersion = path;
|
||||
const selector = document.querySelector('.custom-select');
|
||||
if (selector?.textContent) {
|
||||
@@ -76,7 +73,7 @@ const game = {
|
||||
}
|
||||
versionSelector.close();
|
||||
},
|
||||
archive(client: string) {
|
||||
archive: function (client: string) {
|
||||
const clients: Record<string, string> = {
|
||||
'1.8': '18-client-version',
|
||||
'1.5': '15-client-version',
|
||||
@@ -90,137 +87,211 @@ const game = {
|
||||
},
|
||||
};
|
||||
|
||||
const embed = {
|
||||
create() {
|
||||
const iframe = document.createElement('iframe');
|
||||
iframe.id = 'iframe-container';
|
||||
iframe.style.position = 'fixed';
|
||||
iframe.style.top = '0';
|
||||
iframe.style.left = '0';
|
||||
iframe.style.width = '100%';
|
||||
iframe.style.height = '100%';
|
||||
iframe.style.border = 'none';
|
||||
if (isMobile()) {
|
||||
iframe.src = '/mobile/';
|
||||
} else {
|
||||
iframe.src = '/home/';
|
||||
}
|
||||
document.body.appendChild(iframe);
|
||||
},
|
||||
remove() {
|
||||
const iframe = window.top?.document.getElementById('iframe-container');
|
||||
iframe?.remove();
|
||||
},
|
||||
};
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const navigate = {
|
||||
home: {
|
||||
game() {
|
||||
window.location.href = '/home/game/';
|
||||
game: function () {
|
||||
const navUrl = '/home/game/';
|
||||
storage.session.set('lastPage', navUrl);
|
||||
window.location.href = navUrl;
|
||||
},
|
||||
clients() {
|
||||
window.location.href = '/home/clients/';
|
||||
clients: function () {
|
||||
const navUrl = '/home/clients/';
|
||||
storage.session.set('lastPage', navUrl);
|
||||
window.location.href = navUrl;
|
||||
},
|
||||
archive() {
|
||||
window.location.href = '/home/archive/';
|
||||
archive: function () {
|
||||
const navUrl = '/home/archive/';
|
||||
storage.session.set('lastPage', navUrl);
|
||||
window.location.href = navUrl;
|
||||
},
|
||||
downloads() {
|
||||
window.location.href = '/home/downloads/';
|
||||
downloads: function () {
|
||||
const navUrl = '/home/downloads/';
|
||||
storage.session.set('lastPage', navUrl);
|
||||
window.location.href = navUrl;
|
||||
},
|
||||
},
|
||||
mods: {
|
||||
client() {
|
||||
window.location.href = '/mods/client/';
|
||||
client: function () {
|
||||
const navUrl = '/mods/client/';
|
||||
storage.session.set('lastPage', navUrl);
|
||||
window.location.href = navUrl;
|
||||
},
|
||||
mods() {
|
||||
window.location.href = '/mods/mods/';
|
||||
mods: function () {
|
||||
const navUrl = '/mods/mods/';
|
||||
storage.session.set('lastPage', navUrl);
|
||||
window.location.href = navUrl;
|
||||
},
|
||||
resourcepacks() {
|
||||
window.location.href = '/mods/resourcepacks/';
|
||||
resourcepacks: function () {
|
||||
const navUrl = '/mods/resourcepacks/';
|
||||
storage.session.set('lastPage', navUrl);
|
||||
window.location.href = navUrl;
|
||||
},
|
||||
},
|
||||
mobile() {
|
||||
window.location.href = '/mobile/';
|
||||
mobile: function () {
|
||||
const navUrl = '/mobile/';
|
||||
storage.session.set('lastPage', navUrl);
|
||||
window.location.href = navUrl;
|
||||
},
|
||||
updates() {
|
||||
window.location.href = '/updates/';
|
||||
updates: function () {
|
||||
const navUrl = '/updates/';
|
||||
storage.session.set('lastPage', navUrl);
|
||||
window.location.href = navUrl;
|
||||
},
|
||||
servers() {
|
||||
window.location.href = '/servers/';
|
||||
servers: function () {
|
||||
const navUrl = '/servers/';
|
||||
storage.session.set('lastPage', navUrl);
|
||||
window.location.href = navUrl;
|
||||
},
|
||||
settings() {
|
||||
window.location.href = '/settings/';
|
||||
settings: function () {
|
||||
const navUrl = '/settings/';
|
||||
storage.session.set('lastPage', navUrl);
|
||||
window.location.href = navUrl;
|
||||
},
|
||||
};
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const cookie = {
|
||||
get(key: string): string | null {
|
||||
for (const cookie of document.cookie.replaceAll('; ', ';').split(';')) {
|
||||
const cookiePair = cookie.split('=');
|
||||
if (encodeURIComponent(key) === cookiePair[0]) {
|
||||
return decodeURIComponent(cookiePair[1]);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
set(key: string, value: string, days: number) {
|
||||
set: function (key: string, value: string, days: number) {
|
||||
let maxAge;
|
||||
if (days) {
|
||||
maxAge = days * 60 * 60 * 24;
|
||||
} else {
|
||||
maxAge = 31536000;
|
||||
}
|
||||
document.cookie = `${encodeURIComponent(key)}=${encodeURIComponent(value)}; max-age=${maxAge}; path=/; secure`;
|
||||
document.cookie = `${encodeURIComponent(key)}=${encodeURIComponent(value)}; Max-Age=${maxAge}; Path=/; SameSite=Lax; Secure`;
|
||||
},
|
||||
delete(key: string) {
|
||||
document.cookie = `${encodeURIComponent(key)}=; max-age=0; path=/`;
|
||||
get: function (key: string): string | null {
|
||||
for (const cookie of document.cookie.split('; ')) {
|
||||
const cookiePair = cookie.split('=');
|
||||
if (encodeURIComponent(key) === cookiePair[0]) {
|
||||
// @ts-expect-error 123
|
||||
return decodeURIComponent(cookiePair[1]);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
delete: function (key: string) {
|
||||
document.cookie = `${encodeURIComponent(key)}=; Max-Age=0; Path=/`;
|
||||
},
|
||||
};
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const storage = {
|
||||
local: {
|
||||
get: function (key: string) {
|
||||
const item = localStorage.getItem('minexlauncher');
|
||||
if (item !== null) {
|
||||
const json = JSON.parse(item);
|
||||
if (json[key] !== undefined) {
|
||||
return json[key];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
set: function (key: string, value: string) {
|
||||
let item = localStorage.getItem('minexlauncher');
|
||||
if (item === null) {
|
||||
item = '{}';
|
||||
}
|
||||
const json = JSON.parse(item);
|
||||
json[key] = value;
|
||||
localStorage.setItem('minexlauncher', JSON.stringify(json));
|
||||
},
|
||||
delete: function (key: string) {
|
||||
const item = localStorage.getItem('minexlauncher');
|
||||
if (item !== null) {
|
||||
const json = JSON.parse(item);
|
||||
delete json[key];
|
||||
localStorage.setItem('minexlauncher', JSON.stringify(json));
|
||||
}
|
||||
},
|
||||
},
|
||||
session: {
|
||||
get: function (key: string) {
|
||||
const item = sessionStorage.getItem('minexlauncher');
|
||||
if (item !== null) {
|
||||
const json = JSON.parse(item);
|
||||
if (json[key] !== undefined) {
|
||||
return json[key];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
set: function (key: string, value: string) {
|
||||
let item = sessionStorage.getItem('minexlauncher');
|
||||
if (item === null) {
|
||||
item = '{}';
|
||||
}
|
||||
const json = JSON.parse(item);
|
||||
json[key] = value;
|
||||
sessionStorage.setItem('minexlauncher', JSON.stringify(json));
|
||||
},
|
||||
delete: function (key: string) {
|
||||
const item = sessionStorage.getItem('minexlauncher');
|
||||
if (item !== null) {
|
||||
const json = JSON.parse(item);
|
||||
delete json[key];
|
||||
sessionStorage.setItem('minexlauncher', JSON.stringify(json));
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const query = {
|
||||
get(name: string) {
|
||||
const urlParams = new URLSearchParams(top?.location.search);
|
||||
return urlParams.get(name);
|
||||
get: function (name: string) {
|
||||
return new URLSearchParams(window.top?.location.search).get(name);
|
||||
},
|
||||
};
|
||||
|
||||
function isMobile(): boolean {
|
||||
try {
|
||||
document.exitPointerLock();
|
||||
return /Mobi/i.test(window.navigator.userAgent);
|
||||
} catch (e) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
const detect = {
|
||||
mobile: function (): boolean {
|
||||
try {
|
||||
document.exitPointerLock();
|
||||
return /Mobi/i.test(window.navigator.userAgent);
|
||||
} catch (e) {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
if (window.location.hostname === '0.0.0.0') {
|
||||
navigate;
|
||||
query;
|
||||
if (detect.mobile()) {
|
||||
const link = document.createElement('link');
|
||||
link.rel = 'stylesheet';
|
||||
link.href = '/resources/styles/mobile.css';
|
||||
document.head.appendChild(link);
|
||||
}
|
||||
|
||||
let selectedVersion: string;
|
||||
theme.load();
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const usernameForm = document.getElementById('username-form') as HTMLFormElement;
|
||||
const usernameInput = document.getElementById('username-input') as HTMLInputElement;
|
||||
const profileName = document.getElementById('profile-name');
|
||||
if (window.location.pathname !== '/') {
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const profileName = document.getElementById('profile-name');
|
||||
if (profileName) {
|
||||
profileName.textContent = storage.local.get('username');
|
||||
}
|
||||
});
|
||||
|
||||
const savedUsername = cookie.get('minexlauncher.username');
|
||||
if (profileName && savedUsername) {
|
||||
profileName.textContent = savedUsername;
|
||||
} else if (profileName && !savedUsername) {
|
||||
profileName.textContent = 'Default';
|
||||
}
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const lastVersion = storage.local.get('lastVersion');
|
||||
if (lastVersion !== null && lastVersion < launcherVersion) {
|
||||
alert(`MineXLauncher has been updated to v${launcherVersion}!
|
||||
|
||||
if (profileName && window.location.pathname === '/settings/') {
|
||||
usernameForm.addEventListener('submit', function (event) {
|
||||
event.preventDefault();
|
||||
const username = usernameInput.value.trim();
|
||||
if (username) {
|
||||
cookie.set('minexlauncher.username', username, 30);
|
||||
profileName.textContent = cookie.get('minexlauncher.username');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
Changes in v${launcherVersion}:
|
||||
- Added welcome and setup screen
|
||||
- Show changelog when MineXLauncher is updated
|
||||
- Added themes and backgrounds
|
||||
- Settings now update automatically without saving them
|
||||
- You will now stay on the same page when reloading
|
||||
- Username rules have been updated to match Minecraft
|
||||
- Added Starlike Client`);
|
||||
storage.local.set('lastVersion', launcherVersion);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
modItem.classList.add('mod-item');
|
||||
modItem.innerHTML = `
|
||||
<div class="mod-icon">
|
||||
<img src="${mod.icon}" />
|
||||
<img loading="lazy" src="${mod.icon}" />
|
||||
</div>
|
||||
<div class="mod-details">
|
||||
<h3 class="mod-name">${mod['display-name'] ?? ''}</h3>
|
||||
|
||||
@@ -8,7 +8,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
modItem.classList.add('mod-item');
|
||||
modItem.innerHTML = `
|
||||
<div class="mod-icon">
|
||||
<img src="${mod.icon}" />
|
||||
<img loading="lazy" src="${mod.icon}" />
|
||||
</div>
|
||||
<div class="mod-details">
|
||||
<h3 class="mod-name">${mod['display-name'] ?? ''}</h3>
|
||||
|
||||
64
src/resources/scripts/settings.ts
Normal file
64
src/resources/scripts/settings.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
if (window.location.pathname === '/settings/') {
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const profileName = document.getElementById('profile-name');
|
||||
const usernameInput = document.getElementById('username-input') as HTMLInputElement;
|
||||
const themeSelect = document.getElementById('theme-select') as HTMLSelectElement;
|
||||
|
||||
usernameInput.placeholder = storage.local.get('username') ?? '';
|
||||
themeSelect.value = storage.local.get('theme') ?? '';
|
||||
|
||||
usernameInput.addEventListener('input', function () {
|
||||
let username = usernameInput.value.replace(/[^A-Za-z0-9]/g, '_').substring(0, 16);
|
||||
usernameInput.value = username;
|
||||
while (username.length < 3) {
|
||||
username += '_';
|
||||
}
|
||||
storage.local.set('username', username);
|
||||
if (profileName) {
|
||||
profileName.textContent = username;
|
||||
}
|
||||
});
|
||||
|
||||
themeSelect.addEventListener('change', function () {
|
||||
theme.set(themeSelect.value);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (window.location.pathname === '/welcome.html') {
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const setupForm = document.getElementById('setup-form') as HTMLFormElement;
|
||||
const usernameInput = document.getElementById('username-input') as HTMLInputElement;
|
||||
const themeSelect = document.getElementById('theme-select') as HTMLSelectElement;
|
||||
|
||||
usernameInput.addEventListener('input', function () {
|
||||
const username = usernameInput.value.replace(/[^A-Za-z0-9]/g, '_').substring(0, 16);
|
||||
usernameInput.value = username;
|
||||
});
|
||||
|
||||
themeSelect.addEventListener('change', function () {
|
||||
theme.load(themeSelect.value);
|
||||
});
|
||||
|
||||
setupForm.addEventListener('submit', function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
let username = usernameInput.value.replace(/[^A-Za-z0-9]/g, '_').substring(0, 16);
|
||||
usernameInput.value = username;
|
||||
|
||||
if (!username) {
|
||||
alert('Please type a username.');
|
||||
return;
|
||||
} else {
|
||||
while (username.length < 3) {
|
||||
username += '_';
|
||||
}
|
||||
storage.local.set('username', username);
|
||||
storage.local.set('theme', themeSelect.value);
|
||||
storage.local.set('lastVersion', launcherVersion);
|
||||
// @ts-expect-error 123
|
||||
window.top.location.href = '/';
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user