Chrome 扩展程序 - 从网页中检索全局变量 [英] Chrome extension - retrieving global variable from webpage

查看:44
本文介绍了Chrome 扩展程序 - 从网页中检索全局变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发 Chrome 扩展程序.我希望解析原始"Gmail 邮件(当前查看的邮件)的内容.

I am working on an extension for Chrome. I wish parse the content of the "original" Gmail message (the currently viewed message).

我尝试使用 jQuery.load() 如下

I tried to utilize the jQuery.load() as follows

$(windows).load(function() { alert(GLOBALS); });

并将其放置在内容脚本中,但它也不起作用.我正在使用 Chrome 的开发人员工具,它在调用 alert(GLOBALS);

and place it at the content script, but it does not work either. I am using Chrome's developer tools, which returns the following error on the invocation of the alert(GLOBALS);

未捕获的引用错误:未定义 GLOBALS

Uncaught ReferenceError: GLOBALS is not defined

虽然,当使用开发者工具的控制台时,在控制台中输入GLOBALS 会返回一个数组.

Although, when using the developers tools' console, typing into the console GLOBALS it returns an array.

知道如何从内容脚本访问 GLOBALS 吗?

Any clue how to access the GLOBALS from the content script?

推荐答案

内容脚本一个孤立的环境.要访问任何全局属性(页面的 window),您必须注入一个新的

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆