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"]});
相关推荐
kungggyoyoyo4 分钟前
TRAE中国版SOLO模式上线!我用它从0到1开发了一款AI小说编辑器
前端·vue.js·trae
ohyeah6 分钟前
栈:那个“先进后出”的小可爱,其实超好用!
前端·数据结构
心随雨下16 分钟前
typescript中Triple-Slash Directives如何使用
前端·javascript·typescript
自在极意功。21 分钟前
AJAX 深度详解:从基础原理到项目实战
前端·ajax·okhttp
s***45322 分钟前
SpringBoot返回文件让前端下载的几种方式
前端·spring boot·后端
海上彼尚26 分钟前
[逆向] 1.本地登录爆破
前端·安全
什么时候吃饭31 分钟前
vue2、vue3父子组件嵌套生命周期执行顺序
前端·vue.js
2501_9409439132 分钟前
体系课\ Python Web全栈工程师
开发语言·前端·python
q***064733 分钟前
SpringSecurity相关jar包的介绍
android·前端·后端
低保和光头哪个先来39 分钟前
场景2:Vue Router 中 query 与 params 的区别
前端·javascript·vue.js·前端框架