1
0
mirror of https://github.com/zumbiepig/MineXLauncher.git synced 2025-06-08 09:24:48 +00:00

no about blank

This commit is contained in:
zumbiepig 2024-09-25 15:42:22 -07:00
parent ac63b3f360
commit 372037093e
No known key found for this signature in database
GPG Key ID: 17C891BE28B953DE

View File

@ -110,11 +110,12 @@ const game = {
if (!window.gameWindow || window.gameWindow.closed) { if (!window.gameWindow || window.gameWindow.closed) {
const noPopup = storage.local.get('noPopup'); const noPopup = storage.local.get('noPopup');
window.gameWindow = window.open( window.gameWindow = window.open(
'about:blank', noPopup ? version : 'about:blank',
'_blank', '_blank',
`popup=${noPopup ? 'false' : 'true'}`, `popup=${noPopup ? 'false' : 'true'}`,
); );
if (window.gameWindow) { if (window.gameWindow) {
if (!noPopup) {
window.gameWindow.document.title = 'MineXLauncher'; window.gameWindow.document.title = 'MineXLauncher';
const icon = window.gameWindow.document.createElement('link'); const icon = window.gameWindow.document.createElement('link');
icon.rel = 'icon'; icon.rel = 'icon';
@ -131,7 +132,16 @@ const game = {
iframe.style.border = 'none'; iframe.style.border = 'none';
window.gameWindow.document.body.append(iframe); window.gameWindow.document.body.append(iframe);
if (iframe.contentWindow) { ['keydown', 'keyup'].forEach((eventType) =>
window.gameWindow?.addEventListener(eventType, (event) =>
iframe.contentWindow?.dispatchEvent(
new KeyboardEvent(eventType, event),
),
),
);
window.gameWindowIframe = iframe.contentWindow;
} else window.gameWindowIframe = window.gameWindow;
if (window.gameWindowIframe) {
( (
['debug', 'log', 'info', 'warn', 'error'] as ( ['debug', 'log', 'info', 'warn', 'error'] as (
| 'debug' | 'debug'
@ -141,25 +151,14 @@ const game = {
| 'error' | 'error'
)[] )[]
).forEach((type) => { ).forEach((type) => {
if (iframe.contentWindow) if (window.gameWindowIframe)
iframe.contentWindow.console[type] = (msg: string) => window.gameWindowIframe.console[type] = (msg: string) =>
consoleLog(type, msg); consoleLog(type, msg);
}); });
}
['keydown', 'keyup'].forEach((eventType) =>
window.gameWindow?.addEventListener(eventType, (event) =>
iframe.contentWindow?.dispatchEvent(
new KeyboardEvent(eventType, event),
),
),
);
window.gameWindow.focus(); window.gameWindow.focus();
window.gameWindow.document.documentElement.requestFullscreen(); window.gameWindow.document.documentElement.requestFullscreen();
} }
window.gameWindowIframe = iframe.contentWindow;
}
} else { } else {
window.gameWindow.focus(); window.gameWindow.focus();
const console = document.querySelector( const console = document.querySelector(