diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2021-03-20 11:51:08 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2021-03-21 12:24:36 +0900 |
commit | 8828d175d9754e7afedf1dbb0b7bda2824608b0a (patch) | |
tree | 8cec92a05b5895848d0b423fce9473f9e7a905b0 /src | |
parent | 3ffb4b066cdcc60a49ce4ecd0bbc498da6256534 (diff) |
Inject iframe on top window
Diffstat (limited to 'src')
-rw-r--r-- | src/content/presenters/ConsoleFramePresenter.ts | 6 | ||||
-rw-r--r-- | src/content/usecases/AddonEnabledUseCase.ts | 10 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/content/presenters/ConsoleFramePresenter.ts b/src/content/presenters/ConsoleFramePresenter.ts index 9c4b3f1..0db58f0 100644 --- a/src/content/presenters/ConsoleFramePresenter.ts +++ b/src/content/presenters/ConsoleFramePresenter.ts @@ -6,6 +6,8 @@ export default interface ConsoleFramePresenter { blur(): void; resize(width: number, height: number): void; + + isTopWindow(): boolean; } export class ConsoleFramePresenterImpl implements ConsoleFramePresenter { @@ -47,4 +49,8 @@ export class ConsoleFramePresenterImpl implements ConsoleFramePresenter { } ele.style.height = `${height}px`; } + + isTopWindow(): boolean { + return window.top === window; + } } diff --git a/src/content/usecases/AddonEnabledUseCase.ts b/src/content/usecases/AddonEnabledUseCase.ts index b45c47f..f49fde5 100644 --- a/src/content/usecases/AddonEnabledUseCase.ts +++ b/src/content/usecases/AddonEnabledUseCase.ts @@ -34,10 +34,12 @@ export default class AddonEnabledUseCase { private async setEnabled(on: boolean): Promise<void> { this.repository.set(on); - if (on) { - this.consoleFramePresenter.attach(); - } else { - this.consoleFramePresenter.detach(); + if (this.consoleFramePresenter.isTopWindow()) { + if (on) { + this.consoleFramePresenter.attach(); + } else { + this.consoleFramePresenter.detach(); + } } await this.indicator.setEnabled(on); } |