Javascript Chrome扩展:无法在DOM中插入HTML,权限问题

Javascript Chrome扩展:无法在DOM中插入HTML,权限问题,javascript,google-chrome-extension,code-injection,Javascript,Google Chrome Extension,Code Injection,我的权限有问题,我想将我的javascript注入一个由https、http和文件提供服务的页面 在清单文件下面 以及注入的javascript background.js 我已经尝试过删除权限:[https://,http://,file://],但它不起作用 非常感谢您提供的任何帮助。提供所有权限的最快方法是,字面上包括 Rob W在评论中指出了您的另一个问题:indexOf'http://*/*/*'搜索带有星号的字符串 按照他的建议,您可以执行tab.url.indexOf'http:'

我的权限有问题,我想将我的javascript注入一个由https、http和文件提供服务的页面

在清单文件下面

以及注入的javascript background.js

我已经尝试过删除权限:[https://,http://,file://],但它不起作用


非常感谢您提供的任何帮助。

提供所有权限的最快方法是,字面上包括

Rob W在评论中指出了您的另一个问题:indexOf'http://*/*/*'搜索带有星号的字符串


按照他的建议,您可以执行tab.url.indexOf'http:'==0等操作。

不幸的是,对于堆栈溢出的公认格式来说,您的问题太广泛,可能会被关闭。此外,它也没有显示您已经尝试了什么(如果有的话)来实现扩展。请先尝试,然后再提出具体的、孤立的实施问题。请不要在问题中添加您的生活故事。我强烈建议您从文档开始。它解释了您不了解的体系结构的基础知识。至于Stack Overflow的公认格式,我看到您相对较新,所以请看一下.indexOf搜索子字符串。试试tab.url.indexOf'http:'==0 | |等。。我也尝试过使用.indexOf'http://*/*/*'而不是.indexOf'http://*/*,但它没有改变任何东西,我目前正在使用activeTab for。但是谢谢你的回答。@kitkatball在回答中添加了你的另一个问题。
{

    "background":{
        "scripts":["background.js"]
    },

    "permissions":["tabs"],

    "browser_action": {
        "default_icon": "img/icone.png",
        "default_title": "displayer."
    },

    "icons" : {
        "128" : "img/icone_128.png",
        "48" : "img/icone_48.png",
        "32" : "img/icone_32.png",
        "24" : "img/icone_24.png",
        "16" : "img/icone_16.png"
    },

    "manifest_version": 2,
    "name": "displayer.",
    "description": "This extension helps you to compare your wireframe with your current coded page..",
    "version": "1.0.1"

 }
chrome.browserAction.onClicked.addListener(function (tab) { //Fired when User Clicks ICON
    if (tab.url.indexOf("http://*/*, https://*/*, file://*/*") != -1) { // Inspect whether the place where user clicked matches with our list of URL
        chrome.tabs.executeScript(tab.id,
        {"file": "contentscript.js"},
        function () { // Execute your code
            console.log("Script Executed .. "); // Notification on Completion
        });
        chrome.tabs.insertCSS(null, {file: "grid.css"});
    }
});