src/content
This commit is contained in:
parent
a0882bbceb
commit
b002d70070
19 changed files with 119 additions and 80 deletions
|
@ -1,5 +1,21 @@
|
|||
import * as urls from '../../shared/urls';
|
||||
|
||||
declare namespace browser.browserSettings.homepageOverride {
|
||||
|
||||
type BrowserSettings = {
|
||||
value: string;
|
||||
levelOfControl: LevelOfControlType;
|
||||
};
|
||||
|
||||
type LevelOfControlType =
|
||||
'not_controllable' |
|
||||
'controlled_by_other_extensions' |
|
||||
'controllable_by_this_extension' |
|
||||
'controlled_by_this_extension';
|
||||
|
||||
function get(param: object): Promise<BrowserSettings>;
|
||||
}
|
||||
|
||||
export default class BrowserSettingRepository {
|
||||
async getHomepageUrls(): Promise<string[]> {
|
||||
let { value } = await browser.browserSettings.homepageOverride.get({});
|
||||
|
|
|
@ -21,7 +21,7 @@ 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, url: tab.url, x, y };
|
||||
let mark = { tabId: tab.id as number, url: tab.url as string, x, y };
|
||||
return this.markRepository.setMark(key, mark);
|
||||
}
|
||||
|
||||
|
@ -33,15 +33,14 @@ export default class MarkUseCase {
|
|||
return this.consoleClient.showError(
|
||||
current.id as number, 'Mark is not set');
|
||||
}
|
||||
|
||||
return this.contentMessageClient.scrollTo(
|
||||
mark.tabId, mark.x, mark.y
|
||||
).then(() => {
|
||||
try {
|
||||
await this.contentMessageClient.scrollTo(mark.tabId, mark.x, mark.y);
|
||||
return this.tabPresenter.select(mark.tabId);
|
||||
}).catch(async() => {
|
||||
} catch (e) {
|
||||
let tab = await this.tabPresenter.create(mark.url);
|
||||
let mark2 = { tabId: tab.id, url: mark.url, x: mark.x, y: mark.y };
|
||||
return this.markRepository.setMark(key, mark2);
|
||||
});
|
||||
return this.markRepository.setMark(key, {
|
||||
tabId: tab.id as number, url: mark.url, x: mark.x, y: mark.y,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import manifest from '../../../manifest.json';
|
||||
import TabPresenter from '../presenters/TabPresenter';
|
||||
import NotifyPresenter from '../presenters/NotifyPresenter';
|
||||
|
||||
|
@ -13,6 +12,7 @@ export default class VersionUseCase {
|
|||
}
|
||||
|
||||
notify(): Promise<void> {
|
||||
let manifest = browser.runtime.getManifest();
|
||||
let title = `Vim Vixen ${manifest.version} has been installed`;
|
||||
let message = 'Click here to see release notes';
|
||||
let url = this.releaseNoteUrl(manifest.version);
|
||||
|
|
|
@ -40,7 +40,8 @@ const filterByPathname = (items: Item[], min: number): Item[] => {
|
|||
let pathname = url.origin + url.pathname;
|
||||
if (!hash[pathname]) {
|
||||
hash[pathname] = item;
|
||||
} else if (hash[pathname].url.length > item.url.length) {
|
||||
} else if ((hash[pathname].url as string).length >
|
||||
(item.url as string).length) {
|
||||
hash[pathname] = item;
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +58,8 @@ const filterByOrigin = (items: Item[], min: number): Item[] => {
|
|||
let origin = new URL(item.url as string).origin;
|
||||
if (!hash[origin]) {
|
||||
hash[origin] = item;
|
||||
} else if (hash[origin].url.length > item.url.length) {
|
||||
} else if ((hash[origin].url as string).length >
|
||||
(item.url as string).length) {
|
||||
hash[origin] = item;
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue