在chrome://扩展页面访问扩展 [英] Access extensions in the chrome://extensions page

查看:139
本文介绍了在chrome://扩展页面访问扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的 mainfest.json

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

但我无法在 chrome:// extensions / 页面中寻找内容脚本

help !!!

but I cannot find content script in the chrome://extensions/ page
help!!!

推荐答案

您可以在PC上启用 chrome:// flags /#extensions-on-chrome-urls ,然后添加在manifest.json中将必要的网址 chrome:// extensions / ,转换为matches,但此类扩展名不会由于无效的方案错误,可以在普通浏览器上安装。

You can do it on your PC by enabling chrome://flags/#extensions-on-chrome-urls and adding the necessary url, chrome://extensions/, into "matches" in manifest.json but such extension won't be possible to install on a normal browser due to an invalid scheme error.

为避免致命错误,请勿使用manifest.json注入内容脚本/样式,通过 chrome.tabs.insertCSS chrome.tabs.executeScript 手动在后台或弹出脚本中手动执行:

To avoid the fatal error, don't use manifest.json to inject the content script/style, do it manually in the background or popup script via chrome.tabs.insertCSS or chrome.tabs.executeScript:


  • chrome:// flags :enable chrome上的扩展:// URLs flag

  • manifest.json:

  • chrome://flags: enable Extensions on chrome:// URLs flag
  • manifest.json:

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


  • 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网上应用店。

    Beware of possible problems submitting such extension to the Chrome Webstore.

    这篇关于在chrome://扩展页面访问扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆