aboutsummaryrefslogtreecommitdiff
path: root/src/content
diff options
context:
space:
mode:
Diffstat (limited to 'src/content')
-rw-r--r--src/content/controllers/SettingController.ts3
-rw-r--r--src/content/di.ts2
-rw-r--r--src/content/repositories/AddressRepository.ts9
-rw-r--r--src/content/usecases/KeymapUseCase.ts15
4 files changed, 28 insertions, 1 deletions
diff --git a/src/content/controllers/SettingController.ts b/src/content/controllers/SettingController.ts
index 06273a0..e1c7f01 100644
--- a/src/content/controllers/SettingController.ts
+++ b/src/content/controllers/SettingController.ts
@@ -15,7 +15,8 @@ export default class SettingController {
async initSettings(): Promise<void> {
try {
let current = await this.settingUseCase.reload();
- let disabled = current.blacklist.includes(window.location.href);
+ let url = new URL(window.location.href);
+ let disabled = current.blacklist.includesEntireBlacklist(url);
if (disabled) {
this.addonEnabledUseCase.disable();
} else {
diff --git a/src/content/di.ts b/src/content/di.ts
index e18806a..63103a1 100644
--- a/src/content/di.ts
+++ b/src/content/di.ts
@@ -2,6 +2,7 @@
import { AddonEnabledRepositoryImpl } from './repositories/AddonEnabledRepository';
import { AddonIndicatorClientImpl } from './client/AddonIndicatorClient';
+import { AddressRepositoryImpl } from './repositories/AddressRepository';
import { ClipboardRepositoryImpl } from './repositories/ClipboardRepository';
import { ConsoleClientImpl } from './client/ConsoleClient';
import { ConsoleFramePresenterImpl } from './presenters/ConsoleFramePresenter';
@@ -31,6 +32,7 @@ import { container } from 'tsyringe';
container.register('FollowMasterClient', { useValue: new FollowMasterClientImpl(window.top) });
container.register('AddonEnabledRepository', { useClass: AddonEnabledRepositoryImpl });
container.register('AddonIndicatorClient', { useClass: AddonIndicatorClientImpl });
+container.register('AddressRepository', { useClass: AddressRepositoryImpl });
container.register('ClipboardRepository', { useClass: ClipboardRepositoryImpl });
container.register('ConsoleClient', { useClass: ConsoleClientImpl });
container.register('ConsoleFramePresenter', { useClass: ConsoleFramePresenterImpl });
diff --git a/src/content/repositories/AddressRepository.ts b/src/content/repositories/AddressRepository.ts
new file mode 100644
index 0000000..6f9487b
--- /dev/null
+++ b/src/content/repositories/AddressRepository.ts
@@ -0,0 +1,9 @@
+export default interface AddressRepository {
+ getCurrentURL(): URL
+}
+
+export class AddressRepositoryImpl implements AddressRepository {
+ getCurrentURL(): URL {
+ return new URL(window.location.href);
+ }
+}
diff --git a/src/content/usecases/KeymapUseCase.ts b/src/content/usecases/KeymapUseCase.ts
index 495f6d0..67d667d 100644
--- a/src/content/usecases/KeymapUseCase.ts
+++ b/src/content/usecases/KeymapUseCase.ts
@@ -6,6 +6,7 @@ import * as operations from '../../shared/operations';
import Keymaps from '../../shared/settings/Keymaps';
import Key from '../../shared/settings/Key';
import KeySequence from '../../shared/settings/KeySequence';
+import AddressRepository from '../repositories/AddressRepository';
type KeymapEntityMap = Map<KeySequence, operations.Operation>;
@@ -25,11 +26,19 @@ export default class KeymapUseCase {
@inject('AddonEnabledRepository')
private addonEnabledRepository: AddonEnabledRepository,
+
+ @inject('AddressRepository')
+ private addressRepository: AddressRepository,
) {
}
nextOp(key: Key): operations.Operation | null {
let sequence = this.repository.enqueueKey(key);
+ if (sequence.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 = Array.from(keymaps.keys()).filter(
@@ -71,4 +80,10 @@ export default class KeymapUseCase {
) as [KeySequence, operations.Operation][];
return new Map<KeySequence, operations.Operation>(entries);
}
+
+ private blacklistKey(key: Key): boolean {
+ let url = this.addressRepository.getCurrentURL();
+ let blacklist = this.settingRepository.get().blacklist;
+ return blacklist.includeKey(url, key);
+ }
}