首页 > 解决方案 > 创建扩展并尝试更改网页背景颜色但权限失败

问题描述

我正在尝试使用以下代码更改活动选项卡网页的背景颜色:

来自 popup.js 的代码

chrome.tabs.executeScript(null, {code:"document.body.bgColor='red'"});

manifest.json 的代码

"permissions": ["storage", "activeTab", "tabs", "<all_urls>"]

扩展错误日志将此报告为问题:

Unchecked runtime.lastError: Cannot access contents of url "chrome-search://local-ntp/local-ntp.html".
Extension manifest must request permission to access this host.

对于上述错误,我的活动标签中有 google.co.uk,我还尝试了其他网页以确认问题不是特定于特定网页。

为什么我的权限不包括这个?

标签: javascriptgoogle-chrome-extensionpermissions

解决方案


推荐阅读