edge 插件 iframe 读取

当前页面里的iframe 加载的网页没有注入到,无法读取 iframe里的节点内容

  1. 使用all_frames选项 : 在你的content_scripts配置中,添加all_frames: true,这样可以确保脚本注入到所有的iframe中。

    复制代码
    "content_scripts": [
      {
        "matches": ["<all_urls>"],
        "js": ["content_hook.js"],
        "run_at": "document_start",
        "all_frames": true
      },
      {
        "matches": ["<all_urls>"], 
        "js": ["js/pako.min.js","js/utils.js", "js/coockie.js", "js/youtub.js", "content.js"],
        "run_at": "document_start",
        "all_frames": true
      }
    ]
  2. 动态注入脚本 : 你可以在background.js中监听webNavigation事件,并动态注入脚本到iframe中。

    复制代码
    chrome.webNavigation.onCompleted.addListener(function(details) {
      chrome.scripting.executeScript({
        target: {tabId: details.tabId, frameIds: [details.frameId]},
        files: ['content_hook.js']
      });
    }, {url: [{urlMatches: '<all_urls>'}]});
  3. 使用chrome.webRequest API : 你可以使用chrome.webRequest API来监听iframe的加载,并注入脚本。

    复制代码
    chrome.webRequest.onCompleted.addListener(function(details) {
      chrome.scripting.executeScript({
        target: {tabId: details.tabId, frameIds: [details.frameId]},
        files: ['content_hook.js']
      });
    }, {urls: ["<all_urls>"], types: ["sub_frame"]});
相关推荐
袁煦丞8 分钟前
2025.8.18实验室【代码跑酷指南】Jupyter Notebook程序员的魔法本:cpolar内网穿透实验室第622个成功挑战
前端·程序员·远程工作
Joker Zxc13 分钟前
【前端基础】flex布局中使用`justify-content`后,最后一行的布局问题
前端·css
无奈何杨16 分钟前
风控系统事件分析中心,关联关系、排行、时间分布
前端·后端
Moment22 分钟前
nginx 如何配置防止慢速攻击 🤔🤔🤔
前端·后端·nginx
晓得迷路了27 分钟前
栗子前端技术周刊第 94 期 - React Native 0.81、jQuery 4.0.0 RC1、Bun v1.2.20...
前端·javascript·react.js
前端小巷子29 分钟前
Vue 自定义指令
前端·vue.js·面试
玲小珑35 分钟前
Next.js 教程系列(二十七)React Server Components (RSC) 与未来趋势
前端·next.js
Mike_jia35 分钟前
UptimeRobot API状态监控:零成本打造企业级业务健康看板
前端
江城开朗的豌豆36 分钟前
React状态更新踩坑记:我是这样优雅修改参数的
前端·javascript·react.js
CodeSheep1 小时前
Stack Overflow,轰然倒下了!
前端·后端·程序员