如何以编程方式访问firefox 52中内容脚本中的窗口(全局)对象?
window["myGlobalObjectName"]
在此内容脚本案例中不起作用。
在这种情况下,似乎所有user-defined-object-name
都不是window
的一员。
的manifest.json:
{
"description": "word_extension",
"manifest_version": 2,
"name": "word_extension",
"version": "1.0",
"applications": {
"gecko": {
"id": "word_extension@myself.myself",
"strict_min_version": "50.0"
}
},
"permissions": ["<all_urls>","tabs","nativeMessaging"],
"content_scripts":[{
"matches":["<all_urls>"]
,"run_at":"document_idle","js":["content_script.js"]}]
}
content_script.js:
var test=123
function f()
{
console.log("hello")
}
//All of the following is undefined
console.log(window.f)
console.log(window.test)
console.log(window["f"])
console.log(window["test"])