Could I make a Google Chrome extension for chrome pages (downloads, extensions etc)?

后端 未结 3 1572
难免孤独
难免孤独 2020-12-19 20:29

I\'d like to make a very simple extensions that slightly alters how the Downloads page looks. Changing the History page might be interesting too, but that\'s for later.

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-19 21:14

    As this page shows, there is no API to override the downloads page... However, there is a way to make a file you have made replace the chrome://downloads/ page whenever it is loaded using javascript in your background page...

    chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab){
      if(changeInfo.status === "loading"){
        if(tab.url === "chrome://downloads/"){
          chrome.tabs.update(tab.id, {url: "REPLACEMENT.html"});
        } 
      }
    });
    

    Essentially what this does is - As soon as the page chrome://downloads begins loading (using the tabs.onUpdated API), the page is redirected to REPLACEMENT.html (Using tabs.update API)... There is no visible delay in the tab update as this script is run before the chrome://downloads page begins loading... You can use a similar code in your file by pressing CTRL + U on the downloads page to view and copy its source code

提交回复
热议问题