简体   繁体   English

通过Chrome扩展程序访问来自不同域的iframe内容

[英]Access iframe content from different domain through chrome extension

I'm trying to develop a chrome extension that reads a value from an input element inside of an iframe, which src indicates to a completely different domain. 我正在尝试开发一个chrome扩展程序,该扩展程序从iframe内的输入元素读取一个值,而src则表示一个完全不同的域。

I already tried including 我已经尝试过包括

"all_frames": true,

into the manifest.json, but it seems to get called through a script. 进入manifest.json,但似乎是通过脚本调用的。

I can see it inside of the "inspect elements" tool, so I assumed that would work, but now I am kind of stuck. 我可以在“检查元素”工具中看到它,因此我认为这行得通,但是现在有点卡住了。

If you have a script that is injected with all_frames: true AND matches both domains, then you have 2 separate instances of content scripts. 如果您有一个注入了all_frames: true的脚本,并且匹配两个域,那么您将有2个单独的内容脚本实例。

They can either talk using postMessage , or through the background page using Messaging (unfortunately, Messaging API can't work directly between them). 他们可以使用postMessage进行交谈,也可以使用Messaging来访问背景页面(不幸的是,Messaging API无法在它们之间直接工作)。

This question may be useful as well. 这个问题也可能有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM