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"]});
相关推荐
狂炫冰美式4 小时前
人均配了AI, 为什么公司还是没变快? 🤔 本质还是分布式系统问题
前端·后端·架构
乘风gg5 小时前
多 Agent 不是万能的!搞懂这 5 个原则,少走 1 年弯路!
前端·agent·ai编程
猩猩程序员5 小时前
Vercel 推出 Agent 框架 Eve:让 AI Agent 像写 Web 应用一样简单
前端
爱读源码的大都督6 小时前
Claude Code源码分析(三):为什么系统提示词中需要有tools呢?
前端·人工智能·后端
爱勇宝6 小时前
Claude Code 被曝暗藏“隐形检测”代码:封代理不是最可怕的,可怕的是你根本不知道它在干什么
前端·后端·程序员
小牛不牛的程序员6 小时前
我用 Claude Code 半天撸完了一个完整网站,AI 编程到底提升了多少效率?
前端
东风破_6 小时前
JavaScript 面试常考的字符串算法:从反转字符串到回文判断
前端·javascript
ITOM运维行者6 小时前
从零搭建企业级服务器监控体系:踩坑实录与架构设计
前端·后端
monologues6 小时前
深入 Vue 3 源码:响应式系统的精妙设计与编译优化
前端
hunterandroid6 小时前
Paging 3 分页:从手动分页到声明式加载
前端