首页 > 解决方案 > 如何防止 chrome 扩展在 chrome:// url 上运行

问题描述

如果我尝试在 chrome:// url 上打开 popup.html,我的 Chrome 扩展程序会引发错误。

我设置了回调函数来防止这种情况:

/ Inject the payload.js script into the current tab after the popout has loaded
window.addEventListener('load', function (evt) {
  // catching injecting into chrome:// pages error
    chrome.extension.getBackgroundPage().chrome.tabs.executeScript(null, {
        file: 'js/payload.js'
  }, ()=>{
    if(chrome.runtime.lastError) {
      console.log("injecting error");
    }
    });;
});

然而,错误仍然出现。"chrome://*/"我的清单文件中有什么方法可以允许吗?

标签: javascriptjsongoogle-chrome-extension

解决方案


推荐阅读