Chrome extension action on shutdown

后端 未结 2 1297
情深已故
情深已故 2021-01-14 14:46

I\'m writing a very simple Chrome extension to automatically clear my history as this isn\'t a built in feature. I\'ve got it functional but just want to confirm I\'ve done

2条回答
  •  萌比男神i
    2021-01-14 15:14

    you are right, there's no way to execute anything on Chrome shutdown. Chrome doesn't have an onClose event. Not only literally, but metaphorically speaking: When Chrome closes, it doesn't wait for any extension to close.

    You can hang from chrome.windows.onRemoved and wait for the last window to close, but if Chrome is shutting down, it's not guaranteed your extension will have time to run it. Same thing with onSuspend, or whatever you find.

    So, if your implementation works, it won't be guaranteed to work in other Chrome.

    About chrome.history.deleteAll, I have the same problem, and will try with chrome.browsingData, a more modern and complete way to deal with browsing data, including history.

提交回复
热议问题