【发布时间】:2014-10-09 10:14:24
【问题描述】:
因此,默认情况下,新标签页将替换为我的 Chrome 扩展程序(通过清单)。但是,我想提供禁用它的选项(以编程方式)。
我该怎么做?
【问题讨论】:
因此,默认情况下,新标签页将替换为我的 Chrome 扩展程序(通过清单)。但是,我想提供禁用它的选项(以编程方式)。
我该怎么做?
【问题讨论】:
Google 做了一个星球大战新标签替换,允许您查看默认的新标签页。它使用的 url 是 chrome-search://local-ntp/local-ntp.html。示例:
options.html:
<input type="checkbox"> Use default new tab page
options.js:
var checkbox = document.querySelector("input[type=checkbox]")
checkbox.addEventListener("click", function() {
chrome.storage.sync.set({ defaultnewtab: checkbox.checked })
})
newtab.js:
chrome.storage.sync.get("defaultnewtab", function(storage) {
if(storage.defaultnewtab) {
chrome.tabs.update({ url: "chrome-search://local-ntp/local-ntp.html" })
} })
【讨论】: