diff options
Diffstat (limited to 'src/content')
32 files changed, 145 insertions, 145 deletions
diff --git a/src/content/Application.ts b/src/content/Application.ts index 1677655..cfa01fd 100644 --- a/src/content/Application.ts +++ b/src/content/Application.ts @@ -111,7 +111,7 @@ export default class Application { } }); - let inputDriver = new InputDriver(window.document.body); + const inputDriver = new InputDriver(window.document.body); inputDriver.onKey(key => this.followKeyController.press(key)); inputDriver.onKey(key => this.markKeyController.press(key)); inputDriver.onKey(key => this.keymapController.press(key)); diff --git a/src/content/InputDriver.ts b/src/content/InputDriver.ts index bc184d2..cf28205 100644 --- a/src/content/InputDriver.ts +++ b/src/content/InputDriver.ts @@ -25,7 +25,7 @@ const modifiedKeyName = (name: string): string => { // visible for testing export const keyFromKeyboardEvent = (e: KeyboardEvent): Key => { - let key = modifiedKeyName(e.key); + const key = modifiedKeyName(e.key); let shift = e.shiftKey; if (key.length === 1 && key.toUpperCase() === key.toLowerCase()) { // make shift false for symbols to enable key bindings by symbold keys. @@ -83,7 +83,7 @@ export default class InputDriver { // eslint-disable-next-line max-statements private capture(e: KeyboardEvent) { - let target = e.target; + const target = e.target; if (!(target instanceof HTMLElement)) { return; } @@ -98,9 +98,9 @@ export default class InputDriver { return; } - let key = keyFromKeyboardEvent(e); - for (let listener of this.onKeyListeners) { - let stop = listener(key); + const key = keyFromKeyboardEvent(e); + for (const listener of this.onKeyListeners) { + const stop = listener(key); if (stop) { e.preventDefault(); e.stopPropagation(); diff --git a/src/content/MessageListener.ts b/src/content/MessageListener.ts index d035825..e1f7c75 100644 --- a/src/content/MessageListener.ts +++ b/src/content/MessageListener.ts @@ -9,7 +9,7 @@ export default class MessageListener { listener: (msg: Message, sender: Window) => void, ) { window.addEventListener('message', (event: MessageEvent) => { - let sender = event.source; + const sender = event.source; if (!(sender instanceof Window)) { return; } diff --git a/src/content/client/FindClient.ts b/src/content/client/FindClient.ts index af0b427..8b2aca4 100644 --- a/src/content/client/FindClient.ts +++ b/src/content/client/FindClient.ts @@ -8,7 +8,7 @@ export default interface FindClient { export class FindClientImpl implements FindClient { async getGlobalLastKeyword(): Promise<string | null> { - let keyword = await browser.runtime.sendMessage({ + const keyword = await browser.runtime.sendMessage({ type: messages.FIND_GET_KEYWORD, }); return keyword as string; diff --git a/src/content/client/SettingClient.ts b/src/content/client/SettingClient.ts index fc62720..f89f3cd 100644 --- a/src/content/client/SettingClient.ts +++ b/src/content/client/SettingClient.ts @@ -7,7 +7,7 @@ export default interface SettingClient { export class SettingClientImpl { async load(): Promise<Settings> { - let settings = await browser.runtime.sendMessage({ + const settings = await browser.runtime.sendMessage({ type: messages.SETTINGS_QUERY, }); return Settings.fromJSON(settings); diff --git a/src/content/controllers/AddonEnabledController.ts b/src/content/controllers/AddonEnabledController.ts index bae95bf..59b45fa 100644 --- a/src/content/controllers/AddonEnabledController.ts +++ b/src/content/controllers/AddonEnabledController.ts @@ -12,7 +12,7 @@ export default class AddonEnabledController { getAddonEnabled( _message: messages.AddonEnabledQueryMessage, ): Promise<boolean> { - let enabled = this.addonEnabledUseCase.getEnabled(); + const enabled = this.addonEnabledUseCase.getEnabled(); return Promise.resolve(enabled); } } diff --git a/src/content/controllers/KeymapController.ts b/src/content/controllers/KeymapController.ts index 452e3d4..f9c2545 100644 --- a/src/content/controllers/KeymapController.ts +++ b/src/content/controllers/KeymapController.ts @@ -32,7 +32,7 @@ export default class KeymapController { // eslint-disable-next-line complexity, max-lines-per-function press(key: Key): boolean { - let nextOp = this.keymapUseCase.nextOps(key); + const nextOp = this.keymapUseCase.nextOps(key); if (nextOp === null) { return false; } diff --git a/src/content/controllers/SettingController.ts b/src/content/controllers/SettingController.ts index e1c7f01..9124188 100644 --- a/src/content/controllers/SettingController.ts +++ b/src/content/controllers/SettingController.ts @@ -14,9 +14,9 @@ export default class SettingController { async initSettings(): Promise<void> { try { - let current = await this.settingUseCase.reload(); - let url = new URL(window.location.href); - let disabled = current.blacklist.includesEntireBlacklist(url); + const current = await this.settingUseCase.reload(); + const url = new URL(window.location.href); + const disabled = current.blacklist.includesEntireBlacklist(url); if (disabled) { this.addonEnabledUseCase.disable(); } else { diff --git a/src/content/domains/KeySequence.ts b/src/content/domains/KeySequence.ts index 4534b60..cf59125 100644 --- a/src/content/domains/KeySequence.ts +++ b/src/content/domains/KeySequence.ts @@ -38,7 +38,7 @@ export default class KeySequence { if (nonDigitAt === -1) { nonDigitAt = this.keys.length; } - let digits = this.keys.slice(0, nonDigitAt) + const digits = this.keys.slice(0, nonDigitAt) .map(key => key.key) .join(''); return Number(digits); @@ -53,7 +53,7 @@ export default class KeySequence { } splitNumericPrefix(): [KeySequence, KeySequence] { - let nonDigitIndex = this.keys.findIndex(key => !key.isDigit()); + const nonDigitIndex = this.keys.findIndex(key => !key.isDigit()); if (nonDigitIndex === -1) { return [this, new KeySequence([])]; } @@ -73,7 +73,7 @@ export default class KeySequence { let nextPos = 1; if (remaining.startsWith('<')) { - let ltPos = remaining.indexOf('>'); + const ltPos = remaining.indexOf('>'); if (ltPos > 0) { nextPos = ltPos + 1; } @@ -85,7 +85,7 @@ export default class KeySequence { ); }; - let data = fromMapKeysRecursive(keys, []); + const data = fromMapKeysRecursive(keys, []); return new KeySequence(data); } } diff --git a/src/content/hint-key-producer.ts b/src/content/hint-key-producer.ts index 935394e..3c9482f 100644 --- a/src/content/hint-key-producer.ts +++ b/src/content/hint-key-producer.ts @@ -19,14 +19,14 @@ export default class HintKeyProducer { } private increment(): void { - let max = this.charset.length - 1; + const max = this.charset.length - 1; if (this.counter.every(x => x === max)) { this.counter = new Array(this.counter.length + 1).fill(0); return; } this.counter.reverse(); - let len = this.charset.length; + const len = this.charset.length; let num = this.counter.reduce((x, y, index) => x + y * len ** index) + 1; for (let i = 0; i < this.counter.length; ++i) { this.counter[i] = num % len; diff --git a/src/content/index.ts b/src/content/index.ts index 5b9b92c..176a157 100644 --- a/src/content/index.ts +++ b/src/content/index.ts @@ -11,10 +11,10 @@ if (window.self === window.top) { } try { - let app = container.resolve(Application); + const app = container.resolve(Application); app.run(); } catch (e) { console.error(e); } -let style = window.document.createElement('style'); +const style = window.document.createElement('style'); style.textContent = consoleFrameStyle; window.document.head.appendChild(style); diff --git a/src/content/presenters/ConsoleFramePresenter.ts b/src/content/presenters/ConsoleFramePresenter.ts index 62db2bb..63c78fb 100644 --- a/src/content/presenters/ConsoleFramePresenter.ts +++ b/src/content/presenters/ConsoleFramePresenter.ts @@ -6,7 +6,7 @@ export default interface ConsoleFramePresenter { export class ConsoleFramePresenterImpl implements ConsoleFramePresenter { initialize(): void { - let iframe = document.createElement('iframe'); + const iframe = document.createElement('iframe'); iframe.src = browser.runtime.getURL('build/console.html'); iframe.id = 'vimvixen-console-frame'; iframe.className = 'vimvixen-console-frame'; @@ -14,7 +14,7 @@ export class ConsoleFramePresenterImpl implements ConsoleFramePresenter { } blur(): void { - let ele = document.getElementById('vimvixen-console-frame'); + const ele = document.getElementById('vimvixen-console-frame'); if (!ele) { throw new Error('console frame not created'); } diff --git a/src/content/presenters/FindPresenter.ts b/src/content/presenters/FindPresenter.ts index f171d2f..98d8088 100644 --- a/src/content/presenters/FindPresenter.ts +++ b/src/content/presenters/FindPresenter.ts @@ -26,13 +26,13 @@ declare var window: MyWindow; export class FindPresenterImpl implements FindPresenter { find(keyword: string, backwards: boolean): boolean { - let caseSensitive = false; - let wrapScan = true; + const caseSensitive = false; + const wrapScan = true; // NOTE: aWholeWord dows not implemented, and aSearchInFrames does not work // because of same origin policy - let found = window.find(keyword, caseSensitive, backwards, wrapScan); + const found = window.find(keyword, caseSensitive, backwards, wrapScan); if (found) { return found; } @@ -42,7 +42,7 @@ export class FindPresenterImpl implements FindPresenter { } clearSelection(): void { - let sel = window.getSelection(); + const sel = window.getSelection(); if (sel) { sel.removeAllRanges(); } diff --git a/src/content/presenters/FocusPresenter.ts b/src/content/presenters/FocusPresenter.ts index 7e20cd6..842c41e 100644 --- a/src/content/presenters/FocusPresenter.ts +++ b/src/content/presenters/FocusPresenter.ts @@ -6,10 +6,10 @@ export default interface FocusPresenter { export class FocusPresenterImpl implements FocusPresenter { focusFirstElement(): boolean { - let inputTypes = ['email', 'number', 'search', 'tel', 'text', 'url']; - let inputSelector = inputTypes.map(type => `input[type=${type}]`).join(','); - let targets = window.document.querySelectorAll(inputSelector + ',textarea'); - let target = Array.from(targets).find(doms.isVisible); + const inputTypes = ['email', 'number', 'search', 'tel', 'text', 'url']; + const inputSelector = inputTypes.map(type => `input[type=${type}]`).join(','); + const targets = window.document.querySelectorAll(inputSelector + ',textarea'); + const target = Array.from(targets).find(doms.isVisible); if (target instanceof HTMLInputElement) { target.focus(); return true; diff --git a/src/content/presenters/FollowPresenter.ts b/src/content/presenters/FollowPresenter.ts index 0132621..fef8140 100644 --- a/src/content/presenters/FollowPresenter.ts +++ b/src/content/presenters/FollowPresenter.ts @@ -23,12 +23,12 @@ const inViewport = ( viewSize: Size, framePosition: Point, ): boolean => { - let { + const { top, left, bottom, right } = doms.viewportRect(element); - let doc = win.document; - let frameWidth = doc.documentElement.clientWidth; - let frameHeight = doc.documentElement.clientHeight; + const doc = win.document; + const frameWidth = doc.documentElement.clientWidth; + const frameHeight = doc.documentElement.clientHeight; if (right < 0 || bottom < 0 || top > frameHeight || left > frameWidth) { // out of frame @@ -47,10 +47,10 @@ const isAriaHiddenOrAriaDisabled = (win: Window, element: Element): boolean => { if (!element || win.document.documentElement === element) { return false; } - for (let attr of ['aria-hidden', 'aria-disabled']) { - let value = element.getAttribute(attr); + for (const attr of ['aria-hidden', 'aria-disabled']) { + const value = element.getAttribute(attr); if (value !== null) { - let hidden = value.toLowerCase(); + const hidden = value.toLowerCase(); if (hidden === '' || hidden === 'true') { return true; } @@ -79,15 +79,15 @@ export class FollowPresenterImpl implements FollowPresenter { } getTargetCount(viewSize: Size, framePosition: Point): number { - let targets = this.getTargets(viewSize, framePosition); + const targets = this.getTargets(viewSize, framePosition); return targets.length; } createHints(viewSize: Size, framePosition: Point, tags: string[]): void { - let targets = this.getTargets(viewSize, framePosition); - let min = Math.min(targets.length, tags.length); + const targets = this.getTargets(viewSize, framePosition); + const min = Math.min(targets.length, tags.length); for (let i = 0; i < min; ++i) { - let target = targets[i]; + const target = targets[i]; if (target instanceof HTMLAnchorElement || target instanceof HTMLAreaElement) { this.hints.push(new LinkHint(target, tags[i])); @@ -98,8 +98,8 @@ export class FollowPresenterImpl implements FollowPresenter { } filterHints(prefix: string): void { - let shown = this.hints.filter(h => h.getTag().startsWith(prefix)); - let hidden = this.hints.filter(h => !h.getTag().startsWith(prefix)); + const shown = this.hints.filter(h => h.getTag().startsWith(prefix)); + const hidden = this.hints.filter(h => !h.getTag().startsWith(prefix)); shown.forEach(h => h.show()); hidden.forEach(h => h.hide()); @@ -115,9 +115,9 @@ export class FollowPresenterImpl implements FollowPresenter { } private getTargets(viewSize: Size, framePosition: Point): HTMLElement[] { - let all = window.document.querySelectorAll(TARGET_SELECTOR); - let filtered = Array.prototype.filter.call(all, (element: HTMLElement) => { - let style = window.getComputedStyle(element); + const all = window.document.querySelectorAll(TARGET_SELECTOR); + const filtered = Array.prototype.filter.call(all, (element: HTMLElement) => { + const style = window.getComputedStyle(element); // AREA's 'display' in Browser style is 'none' return (element.tagName === 'AREA' || style.display !== 'none') && diff --git a/src/content/presenters/Hint.ts b/src/content/presenters/Hint.ts index 60c0f4c..44b8185 100644 --- a/src/content/presenters/Hint.ts +++ b/src/content/presenters/Hint.ts @@ -6,7 +6,7 @@ interface Point { } const hintPosition = (element: Element): Point => { - let { left, top, right, bottom } = doms.viewportRect(element); + const { left, top, right, bottom } = doms.viewportRect(element); if (element.tagName !== 'AREA') { return { x: left, y: top }; @@ -26,15 +26,15 @@ export default abstract class Hint { constructor(target: HTMLElement, tag: string) { this.tag = tag; - let doc = target.ownerDocument; + const doc = target.ownerDocument; if (doc === null) { throw new TypeError('ownerDocument is null'); } - let { x, y } = hintPosition(target); - let { scrollX, scrollY } = window; + const { x, y } = hintPosition(target); + const { scrollX, scrollY } = window; - let hint = doc.createElement('span'); + const hint = doc.createElement('span'); hint.className = 'vimvixen-hint'; hint.textContent = tag; hint.style.left = x + scrollX + 'px'; @@ -95,7 +95,7 @@ export class InputHint extends Hint { } activate(): void { - let target = this.target; + const target = this.target; switch (target.tagName.toLowerCase()) { case 'input': switch ((target as HTMLInputElement).type) { diff --git a/src/content/presenters/NavigationPresenter.ts b/src/content/presenters/NavigationPresenter.ts index 11d96ec..951e62a 100644 --- a/src/content/presenters/NavigationPresenter.ts +++ b/src/content/presenters/NavigationPresenter.ts @@ -49,7 +49,7 @@ export class NavigationPresenterImpl implements NavigationPresenter { // Code common to linkPrev and linkNext which navigates to the specified page. private linkRel(rel: 'prev' | 'next'): void { - let link = selectLast<HTMLLinkElement>(`link[rel~=${rel}][href]`); + const link = selectLast<HTMLLinkElement>(`link[rel~=${rel}][href]`); if (link) { window.location.href = link.href; return; @@ -57,7 +57,7 @@ export class NavigationPresenterImpl implements NavigationPresenter { const pattern = REL_PATTERN[rel]; - let a = selectLast<HTMLAnchorElement>(`a[rel~=${rel}][href]`) || + const a = selectLast<HTMLAnchorElement>(`a[rel~=${rel}][href]`) || // `innerText` is much slower than `textContent`, but produces much better // (i.e. less unexpected) results selectLast('a[href]', lnk => pattern.test(lnk.innerText)); diff --git a/src/content/presenters/ScrollPresenter.ts b/src/content/presenters/ScrollPresenter.ts index e83f172..387ab62 100644 --- a/src/content/presenters/ScrollPresenter.ts +++ b/src/content/presenters/ScrollPresenter.ts @@ -8,7 +8,7 @@ let scrolling = false; let lastTimeoutId: number | null = null; const isScrollableStyle = (element: Element): boolean => { - let { overflowX, overflowY } = window.getComputedStyle(element); + const { overflowX, overflowY } = window.getComputedStyle(element); return !(overflowX !== 'scroll' && overflowX !== 'auto' && overflowY !== 'scroll' && overflowY !== 'auto'); }; @@ -27,9 +27,9 @@ const findScrollable = (element: Element): Element | null => { return element; } - let children = Array.from(element.children).filter(doms.isVisible); - for (let child of children) { - let scrollable = findScrollable(child); + const children = Array.from(element.children).filter(doms.isVisible); + for (const child of children) { + const scrollable = findScrollable(child); if (scrollable) { return scrollable; } @@ -44,7 +44,7 @@ const scrollTarget = () => { if (isOverflowed(window.document.body)) { return window.document.body; } - let target = findScrollable(window.document.documentElement); + const target = findScrollable(window.document.documentElement); if (target) { return target; } @@ -79,8 +79,8 @@ class Scroller { } scrollBy(x: number, y: number): void { - let left = this.element.scrollLeft + x; - let top = this.element.scrollTop + y; + const left = this.element.scrollLeft + x; + const top = this.element.scrollTop + y; this.scrollTo(left, top); } @@ -110,12 +110,12 @@ export default interface ScrollPresenter { export class ScrollPresenterImpl { getScroll(): Point { - let target = scrollTarget(); + const target = scrollTarget(); return { x: target.scrollLeft, y: target.scrollTop }; } scrollVertically(count: number, smooth: boolean): void { - let target = scrollTarget(); + const target = scrollTarget(); let delta = SCROLL_DELTA_Y * count; if (scrolling) { delta = SCROLL_DELTA_Y * count * 4; @@ -124,7 +124,7 @@ export class ScrollPresenterImpl { } scrollHorizonally(count: number, smooth: boolean): void { - let target = scrollTarget(); + const target = scrollTarget(); let delta = SCROLL_DELTA_X * count; if (scrolling) { delta = SCROLL_DELTA_X * count * 4; @@ -133,8 +133,8 @@ export class ScrollPresenterImpl { } scrollPages(count: number, smooth: boolean): void { - let target = scrollTarget(); - let height = target.clientHeight; + const target = scrollTarget(); + const height = target.clientHeight; let delta = height * count; if (scrolling) { delta = height * count; @@ -143,35 +143,35 @@ export class ScrollPresenterImpl { } scrollTo(x: number, y: number, smooth: boolean): void { - let target = scrollTarget(); + const target = scrollTarget(); new Scroller(target, smooth).scrollTo(x, y); } scrollToTop(smooth: boolean): void { - let target = scrollTarget(); - let x = target.scrollLeft; - let y = 0; + const target = scrollTarget(); + const x = target.scrollLeft; + const y = 0; new Scroller(target, smooth).scrollTo(x, y); } scrollToBottom(smooth: boolean): void { - let target = scrollTarget(); - let x = target.scrollLeft; - let y = target.scrollHeight; + const target = scrollTarget(); + const x = target.scrollLeft; + const y = target.scrollHeight; new Scroller(target, smooth).scrollTo(x, y); } scrollToHome(smooth: boolean): void { - let target = scrollTarget(); - let x = 0; - let y = target.scrollTop; + const target = scrollTarget(); + const x = 0; + const y = target.scrollTop; new Scroller(target, smooth).scrollTo(x, y); } scrollToEnd(smooth: boolean): void { - let target = scrollTarget(); - let x = target.scrollWidth; - let y = target.scrollTop; + const target = scrollTarget(); + const x = target.scrollWidth; + const y = target.scrollTop; new Scroller(target, smooth).scrollTo(x, y); } } diff --git a/src/content/repositories/AddonEnabledRepository.ts b/src/content/repositories/AddonEnabledRepository.ts index 7921bdb..ce3f521 100644 --- a/src/content/repositories/AddonEnabledRepository.ts +++ b/src/content/repositories/AddonEnabledRepository.ts @@ -1,4 +1,4 @@ -let enabled: boolean = false; +let enabled = false; export default interface AddonEnabledRepository { set(on: boolean): void; diff --git a/src/content/repositories/ClipboardRepository.ts b/src/content/repositories/ClipboardRepository.ts index a046851..8219835 100644 --- a/src/content/repositories/ClipboardRepository.ts +++ b/src/content/repositories/ClipboardRepository.ts @@ -6,7 +6,7 @@ export default interface ClipboardRepository { export class ClipboardRepositoryImpl { read(): string { - let textarea = window.document.createElement('textarea'); + const textarea = window.document.createElement('textarea'); window.document.body.append(textarea); textarea.style.position = 'fixed'; @@ -14,8 +14,8 @@ export class ClipboardRepositoryImpl { textarea.contentEditable = 'true'; textarea.focus(); - let ok = window.document.execCommand('paste'); - let value = textarea.textContent!!; + const ok = window.document.execCommand('paste'); + const value = textarea.textContent!!; textarea.remove(); if (!ok) { @@ -26,7 +26,7 @@ export class ClipboardRepositoryImpl { } write(text: string): void { - let input = window.document.createElement('input'); + const input = window.document.createElement('input'); window.document.body.append(input); input.style.position = 'fixed'; @@ -34,7 +34,7 @@ export class ClipboardRepositoryImpl { input.value = text; input.select(); - let ok = window.document.execCommand('copy'); + const ok = window.document.execCommand('copy'); input.remove(); if (!ok) { diff --git a/src/content/repositories/MarkKeyRepository.ts b/src/content/repositories/MarkKeyRepository.ts index 0b24af2..18c3e23 100644 --- a/src/content/repositories/MarkKeyRepository.ts +++ b/src/content/repositories/MarkKeyRepository.ts @@ -17,7 +17,7 @@ interface Mode { jumpMode: boolean; } -let current: Mode = { +const current: Mode = { setMode: false, jumpMode: false, }; diff --git a/src/content/repositories/MarkRepository.ts b/src/content/repositories/MarkRepository.ts index 678abc4..afa980a 100644 --- a/src/content/repositories/MarkRepository.ts +++ b/src/content/repositories/MarkRepository.ts @@ -14,7 +14,7 @@ export class MarkRepositoryImpl implements MarkRepository { } get(key: string): Mark | null { - let v = saved[key]; + const v = saved[key]; if (!v) { return null; } diff --git a/src/content/usecases/AddonEnabledUseCase.ts b/src/content/usecases/AddonEnabledUseCase.ts index 2d6fa11..608a401 100644 --- a/src/content/usecases/AddonEnabledUseCase.ts +++ b/src/content/usecases/AddonEnabledUseCase.ts @@ -23,7 +23,7 @@ export default class AddonEnabledUseCase { } async toggle(): Promise<void> { - let current = this.repository.get(); + const current = this.repository.get(); await this.setEnabled(!current); } diff --git a/src/content/usecases/ClipboardUseCase.ts b/src/content/usecases/ClipboardUseCase.ts index c8fe719..7f16f68 100644 --- a/src/content/usecases/ClipboardUseCase.ts +++ b/src/content/usecases/ClipboardUseCase.ts @@ -16,16 +16,16 @@ export default class ClipboardUseCase { } async yankCurrentURL(): Promise<string> { - let url = window.location.href; + const url = window.location.href; this.repository.write(url); await this.consoleClient.info('Yanked ' + url); return Promise.resolve(url); } async openOrSearch(newTab: boolean): Promise<void> { - let search = this.settingRepository.get().search; - let text = this.repository.read(); - let url = urls.searchUrl(text, search); + const search = this.settingRepository.get().search; + const text = this.repository.read(); + const url = urls.searchUrl(text, search); // TODO: Repeat pasting from clipboard instead of opening a certain url. // 'Repeat last' command is implemented in the background script and cannot diff --git a/src/content/usecases/FindUseCase.ts b/src/content/usecases/FindUseCase.ts index 88b516c..c6a478f 100644 --- a/src/content/usecases/FindUseCase.ts +++ b/src/content/usecases/FindUseCase.ts @@ -19,7 +19,7 @@ export default class FindUseCase { if (keyword) { this.saveKeyword(keyword); } else { - let lastKeyword = await this.getKeyword(); + const lastKeyword = await this.getKeyword(); if (!lastKeyword) { return this.showNoLastKeywordError(); } @@ -39,11 +39,11 @@ export default class FindUseCase { private async findNextPrev( backwards: boolean, ): Promise<void> { - let keyword = await this.getKeyword(); + const keyword = await this.getKeyword(); if (!keyword) { return this.showNoLastKeywordError(); } - let found = this.presenter.find(keyword, backwards); + const found = this.presenter.find(keyword, backwards); if (found) { this.consoleClient.info('Pattern found: ' + keyword); } else { diff --git a/src/content/usecases/FollowMasterUseCase.ts b/src/content/usecases/FollowMasterUseCase.ts index 7d7e875..0e7f394 100644 --- a/src/content/usecases/FollowMasterUseCase.ts +++ b/src/content/usecases/FollowMasterUseCase.ts @@ -28,24 +28,24 @@ export default class FollowMasterUseCase { } startFollow(newTab: boolean, background: boolean): void { - let hintchars = this.settingRepository.get().properties.hintchars; + const hintchars = this.settingRepository.get().properties.hintchars; this.producer = new HintKeyProducer(hintchars); this.followKeyRepository.clearKeys(); this.followMasterRepository.setCurrentFollowMode(newTab, background); - let viewWidth = window.top.innerWidth; - let viewHeight = window.top.innerHeight; + const viewWidth = window.top.innerWidth; + const viewHeight = window.top.innerHeight; this.followSlaveClientFactory.create(window.top).requestHintCount( { width: viewWidth, height: viewHeight }, { x: 0, y: 0 }, ); - let frameElements = window.document.querySelectorAll('iframe'); + const frameElements = window.document.querySelectorAll('iframe'); for (let i = 0; i < frameElements.length; ++i) { - let ele = frameElements[i] as HTMLFrameElement | HTMLIFrameElement; - let { left: frameX, top: frameY } = ele.getBoundingClientRect(); - let client = this.followSlaveClientFactory.create(ele.contentWindow!!); + const ele = frameElements[i] as HTMLFrameElement | HTMLIFrameElement; + const { left: frameX, top: frameY } = ele.getBoundingClientRect(); + const client = this.followSlaveClientFactory.create(ele.contentWindow!!); client.requestHintCount( { width: viewWidth, height: viewHeight }, { x: frameX, y: frameY }, @@ -55,28 +55,28 @@ export default class FollowMasterUseCase { // eslint-disable-next-line max-statements createSlaveHints(count: number, sender: Window): void { - let produced = []; + const produced = []; for (let i = 0; i < count; ++i) { - let tag = this.producer!!.produce(); + const tag = this.producer!!.produce(); produced.push(tag); this.followMasterRepository.addTag(tag); } - let doc = window.document; - let viewWidth = window.innerWidth || doc.documentElement.clientWidth; - let viewHeight = window.innerHeight || doc.documentElement.clientHeight; + const doc = window.document; + const viewWidth = window.innerWidth || doc.documentElement.clientWidth; + const viewHeight = window.innerHeight || doc.documentElement.clientHeight; let pos = { x: 0, y: 0 }; if (sender !== window) { - let frameElements = window.document.querySelectorAll('iframe'); - let ele = Array.from(frameElements).find(e => e.contentWindow === sender); + const frameElements = window.document.querySelectorAll('iframe'); + const ele = Array.from(frameElements).find(e => e.contentWindow === sender); if (!ele) { // elements of the sender is gone return; } - let { left: frameX, top: frameY } = ele.getBoundingClientRect(); + const { left: frameX, top: frameY } = ele.getBoundingClientRect(); pos = { x: frameX, y: frameY }; } - let client = this.followSlaveClientFactory.create(sender); + const client = this.followSlaveClientFactory.create(sender); client.createHints( { width: viewWidth, height: viewHeight }, pos, @@ -100,8 +100,8 @@ export default class FollowMasterUseCase { activate(tag: string): void { this.followMasterRepository.clearTags(); - let newTab = this.followMasterRepository.getCurrentNewTabMode(); - let background = this.followMasterRepository.getCurrentBackgroundMode(); + const newTab = this.followMasterRepository.getCurrentNewTabMode(); + const background = this.followMasterRepository.getCurrentBackgroundMode(); this.broadcastToSlaves((client) => { client.activateIfExists(tag, newTab, background); client.clearHints(); @@ -125,8 +125,8 @@ export default class FollowMasterUseCase { this.followKeyRepository.pushKey(key); - let tag = this.getCurrentTag(); - let matched = this.followMasterRepository.getTagsByPrefix(tag); + const tag = this.getCurrentTag(); + const matched = this.followMasterRepository.getTagsByPrefix(tag); if (matched.length === 0) { this.cancelFollow(); } else if (matched.length === 1) { @@ -137,9 +137,9 @@ export default class FollowMasterUseCase { } private broadcastToSlaves(handler: (client: FollowSlaveClient) => void) { - let allFrames = [window.self].concat(Array.from(window.frames as any)); - let clients = allFrames.map(w => this.followSlaveClientFactory.create(w)); - for (let client of clients) { + const allFrames = [window.self].concat(Array.from(window.frames as any)); + const clients = allFrames.map(w => this.followSlaveClientFactory.create(w)); + for (const client of clients) { handler(client); } } diff --git a/src/content/usecases/FollowSlaveUseCase.ts b/src/content/usecases/FollowSlaveUseCase.ts index d471adb..fb805b9 100644 --- a/src/content/usecases/FollowSlaveUseCase.ts +++ b/src/content/usecases/FollowSlaveUseCase.ts @@ -34,7 +34,7 @@ export default class FollowSlaveUseCase { } countTargets(viewSize: Size, framePosition: Point): void { - let count = this.presenter.getTargetCount(viewSize, framePosition); + const count = this.presenter.getTargetCount(viewSize, framePosition); this.followMasterClient.responseHintCount(count); } @@ -56,13 +56,13 @@ export default class FollowSlaveUseCase { } async activate(tag: string, newTab: boolean, background: boolean) { - let hint = this.presenter.getHint(tag); + const hint = this.presenter.getHint(tag); if (!hint) { return; } if (hint instanceof LinkHint) { - let url = hint.getLink(); + const url = hint.getLink(); let openNewTab = newTab; // Open link by background script in order to prevent a popup block if (hint.getLinkTarget() === '_blank') { diff --git a/src/content/usecases/HintKeyProducer.ts b/src/content/usecases/HintKeyProducer.ts index 241cd56..68f3fbd 100644 --- a/src/content/usecases/HintKeyProducer.ts +++ b/src/content/usecases/HintKeyProducer.ts @@ -19,14 +19,14 @@ export default class HintKeyProducer { } private increment(): void { - let max = this.charset.length - 1; + const max = this.charset.length - 1; if (this.counter.every(x => x === max)) { this.counter = new Array(this.counter.length + 1).fill(0); return; } this.counter.reverse(); - let len = this.charset.length; + const len = this.charset.length; let num = this.counter.reduce((x, y, index) => x + y * len ** index) + 1; for (let i = 0; i < this.counter.length; ++i) { this.counter[i] = num % len; diff --git a/src/content/usecases/KeymapUseCase.ts b/src/content/usecases/KeymapUseCase.ts index a2e7cc3..074de72 100644 --- a/src/content/usecases/KeymapUseCase.ts +++ b/src/content/usecases/KeymapUseCase.ts @@ -37,17 +37,17 @@ export default class KeymapUseCase { // eslint-disable-next-line max-statements nextOps(key: Key): { repeat: number, op: operations.Operation } | null { - let sequence = this.repository.enqueueKey(key); - let baseSequence = sequence.trimNumericPrefix(); + const sequence = this.repository.enqueueKey(key); + const baseSequence = sequence.trimNumericPrefix(); if (baseSequence.length() === 1 && this.blacklistKey(key)) { // ignore if the input starts with black list keys this.repository.clear(); return null; } - let keymaps = this.keymapEntityMap(); - let matched = keymaps.filter(([seq]) => seq.startsWith(sequence)); - let baseMatched = keymaps.filter(([seq]) => seq.startsWith(baseSequence)); + const keymaps = this.keymapEntityMap(); + const matched = keymaps.filter(([seq]) => seq.startsWith(sequence)); + const baseMatched = keymaps.filter(([seq]) => seq.startsWith(baseSequence)); if (matched.length === 1 && sequence.length() === matched[0][0].length()) { @@ -71,7 +71,7 @@ export default class KeymapUseCase { } private keymapEntityMap(): [KeySequence, operations.Operation][] { - let keymaps = this.settingRepository.get().keymaps.combine(reservedKeymaps); + const keymaps = this.settingRepository.get().keymaps.combine(reservedKeymaps); let entries = keymaps.entries().map( ([keys, op]) => [KeySequence.fromMapKeys(keys), op] ) as [KeySequence, operations.Operation][]; @@ -86,8 +86,8 @@ export default class KeymapUseCase { } private blacklistKey(key: Key): boolean { - let url = this.addressRepository.getCurrentURL(); - let blacklist = this.settingRepository.get().blacklist; + const url = this.addressRepository.getCurrentURL(); + const blacklist = this.settingRepository.get().blacklist; return blacklist.includeKey(url, key); } } diff --git a/src/content/usecases/MarkUseCase.ts b/src/content/usecases/MarkUseCase.ts index a7d5ad8..8cd0c72 100644 --- a/src/content/usecases/MarkUseCase.ts +++ b/src/content/usecases/MarkUseCase.ts @@ -17,7 +17,7 @@ export default class MarkUseCase { } async set(key: string): Promise<void> { - let pos = this.scrollPresenter.getScroll(); + const pos = this.scrollPresenter.getScroll(); if (this.globalKey(key)) { this.client.setGloablMark(key, pos); await this.consoleClient.info(`Set global mark to '${key}'`); @@ -31,7 +31,7 @@ export default class MarkUseCase { if (this.globalKey(key)) { await this.client.jumpGlobalMark(key); } else { - let pos = this.repository.get(key); + const pos = this.repository.get(key); if (!pos) { throw new Error('Mark is not set'); } @@ -40,7 +40,7 @@ export default class MarkUseCase { } scroll(x: number, y: number): void { - let smooth = this.settingRepository.get().properties.smoothscroll; + const smooth = this.settingRepository.get().properties.smoothscroll; this.scrollPresenter.scrollTo(x, y, smooth); } diff --git a/src/content/usecases/ScrollUseCase.ts b/src/content/usecases/ScrollUseCase.ts index 32cbef1..c68c889 100644 --- a/src/content/usecases/ScrollUseCase.ts +++ b/src/content/usecases/ScrollUseCase.ts @@ -11,42 +11,42 @@ export default class ScrollUseCase { } scrollVertically(count: number): void { - let smooth = this.getSmoothScroll(); + const smooth = this.getSmoothScroll(); this.presenter.scrollVertically(count, smooth); } scrollHorizonally(count: number): void { - let smooth = this.getSmoothScroll(); + const smooth = this.getSmoothScroll(); this.presenter.scrollHorizonally(count, smooth); } scrollPages(count: number): void { - let smooth = this.getSmoothScroll(); + const smooth = this.getSmoothScroll(); this.presenter.scrollPages(count, smooth); } scrollToTop(): void { - let smooth = this.getSmoothScroll(); + const smooth = this.getSmoothScroll(); this.presenter.scrollToTop(smooth); } scrollToBottom(): void { - let smooth = this.getSmoothScroll(); + const smooth = this.getSmoothScroll(); this.presenter.scrollToBottom(smooth); } scrollToHome(): void { - let smooth = this.getSmoothScroll(); + const smooth = this.getSmoothScroll(); this.presenter.scrollToHome(smooth); } scrollToEnd(): void { - let smooth = this.getSmoothScroll(); + const smooth = this.getSmoothScroll(); this.presenter.scrollToEnd(smooth); } private getSmoothScroll(): boolean { - let settings = this.settingRepository.get(); + const settings = this.settingRepository.get(); return settings.properties.smoothscroll; } } diff --git a/src/content/usecases/SettingUseCase.ts b/src/content/usecases/SettingUseCase.ts index 4608039..67d1be6 100644 --- a/src/content/usecases/SettingUseCase.ts +++ b/src/content/usecases/SettingUseCase.ts @@ -12,7 +12,7 @@ export default class SettingUseCase { } async reload(): Promise<Settings> { - let settings = await this.client.load(); + const settings = await this.client.load(); this.repository.set(settings); return settings; } |