Javascript Chrome.extensions:打开选项卡>;执行脚本>;关闭选项卡

Javascript Chrome.extensions:打开选项卡>;执行脚本>;关闭选项卡,javascript,html,json,google-chrome-extension,Javascript,Html,Json,Google Chrome Extension,大家好,我想创建一个像网页刮板一样的chrome扩展 “选项卡”按钮应为:打开选项卡>执行脚本>关闭选项卡 但是现在,选项卡被创建了,但是“executescript”和“remove”被忽略了,我缺少了什么 我认为这是一个非常简单的功能,但我对chrome.extensions还是很陌生 希望你今天过得愉快 问候。 NCNN [app.js] var股票; chrome.runtime.onMessage.addListener(函数(请求) { 库存=请求; $.get('https://m

大家好,我想创建一个像网页刮板一样的chrome扩展

“选项卡”按钮应为:打开选项卡>执行脚本>关闭选项卡

但是现在,选项卡被创建了,但是“executescript”和“remove”被忽略了,我缺少了什么

我认为这是一个非常简单的功能,但我对chrome.extensions还是很陌生

希望你今天过得愉快

问候。 NCNN

[app.js]

var股票;
chrome.runtime.onMessage.addListener(函数(请求)
{
库存=请求;
$.get('https://myweb.com/GetData.php?THEDATA=“+库存,功能(数据)
{
});
});
$('#选项卡')。单击(函数()
{
创建({url:'https://stackoverflow.com/“},函数(选项卡)
{
chrome.tabs.executeScript(tab.id,
{
代码:“chrome.runtime.sendMessage(mycommand);”
},()=>chrome.runtime.lastError);
chrome.tabs.remove(tab.id);
});
});
[popup.html]

MYtest
打开选项卡
[manifest.json]

{
    "manifest_version": 2,
    "name": "TestJB",
    "description": "TESTDESC",
    "version": "1.0",
    "permissions":
    [
        "http://*/*",
        "https://*/*",
        "tabs",
        "activeTab",
        "alarms",
        "clipboardRead",
        "clipboardWrite",
        "bookmarks",
        "contextMenus",
        "contentSettings",
        "downloads",
        "history",
        "nativeMessaging",
        "browsingData",
        "proxy",
        "webRequest",
        "webRequestBlocking",
        "cookies",
        "webNavigation",
        "storage",
        "tabCapture",
        "notifications",
        "<all_urls>",
        "unlimitedStorage",
        "debugger"
    ],
    "browser_action":
    {
        "default_icon": "img/icon_128.png",
        "default_popup": "popup.html"
    },
    "icons": 
    {
        "128" : "img/icon_128.png"
    }
}
{
“清单版本”:2,
“名称”:“TestJB”,
“说明”:“TESTDESC”,
“版本”:“1.0”,
“权限”:
[
“http://*/*”,
“https://*/*”,
“标签”,
“活动标签”,
“警报”,
“剪贴簿”,
“剪贴簿书写”,
“书签”,
“上下文菜单”,
“内容设置”,
“下载”,
“历史”,
“nativeMessaging”,
“浏览数据”,
“代理”,
“网络请求”,
“webRequestBlocking”,
“饼干”,
“网络导航”,
“存储”,
“tabCapture”,
“通知”,
"",
“无限制存储”,
“调试器”
],
“浏览器操作”:
{
“默认图标”:“img/icon_128.png”,
“默认弹出窗口”:“popup.html”
},
“图标”:
{
“128”:“img/icon_128.png”
}
}

好的,这对我很有效

[app.js]

var股票;
chrome.runtime.onMessage.addListener(函数(请求)
{
库存=请求;
$.get('https://myweb.com/GetData.php?THEDATA=“+库存,功能(数据)
{
});
});
$('#选项卡')。单击(函数()
{
创建({url:'https://stackoverflow.com/“,活动:false},函数(选项卡)
{
chrome.tabs.executeScript(tab.id,
{
代码:“chrome.runtime.sendMessage(mycommand);”
},()=>chrome.runtime.lastError);
chrome.tabs.remove(tab.id);
});
});