Chrome extension to reload page on load error

前端 未结 1 1525
一个人的身影
一个人的身影 2021-02-06 12:58

Because it isn\'t possible to use Greasemonkey for this, I want to write a Chrome extension that will reload a page if it initially failed to load.

I know how to write a

相关标签:
1条回答
  • 2021-02-06 13:32

    Use chrome.webNavigation.onErrorOccurred or chrome.webRequest.onErrorOccurred to detect navigation errors. These APIs cannot be used in a content script, so you have to add a background page or event page to your extension.

    I recommend to use the webNavigation API because these can also be used with event pages (unlike the webRequest API). Here is an example, use chrome.tabs.reload instead of chrome.tabs.update to get what you want.

    0 讨论(0)
提交回复
热议问题