|
|
|
@@ -6,6 +6,14 @@ interface Keybind |
|
|
|
modifiedCallback: Function | null; |
|
|
|
} |
|
|
|
|
|
|
|
let notyf = new Notyf({ |
|
|
|
duration: 3000, |
|
|
|
position: { |
|
|
|
x: 'right', |
|
|
|
y: 'top' |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
const keybinds: Keybind[] = [ |
|
|
|
{ |
|
|
|
functionName: 'move', |
|
|
|
@@ -181,6 +189,59 @@ const keybinds: Keybind[] = [ |
|
|
|
} |
|
|
|
}, |
|
|
|
modifiedCallback: null |
|
|
|
}, |
|
|
|
{ |
|
|
|
functionName: 'prep', |
|
|
|
displayName: null, |
|
|
|
callback: async () => |
|
|
|
{ |
|
|
|
const switchers = await getStorageValue('switchers'); |
|
|
|
const password = await getStorageValue('password'); |
|
|
|
const jumpPoint: string = await getStorageValue('jp'); |
|
|
|
const moveButton: HTMLButtonElement = |
|
|
|
document.querySelector('button[name=move_region]') as HTMLButtonElement; |
|
|
|
if (!switchers || !password) |
|
|
|
return; |
|
|
|
const currentSwitcher: number = await getStorageValue('currentswitcher'); |
|
|
|
if (urlParams['page'] === 'un' && urlParams['template-overall'] === 'none') |
|
|
|
(document.querySelector('button[type=submit]') as HTMLButtonElement).click(); |
|
|
|
else if (urlParams['page'] === 'UN_status') { |
|
|
|
const resendButton = document.querySelector('body > p.error > a') as HTMLAnchorElement; |
|
|
|
if (resendButton !== null) |
|
|
|
resendButton.click(); |
|
|
|
else |
|
|
|
window.location.href = `/template-overall=none/region=${jumpPoint}`; |
|
|
|
} |
|
|
|
else if (urlParams['region'] === jumpPoint && moveButton !== null) |
|
|
|
moveButton.click(); |
|
|
|
else if (urlParams['page'] === 'change_region' || (urlParams['region'] && moveButton === null)) { |
|
|
|
if (currentSwitcher === (switchers.length - 1)) { |
|
|
|
await setStorageValue('currentswitcher', 0); |
|
|
|
window.location.href = |
|
|
|
`/template-overall=none/page=un?nation=${switchers[0]}&password=${password}&logging_in=1`; |
|
|
|
} |
|
|
|
else { |
|
|
|
await setStorageValue('currentswitcher', currentSwitcher + 1); |
|
|
|
window.location.href = |
|
|
|
`/template-overall=none/page=un?nation=${switchers[currentSwitcher + 1]}&password=${password}&logging_in=1`; |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
window.location.href = |
|
|
|
`/template-overall=none/page=un?nation=${switchers[currentSwitcher]}&password=${password}&logging_in=1`; |
|
|
|
} |
|
|
|
}, |
|
|
|
modifiedCallback: async () => |
|
|
|
{ |
|
|
|
const switchers = await getStorageValue('switchers'); |
|
|
|
if (urlParams['nation']) { |
|
|
|
const newIndex = switchers.indexOf(urlParams['nation']); |
|
|
|
if (newIndex !== -1) { |
|
|
|
await setStorageValue('currentswitcher', newIndex); |
|
|
|
notyf.success(`Synced index with ${urlParams['nation']}`); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
]; |
|
|
|
|
|
|
|
@@ -213,4 +274,8 @@ document.addEventListener('keyup', (e: KeyboardEvent) => |
|
|
|
await setStorageValue('jp', 'artificial_solar_system'); |
|
|
|
if (await getStorageValue('nationstoendorse') === undefined) |
|
|
|
await setStorageValue('nationstoendorse', []); |
|
|
|
if ((await getStorageValue('switchers') !== undefined) && |
|
|
|
(await getStorageValue('currentswitcher') === undefined)) { |
|
|
|
await setStorageValue('currentswitcher', 0); |
|
|
|
} |
|
|
|
})(); |