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"]});
相关推荐
Dxy123931021617 小时前
CSS中的filter属性详解
前端·css
Vincent_czr17 小时前
iOS中常常遇到后端返回JSON出现null值问题
前端
问心无愧051317 小时前
ctf show web入门90
前端·笔记
yingyima17 小时前
午夜惊魂:用 Shell 脚本和 Hey Cron 解决服务器定时报警
前端
青山Coding17 小时前
Cesium应用(五):通视分析,解锁三维场景的”无遮挡“视野
前端·cesium
JavaAgent架构师17 小时前
前端AI工程化(三):异步编程与并发控制
前端·人工智能
独泪了无痕17 小时前
利用vue-pdf-embed实现PDF文件的预览
前端·vue.js
Exploring17 小时前
Hola 计算器 v1.0.1 发布:个税计算全面升级,劳务报酬也能算清楚了!
前端
Pan Zonghui17 小时前
个人开源技术博客前端
前端·开源