diff --git a/public/manifest.firefox.json b/public/manifest.firefox.json index 6ce09a3..a1f490d 100644 --- a/public/manifest.firefox.json +++ b/public/manifest.firefox.json @@ -12,7 +12,8 @@ "content_scripts": [ { "js": ["content.js"], - "matches": [""] + "matches": [""], + "all_frames": true } ], "commands": { diff --git a/public/manifest.json b/public/manifest.json index 9b7547a..6f54360 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -13,7 +13,8 @@ "content_scripts": [ { "js": ["content.js"], - "matches": [""] + "matches": [""], + "all_frames": true } ], "commands": { diff --git a/src/content.js b/src/content.js index d8d9499..b148bd2 100644 --- a/src/content.js +++ b/src/content.js @@ -7,14 +7,16 @@ import { } from "./config"; import { getSetting, getRules, matchRule } from "./libs"; import { Translator } from "./libs/translator"; +import { isIframe } from "./libs/iframe"; /** * 入口函数 */ (async () => { + const href = isIframe ? document.referrer : document.location.href; const setting = await getSetting(); const rules = await getRules(); - const rule = await matchRule(rules, document.location.href, setting); + const rule = await matchRule(rules, href, setting); const translator = new Translator(rule, setting); // 监听消息