Programmatically (or optionally) override Chrome's New Tab page

后端 未结 3 1983
旧时难觅i
旧时难觅i 2020-12-05 08:53

I\'ve written a Chrome extension that overrides the New Tab page:

manifest.json:

  \"chrome_url_overrides\": {
    \"newtab\": \"new         


        
3条回答
  •  旧时难觅i
    2020-12-05 09:49

    Google made a Star Wars new tab replacement which allows you to view the default new tab page. The url it uses is chrome-search://local-ntp/local-ntp.html.

    Example:

    options.html:

     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" })
     }
    })
    

提交回复
热议问题