【发布时间】:2025-12-13 15:10:01
【问题描述】:
我在谷歌页面中有一个按钮。 DOM Inspector 给出它的 id。但是尝试获取对象失败。我在控制台中绑定类名时得到 undefined 结果。页面中只有一个 iframe,我的对象不在其中(据我所知)。
manifest.json:
{
"manifest_version": 2,
"name": "modify strings",
"description": "modify strings in bulk",
"version": "1.0",
"permissions": [
"tabs",
"history",
"http://*/*",
"https://*/*"
],
"content_scripts": [
{
"matches": ["https://play.google.com/apps/*"],
"js": ["jquery-1.11.1.min.js", "myInject.js"],
"all_frames": true
}
],
"web_accessible_resources": [
"script.js",
"jquery-1.11.1.min.js"
],
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
}
}
myInject.js(内容脚本):
var buttonJGET = jQuery("gwt-uid-115", document);
console.log(buttonJGET.className);
【问题讨论】:
标签: javascript jquery google-chrome google-chrome-extension