2015-11-24 230 views
0

这里是我的mainfest.json访问扩展://扩展

"content_scripts": [ { 
    "all_frames": true, 
    "css": [ "css/event.css" ], 
    "matches": [ "\u003Call_urls>" ], 
    "run_at": "document_start" 
} 

但在chrome://extensions/
帮助,我无法找到内容脚本!

+1

我敢肯定,你不能这样做,因为它可能会在人们添加未被删除的扩展程序时引入安全风险。 –

+0

为什么你需要访问chrome:// extensions? –

回答

2

您可以通过启用chrome://flags/#extensions-on-chrome-urls,并添加必要的网址,chrome://extensions/,成manifest.json中,但这种扩展"matches"将无法​​安装在普通浏览器做你的电脑上,由于架构无效错误。

为了避免致命的错误,不使用manifest.json的注入内容脚本/风格,通过chrome.tabs.insertCSSchrome.tabs.executeScript做手工的背景或弹出脚本:

  • chrome://flags:使Extensions on chrome:// URLs标志
  • 的manifest.json:

    "permissions": ["chrome://*/*", "tabs"], 
    "background": { 
        "scripts": ["background.js"] 
    }, 
    
  • background.js:

    var chromeURLstylable; 
    chrome.permissions.contains({origins: ["chrome://*/*", "tabs"]}, function(state) { 
        chromeURLstylable = state; 
        console.log("chrome:// urls support", state); 
    
        if (chromeURLstylable) { 
         chrome.tabs.onUpdated.addListener(function(tabId, info, tab) { 
          if (info.status == "loading" && tab.url.indexOf("chrome://") == 0) { 
           chrome.tabs.insertCSS({ 
            file: "style.css", 
            runAt: "document_start", 
            allFrames: true 
           }); 
          } 
         }); 
        } 
    }); 
    

当心提交这种扩展到Chrome网络商店的可能问题。