mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-07 16:17:20 +02:00
28 lines
673 B
TypeScript
Executable File
28 lines
673 B
TypeScript
Executable File
import { CE } from "@utils/html";
|
|
|
|
|
|
export function localRedirect(path: string) {
|
|
const url = window.location.href.substring(0, 31) + path;
|
|
|
|
const $pageContent = document.getElementById('PageContent');
|
|
if (!$pageContent) {
|
|
return;
|
|
}
|
|
|
|
const $anchor = CE('a', {
|
|
href: url,
|
|
class: 'bx-hidden bx-offscreen',
|
|
}, '');
|
|
$anchor.addEventListener('click', e => {
|
|
// Remove element after clicking on it
|
|
window.setTimeout(() => {
|
|
$pageContent.removeChild($anchor);
|
|
}, 1000);
|
|
});
|
|
|
|
$pageContent.appendChild($anchor);
|
|
$anchor.click();
|
|
}
|
|
|
|
window.localRedirect = localRedirect;
|