From 069369419b940bc5da5aaad4d8359905daa57368 Mon Sep 17 00:00:00 2001 From: huanniangstudio <891863891@qq.com> Date: Fri, 17 Mar 2023 21:46:04 +0800 Subject: [PATCH] fix: do not inject in iframe --- src/content-script/index.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/content-script/index.ts b/src/content-script/index.ts index 7b95f091..0f66a966 100644 --- a/src/content-script/index.ts +++ b/src/content-script/index.ts @@ -105,13 +105,22 @@ function blockedDomainCheck() { return false; } +function iframeCheck() { + const isInIframe = self != top; + if (isInIframe) { + return true; + } else { + return false; + } +} + /** * Determines if the provider should be injected * * @returns {boolean} {@code true} Whether the provider should be injected */ function shouldInjectProvider() { - return doctypeCheck() && suffixCheck() && documentElementCheck() && !blockedDomainCheck(); + return doctypeCheck() && suffixCheck() && documentElementCheck() && !blockedDomainCheck() && !iframeCheck(); } if (shouldInjectProvider()) {