aboutsummaryrefslogtreecommitdiff
path: root/src/background/usecases
diff options
context:
space:
mode:
Diffstat (limited to 'src/background/usecases')
-rw-r--r--src/background/usecases/AddonEnabledUseCase.ts2
-rw-r--r--src/background/usecases/CommandUseCase.ts44
-rw-r--r--src/background/usecases/CompletionsUseCase.ts48
-rw-r--r--src/background/usecases/ConsoleUseCase.ts16
-rw-r--r--src/background/usecases/FindUseCase.ts2
-rw-r--r--src/background/usecases/LinkUseCase.ts4
-rw-r--r--src/background/usecases/MarkUseCase.ts10
-rw-r--r--src/background/usecases/NavigateUseCase.ts16
-rw-r--r--src/background/usecases/TabSelectUseCase.ts18
-rw-r--r--src/background/usecases/TabUseCase.ts30
-rw-r--r--src/background/usecases/VersionUseCase.ts4
-rw-r--r--src/background/usecases/ZoomUseCase.ts18
-rw-r--r--src/background/usecases/filters.ts32
-rw-r--r--src/background/usecases/parsers.ts4
14 files changed, 124 insertions, 124 deletions
diff --git a/src/background/usecases/AddonEnabledUseCase.ts b/src/background/usecases/AddonEnabledUseCase.ts
index bb5cd90..9abd3dc 100644
--- a/src/background/usecases/AddonEnabledUseCase.ts
+++ b/src/background/usecases/AddonEnabledUseCase.ts
@@ -27,7 +27,7 @@ export default class AddonEnabledUseCase {
}
async onTabSelected(tabId: number): Promise<void> {
- let enabled = await this.contentMessageClient.getAddonEnabled(tabId);
+ const enabled = await this.contentMessageClient.getAddonEnabled(tabId);
return this.indicatorPresentor.indicate(enabled);
}
}
diff --git a/src/background/usecases/CommandUseCase.ts b/src/background/usecases/CommandUseCase.ts
index d757215..fcb898d 100644
--- a/src/background/usecases/CommandUseCase.ts
+++ b/src/background/usecases/CommandUseCase.ts
@@ -26,7 +26,7 @@ export default class CommandIndicator {
}
async open(keywords: string): Promise<browser.tabs.Tab> {
- let url = await this.urlOrSearch(keywords);
+ const url = await this.urlOrSearch(keywords);
this.repeatUseCase.storeLastOperation({
type: operations.INTERNAL_OPEN_URL,
url,
@@ -35,7 +35,7 @@ export default class CommandIndicator {
}
async tabopen(keywords: string): Promise<browser.tabs.Tab> {
- let url = await this.urlOrSearch(keywords);
+ const url = await this.urlOrSearch(keywords);
this.repeatUseCase.storeLastOperation({
type: operations.INTERNAL_OPEN_URL,
url,
@@ -45,7 +45,7 @@ export default class CommandIndicator {
}
async winopen(keywords: string): Promise<browser.windows.Window> {
- let url = await this.urlOrSearch(keywords);
+ const url = await this.urlOrSearch(keywords);
this.repeatUseCase.storeLastOperation({
type: operations.INTERNAL_OPEN_URL,
url,
@@ -61,8 +61,8 @@ export default class CommandIndicator {
}
if (!isNaN(Number(keywords))) {
- let tabs = await this.tabPresenter.getAll();
- let index = parseInt(keywords, 10) - 1;
+ const tabs = await this.tabPresenter.getAll();
+ const index = parseInt(keywords, 10) - 1;
if (index < 0 || tabs.length <= index) {
throw new RangeError(`tab ${index + 1} does not exist`);
}
@@ -72,19 +72,19 @@ export default class CommandIndicator {
return;
} else if (keywords.trim() === '#') {
// Select last selected window
- let lastId = await this.tabPresenter.getLastSelectedId();
+ const lastId = await this.tabPresenter.getLastSelectedId();
if (typeof lastId === 'undefined' || lastId === null) {
throw new Error('No last selected tab');
}
return this.tabPresenter.select(lastId);
}
- let current = await this.tabPresenter.getCurrent();
- let tabs = await this.tabPresenter.getByKeyword(keywords);
+ const current = await this.tabPresenter.getCurrent();
+ const tabs = await this.tabPresenter.getByKeyword(keywords);
if (tabs.length === 0) {
throw new RangeError('No matching buffer for ' + keywords);
}
- for (let tab of tabs) {
+ for (const tab of tabs) {
if (tab.index > current.index) {
return this.tabPresenter.select(tab.id as number);
}
@@ -93,8 +93,8 @@ export default class CommandIndicator {
}
async bdelete(force: boolean, keywords: string): Promise<any> {
- let excludePinned = !force;
- let tabs = await this.tabPresenter.getByKeyword(keywords, excludePinned);
+ const excludePinned = !force;
+ const tabs = await this.tabPresenter.getByKeyword(keywords, excludePinned);
if (tabs.length === 0) {
throw new Error('No matching buffer for ' + keywords);
} else if (tabs.length > 1) {
@@ -104,27 +104,27 @@ export default class CommandIndicator {
}
async bdeletes(force: boolean, keywords: string): Promise<any> {
- let excludePinned = !force;
- let tabs = await this.tabPresenter.getByKeyword(keywords, excludePinned);
- let ids = tabs.map(tab => tab.id as number);
+ const excludePinned = !force;
+ const tabs = await this.tabPresenter.getByKeyword(keywords, excludePinned);
+ const ids = tabs.map(tab => tab.id as number);
return this.tabPresenter.remove(ids);
}
async quit(): Promise<any> {
- let tab = await this.tabPresenter.getCurrent();
+ const tab = await this.tabPresenter.getCurrent();
return this.tabPresenter.remove([tab.id as number]);
}
async quitAll(): Promise<any> {
- let tabs = await this.tabPresenter.getAll();
- let ids = tabs.map(tab => tab.id as number);
+ const tabs = await this.tabPresenter.getAll();
+ const ids = tabs.map(tab => tab.id as number);
this.tabPresenter.remove(ids);
}
async addbookmark(title: string): Promise<any> {
- let tab = await this.tabPresenter.getCurrent();
- let item = await this.bookmarkRepository.create(title, tab.url as string);
- let message = 'Saved current page: ' + item.url;
+ const tab = await this.tabPresenter.getCurrent();
+ const item = await this.bookmarkRepository.create(title, tab.url as string);
+ const message = 'Saved current page: ' + item.url;
return this.consoleClient.showInfo(tab.id as number, message);
}
@@ -132,7 +132,7 @@ export default class CommandIndicator {
if (keywords.length === 0) {
return;
}
- let [name, value] = parsers.parseSetOption(keywords);
+ const [name, value] = parsers.parseSetOption(keywords);
await this.settingRepository.setProperty(name, value);
return this.contentMessageClient.broadcastSettingsChanged();
@@ -143,7 +143,7 @@ export default class CommandIndicator {
}
private async urlOrSearch(keywords: string): Promise<any> {
- let settings = await this.settingRepository.get();
+ const settings = await this.settingRepository.get();
return urls.searchUrl(keywords, settings.search);
}
}
diff --git a/src/background/usecases/CompletionsUseCase.ts b/src/background/usecases/CompletionsUseCase.ts
index bfff1e6..779c61d 100644
--- a/src/background/usecases/CompletionsUseCase.ts
+++ b/src/background/usecases/CompletionsUseCase.ts
@@ -22,8 +22,8 @@ export default class CompletionsUseCase {
}
queryConsoleCommand(prefix: string): Promise<CompletionGroup[]> {
- let keys = Object.keys(CommandDocs);
- let items = keys
+ const keys = Object.keys(CommandDocs);
+ const items = keys
.filter(name => name.startsWith(prefix))
.map(name => ({
caption: name,
@@ -41,28 +41,28 @@ export default class CompletionsUseCase {
// TODO This logic contains view entities. They should be defined on
// content script
- let settings = await this.settingRepository.get();
- let groups: CompletionGroup[] = [];
+ const settings = await this.settingRepository.get();
+ const groups: CompletionGroup[] = [];
- let complete = settings.properties.complete;
- for (let c of complete) {
+ const complete = settings.properties.complete;
+ for (const c of complete) {
if (c === 's') {
// eslint-disable-next-line no-await-in-loop
- let engines = await this.querySearchEngineItems(name, keywords);
+ const engines = await this.querySearchEngineItems(name, keywords);
if (engines.length > 0) {
groups.push({ name: 'Search Engines', items: engines });
}
// browser.history not supported on Android
} else if (c === 'h' && typeof browser.history === 'object') {
// eslint-disable-next-line no-await-in-loop
- let histories = await this.queryHistoryItems(name, keywords);
+ const histories = await this.queryHistoryItems(name, keywords);
if (histories.length > 0) {
groups.push({ name: 'History', items: histories });
}
// browser.bookmarks not supported on Android
} else if (c === 'b' && typeof browser.bookmarks === 'object') {
// eslint-disable-next-line no-await-in-loop
- let bookmarks = await this.queryBookmarkItems(name, keywords);
+ const bookmarks = await this.queryBookmarkItems(name, keywords);
if (bookmarks.length > 0) {
groups.push({ name: 'Bookmarks', items: bookmarks });
}
@@ -76,23 +76,23 @@ export default class CompletionsUseCase {
name: string,
keywords: string,
): Promise<CompletionGroup[]> {
- let lastId = await this.tabPresenter.getLastSelectedId();
- let trimmed = keywords.trim();
+ const lastId = await this.tabPresenter.getLastSelectedId();
+ const trimmed = keywords.trim();
let tabs: Tab[] = [];
if (trimmed.length > 0 && !isNaN(Number(trimmed))) {
- let all = await this.tabPresenter.getAll();
- let index = parseInt(trimmed, 10) - 1;
+ const all = await this.tabPresenter.getAll();
+ const index = parseInt(trimmed, 10) - 1;
if (index >= 0 && index < all.length) {
tabs = [all[index]];
}
} else if (trimmed === '%') {
- let all = await this.tabPresenter.getAll();
- let tab = all.find(t => t.active) as Tab;
+ const all = await this.tabPresenter.getAll();
+ const tab = all.find(t => t.active) as Tab;
tabs = [tab];
} else if (trimmed === '#') {
if (typeof lastId !== 'undefined' && lastId !== null) {
- let all = await this.tabPresenter.getAll();
- let tab = all.find(t => t.id === lastId) as Tab;
+ const all = await this.tabPresenter.getAll();
+ const tab = all.find(t => t.id === lastId) as Tab;
tabs = [tab];
}
} else {
@@ -106,7 +106,7 @@ export default class CompletionsUseCase {
}
return ' ';
};
- let items = tabs.map(tab => ({
+ const items = tabs.map(tab => ({
caption: tab.index + 1 + ': ' + flag(tab) + ' ' + tab.title,
content: name + ' ' + tab.title,
url: tab.url,
@@ -129,7 +129,7 @@ export default class CompletionsUseCase {
}
querySet(name: string, keywords: string): Promise<CompletionGroup[]> {
- let items = Properties.defs().map((def) => {
+ const items = Properties.defs().map((def) => {
if (def.type === 'boolean') {
return [
{
@@ -166,8 +166,8 @@ export default class CompletionsUseCase {
async queryTabs(
name: string, excludePinned: boolean, args: string,
): Promise<CompletionGroup[]> {
- let tabs = await this.completionsRepository.queryTabs(args, excludePinned);
- let items = tabs.map(tab => ({
+ const tabs = await this.completionsRepository.queryTabs(args, excludePinned);
+ const items = tabs.map(tab => ({
caption: tab.title,
content: name + ' ' + tab.title,
url: tab.url,
@@ -180,8 +180,8 @@ export default class CompletionsUseCase {
}
async querySearchEngineItems(name: string, keywords: string) {
- let settings = await this.settingRepository.get();
- let engines = Object.keys(settings.search.engines)
+ const settings = await this.settingRepository.get();
+ const engines = Object.keys(settings.search.engines)
.filter(key => key.startsWith(keywords));
return engines.map(key => ({
caption: key,
@@ -209,7 +209,7 @@ export default class CompletionsUseCase {
}
async queryBookmarkItems(name: string, keywords: string) {
- let bookmarks = await this.completionsRepository.queryBookmarks(keywords);
+ const bookmarks = await this.completionsRepository.queryBookmarks(keywords);
return bookmarks.slice(0, COMPLETION_ITEM_LIMIT)
.map(page => ({
caption: page.title,
diff --git a/src/background/usecases/ConsoleUseCase.ts b/src/background/usecases/ConsoleUseCase.ts
index d0bd7bb..775a1e0 100644
--- a/src/background/usecases/ConsoleUseCase.ts
+++ b/src/background/usecases/ConsoleUseCase.ts
@@ -12,12 +12,12 @@ export default class ConsoleUseCase {
}
async showCommand(): Promise<any> {
- let tab = await this.tabPresenter.getCurrent();
+ const tab = await this.tabPresenter.getCurrent();
return this.consoleClient.showCommand(tab.id as number, '');
}
async showOpenCommand(alter: boolean): Promise<any> {
- let tab = await this.tabPresenter.getCurrent();
+ const tab = await this.tabPresenter.getCurrent();
let command = 'open ';
if (alter) {
command += tab.url || '';
@@ -26,7 +26,7 @@ export default class ConsoleUseCase {
}
async showTabopenCommand(alter: boolean): Promise<any> {
- let tab = await this.tabPresenter.getCurrent();
+ const tab = await this.tabPresenter.getCurrent();
let command = 'tabopen ';
if (alter) {
command += tab.url || '';
@@ -35,7 +35,7 @@ export default class ConsoleUseCase {
}
async showWinopenCommand(alter: boolean): Promise<any> {
- let tab = await this.tabPresenter.getCurrent();
+ const tab = await this.tabPresenter.getCurrent();
let command = 'winopen ';
if (alter) {
command += tab.url || '';
@@ -44,13 +44,13 @@ export default class ConsoleUseCase {
}
async showBufferCommand(): Promise<any> {
- let tab = await this.tabPresenter.getCurrent();
- let command = 'buffer ';
+ const tab = await this.tabPresenter.getCurrent();
+ const command = 'buffer ';
return this.consoleClient.showCommand(tab.id as number, command);
}
async showAddbookmarkCommand(alter: boolean): Promise<any> {
- let tab = await this.tabPresenter.getCurrent();
+ const tab = await this.tabPresenter.getCurrent();
let command = 'addbookmark ';
if (alter) {
command += tab.title || '';
@@ -59,7 +59,7 @@ export default class ConsoleUseCase {
}
async hideConsole(): Promise<any> {
- let tab = await this.tabPresenter.getCurrent();
+ const tab = await this.tabPresenter.getCurrent();
return this.consoleClient.hide(tab.id as number);
}
}
diff --git a/src/background/usecases/FindUseCase.ts b/src/background/usecases/FindUseCase.ts
index 41b9cbd..b8593c6 100644
--- a/src/background/usecases/FindUseCase.ts
+++ b/src/background/usecases/FindUseCase.ts
@@ -21,7 +21,7 @@ export default class FindUseCase {
}
async findStart(): Promise<any> {
- let tab = await this.tabPresenter.getCurrent();
+ const tab = await this.tabPresenter.getCurrent();
return this.consoleClient.showFind(tab.id as number);
}
}
diff --git a/src/background/usecases/LinkUseCase.ts b/src/background/usecases/LinkUseCase.ts
index e87867d..9c0eab5 100644
--- a/src/background/usecases/LinkUseCase.ts
+++ b/src/background/usecases/LinkUseCase.ts
@@ -15,9 +15,9 @@ export default class LinkUseCase {
async openNewTab(
url: string, openerId: number, background: boolean,
): Promise<any> {
- let properties: any = { active: !background };
+ const properties: any = { active: !background };
- let platform = await browser.runtime.getPlatformInfo();
+ const platform = await browser.runtime.getPlatformInfo();
if (platform.os !== 'android') {
// openerTabId not supported on Android
properties.openerTabId = openerId;
diff --git a/src/background/usecases/MarkUseCase.ts b/src/background/usecases/MarkUseCase.ts
index 8cb96da..eeac40f 100644
--- a/src/background/usecases/MarkUseCase.ts
+++ b/src/background/usecases/MarkUseCase.ts
@@ -15,15 +15,15 @@ export default class MarkUseCase {
}
async setGlobal(key: string, x: number, y: number): Promise<any> {
- let tab = await this.tabPresenter.getCurrent();
- let mark = { tabId: tab.id as number, url: tab.url as string, x, y };
+ const tab = await this.tabPresenter.getCurrent();
+ const mark = { tabId: tab.id as number, url: tab.url as string, x, y };
return this.markRepository.setMark(key, mark);
}
async jumpGlobal(key: string): Promise<any> {
- let current = await this.tabPresenter.getCurrent();
+ const current = await this.tabPresenter.getCurrent();
- let mark = await this.markRepository.getMark(key);
+ const mark = await this.markRepository.getMark(key);
if (!mark) {
return this.consoleClient.showError(
current.id as number, 'Mark is not set');
@@ -32,7 +32,7 @@ export default class MarkUseCase {
await this.contentMessageClient.scrollTo(mark.tabId, mark.x, mark.y);
return this.tabPresenter.select(mark.tabId);
} catch (e) {
- let tab = await this.tabPresenter.create(mark.url);
+ const tab = await this.tabPresenter.create(mark.url);
return this.markRepository.setMark(key, {
tabId: tab.id as number, url: mark.url, x: mark.x, y: mark.y,
});
diff --git a/src/background/usecases/NavigateUseCase.ts b/src/background/usecases/NavigateUseCase.ts
index 152339a..25e7f20 100644
--- a/src/background/usecases/NavigateUseCase.ts
+++ b/src/background/usecases/NavigateUseCase.ts
@@ -11,28 +11,28 @@ export default class NavigateUseCase {
}
async openHistoryNext(): Promise<void> {
- let tab = await this.tabPresenter.getCurrent();
+ const tab = await this.tabPresenter.getCurrent();
await this.navigateClient.historyNext(tab.id!!);
}
async openHistoryPrev(): Promise<void> {
- let tab = await this.tabPresenter.getCurrent();
+ const tab = await this.tabPresenter.getCurrent();
await this.navigateClient.historyPrev(tab.id!!);
}
async openLinkNext(): Promise<void> {
- let tab = await this.tabPresenter.getCurrent();
+ const tab = await this.tabPresenter.getCurrent();
await this.navigateClient.linkNext(tab.id!!);
}
async openLinkPrev(): Promise<void> {
- let tab = await this.tabPresenter.getCurrent();
+ const tab = await this.tabPresenter.getCurrent();
await this.navigateClient.linkPrev(tab.id!!);
}
async openParent(): Promise<void> {
- let tab = await this.tabPresenter.getCurrent();
- let url = new URL(tab.url!!);
+ const tab = await this.tabPresenter.getCurrent();
+ const url = new URL(tab.url!!);
if (url.hash.length > 0) {
url.hash = '';
} else if (url.search.length > 0) {
@@ -50,8 +50,8 @@ export default class NavigateUseCase {
}
async openRoot(): Promise<void> {
- let tab = await this.tabPresenter.getCurrent();
- let url = new URL(tab.url!!);
+ const tab = await this.tabPresenter.getCurrent();
+ const url = new URL(tab.url!!);
await this.tabPresenter.open(url.origin);
}
}
diff --git a/src/background/usecases/TabSelectUseCase.ts b/src/background/usecases/TabSelectUseCase.ts
index df3db94..62098de 100644
--- a/src/background/usecases/TabSelectUseCase.ts
+++ b/src/background/usecases/TabSelectUseCase.ts
@@ -9,43 +9,43 @@ export default class TabSelectUseCase {
}
async selectPrev(count: number): Promise<any> {
- let tabs = await this.tabPresenter.getAll();
+ const tabs = await this.tabPresenter.getAll();
if (tabs.length < 2) {
return;
}
- let tab = tabs.find(t => t.active);
+ const tab = tabs.find(t => t.active);
if (!tab) {
return;
}
- let select = (tab.index - count + tabs.length) % tabs.length;
+ const select = (tab.index - count + tabs.length) % tabs.length;
return this.tabPresenter.select(tabs[select].id as number);
}
async selectNext(count: number): Promise<any> {
- let tabs = await this.tabPresenter.getAll();
+ const tabs = await this.tabPresenter.getAll();
if (tabs.length < 2) {
return;
}
- let tab = tabs.find(t => t.active);
+ const tab = tabs.find(t => t.active);
if (!tab) {
return;
}
- let select = (tab.index + count) % tabs.length;
+ const select = (tab.index + count) % tabs.length;
return this.tabPresenter.select(tabs[select].id as number);
}
async selectFirst(): Promise<any> {
- let tabs = await this.tabPresenter.getAll();
+ const tabs = await this.tabPresenter.getAll();
return this.tabPresenter.select(tabs[0].id as number);
}
async selectLast(): Promise<any> {
- let tabs = await this.tabPresenter.getAll();
+ const tabs = await this.tabPresenter.getAll();
return this.tabPresenter.select(tabs[tabs.length - 1].id as number);
}
async selectPrevSelected(): Promise<any> {
- let tabId = await this.tabPresenter.getLastSelectedId();
+ const tabId = await this.tabPresenter.getLastSelectedId();
if (tabId === null || typeof tabId === 'undefined') {
return Promise.resolve();
}
diff --git a/src/background/usecases/TabUseCase.ts b/src/background/usecases/TabUseCase.ts
index 386307e..66f8573 100644
--- a/src/background/usecases/TabUseCase.ts
+++ b/src/background/usecases/TabUseCase.ts
@@ -13,26 +13,26 @@ export default class TabUseCase {
}
async close(force: boolean, selectLeft = false): Promise<any> {
- let tab = await this.tabPresenter.getCurrent();
+ const tab = await this.tabPresenter.getCurrent();
if (!force && tab.pinned) {
return Promise.resolve();
}
if (selectLeft && tab.index > 0) {
- let tabs = await this.tabPresenter.getAll();
+ const tabs = await this.tabPresenter.getAll();
await this.tabPresenter.select(tabs[tab.index - 1].id as number);
}
return this.tabPresenter.remove([tab.id as number]);
}
async closeRight(): Promise<any> {
- let tabs = await this.tabPresenter.getAll();
+ const tabs = await this.tabPresenter.getAll();
tabs.sort((t1, t2) => t1.index - t2.index);
- let index = tabs.findIndex(t => t.active);
+ const index = tabs.findIndex(t => t.active);
if (index < 0) {
return;
}
for (let i = index + 1; i < tabs.length; ++i) {
- let tab = tabs[i];
+ const tab = tabs[i];
if (!tab.pinned) {
this.tabPresenter.remove([tab.id as number]);
}
@@ -44,34 +44,34 @@ export default class TabUseCase {
}
async reload(cache: boolean): Promise<any> {
- let tab = await this.tabPresenter.getCurrent();
+ const tab = await this.tabPresenter.getCurrent();
return this.tabPresenter.reload(tab.id as number, cache);
}
async setPinned(pinned: boolean): Promise<any> {
- let tab = await this.tabPresenter.getCurrent();
+ const tab = await this.tabPresenter.getCurrent();
return this.tabPresenter.setPinned(tab.id as number, pinned);
}
async togglePinned(): Promise<any> {
- let tab = await this.tabPresenter.getCurrent();
+ const tab = await this.tabPresenter.getCurrent();
return this.tabPresenter.setPinned(tab.id as number, !tab.pinned);
}
async duplicate(): Promise<any> {
- let tab = await this.tabPresenter.getCurrent();
+ const tab = await this.tabPresenter.getCurrent();
return this.tabPresenter.duplicate(tab.id as number);
}
async openPageSource(): Promise<any> {
- let tab = await this.tabPresenter.getCurrent();
- let url = 'view-source:' + tab.url;
+ const tab = await this.tabPresenter.getCurrent();
+ const url = 'view-source:' + tab.url;
return this.tabPresenter.create(url);
}
async openHome(newTab: boolean): Promise<any> {
- let tab = await this.tabPresenter.getCurrent();
- let urls = await this.browserSettingRepository.getHomepageUrls();
+ const tab = await this.tabPresenter.getCurrent();
+ const urls = await this.browserSettingRepository.getHomepageUrls();
if (urls.length === 1 && urls[0] === 'about:home') {
// eslint-disable-next-line max-len
throw new Error('Cannot open Firefox Home (about:home) by WebExtensions, set your custom URLs');
@@ -79,7 +79,7 @@ export default class TabUseCase {
if (urls.length === 1 && !newTab) {
return this.tabPresenter.open(urls[0], tab.id);
}
- for (let url of urls) {
+ for (const url of urls) {
this.tabPresenter.create(url);
}
}
@@ -92,7 +92,7 @@ export default class TabUseCase {
} else if (newTab) {
await this.tabPresenter.create(url);
} else {
- let tab = await this.tabPresenter.getCurrent();
+ const tab = await this.tabPresenter.getCurrent();
await this.tabPresenter.open(url, tab.id);
}
}
diff --git a/src/background/usecases/VersionUseCase.ts b/src/background/usecases/VersionUseCase.ts
index 0ff0e9b..645c859 100644
--- a/src/background/usecases/VersionUseCase.ts
+++ b/src/background/usecases/VersionUseCase.ts
@@ -11,8 +11,8 @@ export default class VersionUseCase {
}
notify(): Promise<void> {
- let manifest = browser.runtime.getManifest();
- let url = this.releaseNoteUrl(manifest.version);
+ const manifest = browser.runtime.getManifest();
+ const url = this.releaseNoteUrl(manifest.version);
return this.notifyPresenter.notifyUpdated(manifest.version, () => {
this.tabPresenter.create(url);
});
diff --git a/src/background/usecases/ZoomUseCase.ts b/src/background/usecases/ZoomUseCase.ts
index 32ba897..f598871 100644
--- a/src/background/usecases/ZoomUseCase.ts
+++ b/src/background/usecases/ZoomUseCase.ts
@@ -14,27 +14,27 @@ export default class ZoomUseCase {
}
async zoomIn(): Promise<any> {
- let tab = await this.tabPresenter.getCurrent();
- let tabId = tab.id as number;
- let current = await this.tabPresenter.getZoom(tabId);
- let factor = ZOOM_SETTINGS.find(f => f > current);
+ const tab = await this.tabPresenter.getCurrent();
+ const tabId = tab.id as number;
+ const current = await this.tabPresenter.getZoom(tabId);
+ const factor = ZOOM_SETTINGS.find(f => f > current);
if (factor) {
return this.tabPresenter.setZoom(tabId as number, factor);
}
}
async zoomOut(): Promise<any> {
- let tab = await this.tabPresenter.getCurrent();
- let tabId = tab.id as number;
- let current = await this.tabPresenter.getZoom(tabId);
- let factor = ZOOM_SETTINGS.slice(0).reverse().find(f => f < current);
+ const tab = await this.tabPresenter.getCurrent();
+ const tabId = tab.id as number;
+ const current = await this.tabPresenter.getZoom(tabId);
+ const factor = ZOOM_SETTINGS.slice(0).reverse().find(f => f < current);
if (factor) {
return this.tabPresenter.setZoom(tabId as number, factor);
}
}
async zoomNutoral(): Promise<any> {
- let tab = await this.tabPresenter.getCurrent();
+ const tab = await this.tabPresenter.getCurrent();
return this.tabPresenter.setZoom(tab.id as number, 1);
}
}
diff --git a/src/background/usecases/filters.ts b/src/background/usecases/filters.ts
index 84a42fb..98957a7 100644
--- a/src/background/usecases/filters.ts
+++ b/src/background/usecases/filters.ts
@@ -1,13 +1,13 @@
type Item = browser.history.HistoryItem;
const filterHttp = (items: Item[]): Item[] => {
- let httpsHosts = items.map(x => new URL(x.url as string))
+ const httpsHosts = items.map(x => new URL(x.url as string))
.filter(x => x.protocol === 'https:')
.map(x => x.host);
- let hostsSet = new Set(httpsHosts);
+ const hostsSet = new Set(httpsHosts);
return items.filter((item: Item) => {
- let url = new URL(item.url as string);
+ const url = new URL(item.url as string);
return url.protocol === 'https:' || !hostsSet.has(url.host);
});
};
@@ -17,14 +17,14 @@ const filterBlankTitle = (items: Item[]): Item[] => {
};
const filterByTailingSlash = (items: Item[]): Item[] => {
- let urls = items.map(item => new URL(item.url as string));
- let simplePaths = urls
+ const urls = items.map(item => new URL(item.url as string));
+ const simplePaths = urls
.filter(url => url.hash === '' && url.search === '')
.map(url => url.origin + url.pathname);
- let pathsSet = new Set(simplePaths);
+ const pathsSet = new Set(simplePaths);
return items.filter((item) => {
- let url = new URL(item.url as string);
+ const url = new URL(item.url as string);
if (url.hash !== '' || url.search !== '' ||
url.pathname.slice(-1) !== '/') {
return true;
@@ -34,10 +34,10 @@ const filterByTailingSlash = (items: Item[]): Item[] => {
};
const filterByPathname = (items: Item[], min: number): Item[] => {
- let hash: {[key: string]: Item} = {};
- for (let item of items) {
- let url = new URL(item.url as string);
- let pathname = url.origin + url.pathname;
+ const hash: {[key: string]: Item} = {};
+ for (const item of items) {
+ const url = new URL(item.url as string);
+ const pathname = url.origin + url.pathname;
if (!hash[pathname]) {
hash[pathname] = item;
} else if ((hash[pathname].url as string).length >
@@ -45,7 +45,7 @@ const filterByPathname = (items: Item[], min: number): Item[] => {
hash[pathname] = item;
}
}
- let filtered = Object.values(hash);
+ const filtered = Object.values(hash);
if (filtered.length < min) {
return items;
}
@@ -53,9 +53,9 @@ const filterByPathname = (items: Item[], min: number): Item[] => {
};
const filterByOrigin = (items: Item[], min: number): Item[] => {
- let hash: {[key: string]: Item} = {};
- for (let item of items) {
- let origin = new URL(item.url as string).origin;
+ const hash: {[key: string]: Item} = {};
+ for (const item of items) {
+ const origin = new URL(item.url as string).origin;
if (!hash[origin]) {
hash[origin] = item;
} else if ((hash[origin].url as string).length >
@@ -63,7 +63,7 @@ const filterByOrigin = (items: Item[], min: number): Item[] => {
hash[origin] = item;
}
}
- let filtered = Object.values(hash);
+ const filtered = Object.values(hash);
if (filtered.length < min) {
return items;
}
diff --git a/src/background/usecases/parsers.ts b/src/background/usecases/parsers.ts
index e8a1149..544dce4 100644
--- a/src/background/usecases/parsers.ts
+++ b/src/background/usecases/parsers.ts
@@ -1,7 +1,7 @@
import Properties from '../../shared/settings/Properties';
const mustNumber = (v: any): number => {
- let num = Number(v);
+ const num = Number(v);
if (isNaN(num)) {
throw new Error('Not number: ' + v);
}
@@ -16,7 +16,7 @@ const parseSetOption = (
value = !key.startsWith('no');
key = value ? key : key.slice(2);
}
- let def = Properties.def(key);
+ const def = Properties.def(key);
if (!def) {
throw new Error('Unknown property: ' + key);
}