简体   繁体   English

Safari浏览器扩展中的注入脚本与全局变量

[英]injected script in safari extension vs. global variables

All scpripts injected by Safari extension run in their own namespace. Safari扩展注入的所有脚本都在其自己的名称空间中运行。 Is it possible to access original (website author's) javascript variables/functions from injected script? 是否可以从注入的脚本访问原始(网站作者)的javascript变量/函数?

Safari extensions (global.html) are working like little Webpages around your pages. Safari扩展(global.html)就像页面周围的小网页一样工作。 except from the "proxy" declarations to share data, functions, handlers with the injected scripts it should be possible to connect to other webcontent somewhere. 除了使用共享脚本共享数据,函数,处理程序的“代理”声明之外,应该可以在某处连接到其他Webcontent。 i've testet a xml-httprequest from inside a global.html (ajax), did work like a charme. 我已经从global.html(ajax)内测试了一个xml-httprequest,确实起到了魔咒的作用。

but if you mean to call javascript functions from your injected script but given from your content (website author's pages), make shure you call them after they are ready loaded. 但是如果您打算从注入的脚本中调用javascript函数,但从内容(网站作者的页面)中获得javascript函数,请确保在它们准备好加载后再调用它们。 everything you can call from the main (webkit) console is possible to call from a script too. 您可以从主(Webkit)控制台调用的所有内容也可以从脚本调用。

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

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