From 0abb5d8b09d632920c002ffc3af585171fad7e8b Mon Sep 17 00:00:00 2001 From: Haku Date: Fri, 25 Mar 2022 23:34:07 -0400 Subject: [PATCH] adjusted line lengths to be below maximum recommended line length --- src/main.ts | 39 ++++++++++++++++++++++++++------------- src/settings.ts | 15 ++++++++------- 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/src/main.ts b/src/main.ts index 3abea7f..8f58512 100644 --- a/src/main.ts +++ b/src/main.ts @@ -11,7 +11,8 @@ const keybinds: Keybind[] = [ functionName: 'move', displayName: null, callback: () => { - const moveButton: HTMLButtonElement = document.querySelector('button[name=move_region]') as HTMLButtonElement; + const moveButton: HTMLButtonElement = + document.querySelector('button[name=move_region]') as HTMLButtonElement; if (moveButton) moveButton.click(); }, @@ -21,7 +22,8 @@ const keybinds: Keybind[] = [ functionName: 'endorse', displayName: null, callback: () => { - const endorseButton: HTMLButtonElement = (document.querySelector('button[class="endorse button icon wa"]') as HTMLButtonElement); + const endorseButton: HTMLButtonElement = + (document.querySelector('button[class="endorse button icon wa"]') as HTMLButtonElement); if (endorseButton) endorseButton.click(); }, @@ -31,7 +33,8 @@ const keybinds: Keybind[] = [ } else if (urlParams['nation']) { let nationsToEndorse: string[] = await getStorageValue('nationstoendorse'); - const endorseButton: HTMLButtonElement = (document.querySelector('button[class="endorse button icon wa"]') as HTMLButtonElement); + const endorseButton: HTMLButtonElement = + (document.querySelector('button[class="endorse button icon wa"]') as HTMLButtonElement); if (endorseButton && (nationsToEndorse.indexOf(urlParams['nation']) !== -1)) endorseButton.click(); else if (nationsToEndorse.indexOf(urlParams['nation']) !== -1) { @@ -57,7 +60,8 @@ const keybinds: Keybind[] = [ functionName: 'dossier', displayName: null, callback: () => { - const dossierButton: HTMLButtonElement = document.querySelector('button[value=add]') as HTMLButtonElement; + const dossierButton: HTMLButtonElement = + document.querySelector('button[value=add]') as HTMLButtonElement; if (dossierButton) dossierButton.click(); }, @@ -67,7 +71,8 @@ const keybinds: Keybind[] = [ } else if (urlParams['nation']) { let nationsToDossier: string[] = await getStorageValue('nationstodossier'); - const dossierButton: HTMLButtonElement = document.querySelector('button[value=add]') as HTMLButtonElement; + const dossierButton: HTMLButtonElement = + document.querySelector('button[value=add]') as HTMLButtonElement; if (dossierButton && (nationsToDossier.indexOf(urlParams['nation']) !== -1)) dossierButton.click(); else { @@ -81,7 +86,8 @@ const keybinds: Keybind[] = [ } else if (urlParams['page'] === 'dossier') { let nationsToDossier: string[] = await getStorageValue('nationstodossier'); - const currentNation: string = new RegExp('nation=(.+)$').exec((document.querySelector('.info > a') as HTMLAnchorElement).href)[1]; + const currentNation: string = new RegExp('nation=(.+)$') + .exec((document.querySelector('.info > a') as HTMLAnchorElement).href)[1]; const nextNation: string = nationsToDossier[nationsToDossier.indexOf(currentNation) + 1]; if (!nextNation) return; @@ -95,7 +101,8 @@ const keybinds: Keybind[] = [ functionName: 'backtojp', displayName: "Move Back to Jump Point", callback: async () => { - const moveButton: HTMLButtonElement = document.querySelector('button[name=move_region]') as HTMLButtonElement; + const moveButton: HTMLButtonElement = + document.querySelector('button[name=move_region]') as HTMLButtonElement; const jumpPoint: string = await getStorageValue('jp'); if ((urlParams['region'] === jumpPoint) && moveButton) moveButton.click(); @@ -108,11 +115,13 @@ const keybinds: Keybind[] = [ functionName: 'endodel', displayName: "Endorse WA Delegate", callback: () => { - const delegate: HTMLAnchorElement = document.querySelector('#regioncontent > p:nth-child(1) > a') as HTMLAnchorElement; + const delegate: HTMLAnchorElement = + document.querySelector('#regioncontent > p:nth-child(1) > a') as HTMLAnchorElement; if (urlParams['region']) delegate.click(); else if (urlParams['nation']) { - const endorseButton: HTMLButtonElement = (document.querySelector('button[class="endorse button icon wa"]') as HTMLButtonElement); + const endorseButton: HTMLButtonElement = + (document.querySelector('button[class="endorse button icon wa"]') as HTMLButtonElement); if (endorseButton) endorseButton.click(); } @@ -133,8 +142,10 @@ const keybinds: Keybind[] = [ callback: () => { if (urlParams['template-overall']) window.location.href = document.URL.replace('template-overall=none/', ''); - else - window.location.href = `/template-overall=none/${document.URL.replace('https://www.nationstates.net/', '')}`; + else { + window.location.href = `/template-overall=none/ + ${document.URL.replace('https://www.nationstates.net/', '')}`; + } }, modifiedCallback: null }, @@ -164,8 +175,10 @@ const keybinds: Keybind[] = [ functionName: 'regionajax', displayName: "Open Region Ajax2 Page", callback: () => { - if (urlParams['region']) - window.location.href = `/page=ajax2/a=reports/view=region.${urlParams['region']}/filter=move+member+endo`; + if (urlParams['region']) { + window.location.href = + `/page=ajax2/a=reports/view=region.${urlParams['region']}/filter=move+member+endo`; + } }, modifiedCallback: null } diff --git a/src/settings.ts b/src/settings.ts index 60cf160..a4bfcae 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -31,7 +31,8 @@ async function addKeySetter(functionName: string, displayName?: string) setKeyInput.addEventListener('click', async (e: MouseEvent): Promise => { console.log(`Setting ${functionName}`); - const key: string = (document.querySelector(`#${functionName}-key`) as HTMLInputElement).value.toUpperCase(); + const key: string = (document.querySelector(`#${functionName}-key`) as HTMLInputElement).value + .toUpperCase(); await setStorageValue(functionName, key); }); @@ -39,16 +40,14 @@ async function addKeySetter(functionName: string, displayName?: string) const td1: HTMLTableDataCellElement = document.createElement('td'); td1.innerHTML += ``; const td2: HTMLTableDataCellElement = document.createElement('td'); - td2.innerHTML += ``; + td2.innerHTML += + ``; const td3: HTMLTableDataCellElement = document.createElement('td'); td3.appendChild(setKeyInput); tr.appendChild(td1); tr.appendChild(td2); tr.appendChild(td3); document.querySelector('#keys').appendChild(tr); - // This doesn't work apparently - /*document.querySelector('#keys').innerHTML += - ``;*/ } (async () => @@ -63,9 +62,11 @@ async function addKeySetter(functionName: string, displayName?: string) // Other settings (document.querySelector('#jump-point') as HTMLInputElement).value = await getStorageValue('jp'); - document.querySelector('#set-jump-point').addEventListener('click', async (e: MouseEvent): Promise => + document.querySelector('#set-jump-point') + .addEventListener('click', async (e: MouseEvent): Promise => { - const jumpPoint: string = canonicalize((document.querySelector('#jump-point') as HTMLInputElement).value); + const jumpPoint: string = + canonicalize((document.querySelector('#jump-point') as HTMLInputElement).value); await setStorageValue('jp', jumpPoint); }); })(); \ No newline at end of file