Chrome的tabs.executeScript - 无效

时间:2016-06-08 07:05:45

标签: javascript google-chrome-extension

我正在编写一个chrome扩展,它将创建一个带有URL(ds_url)的新选项卡,并执行一些操作以获取DOM元素信息。

以下是background.js

中的代码
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
    chrome.tabs.create({url:ds_url, active:true}, function(tab){
        chrome.tabs.executeScript(tab.id, {file: "caseDoubleClickScript.js", allFrames: true, runAt: "document_end"}, function(results){ 
        });
    });  
});

以下是我的清单代码:

{
"manifest_version": 2,
"name": "RMQA Rules",
"description": "This extension reads the cases and grabs data to perform some automation",
"version": "1.1.1",
"icons": { 
    "16": "icon16x16.png",
    "48": "icon48x48.jpeg",
    "128": "icon128x128.png" 
        },
"browser_action": {
    "default_icon": "icon128x128.png",
    "default_title": "Click To Start the Automation",
    "default_popup": "popup.html"
                },
"background": {
    "scripts": [ "jquery-2.2.2.min.js", "background.js"]
            },
"content_scripts": [
    {
    "matches": ["https://www.example.com/*"],
    "all_frames": true,
    "css": ["main.css"],
    "js": ["jquery-2.2.2.min.js", "contentScript.js",     "casePageContentScript.js", "caseDoubleClickScript.js"],
    "run_at": "document_end"
    }
    ],
"web_accessible_resources": ["casePageContentScript.js","caseDoubleClickScript.js"],
"permissions": [
    "activeTab",
    "declarativeContent",
    "tabs",
    "storage",
    "notifications",
    "webNavigation",
    "https://www.example.com/*"
            ],
"web_accessible_resources": [ "success.png" ]
}

但是我无法从caseDoubleClickScript.js文件中读取新创建的URL中的DOM元素。

0 个答案:

没有答案