0

Is there a way prevent tab from discarding without reloading when used

chrome.tabs.discard(tabId);

?

I have 2 extensions, one that discards tabs and second that manages it's own single tab and I need second extension protect it's tab from being discarded. My current work around is to listen on chrome.tabs.onReplaced event and reload the tab:

chrome.tabs.onReplaced.addListener((newTabId, oldTabId) =>
{
  chrome.tabs.reload(newTabId);
});

But is there a way undiscard a tab without reloading it, or better yet prevent discard in the first place?

vanowm
  • 9,466
  • 2
  • 21
  • 37
  • 1
    Chrome simply reloads the tab when it's clicked, there's no "undiscard". The only way to prevent discarding is to [modify that other extension](https://stackoverflow.com/a/16688027). – wOxxOm Aug 02 '22 at 06:35
  • You can try `chrome.tabs.update(id, { autoDiscardable: false })` to prevent being discarded. For more information, please read [this doc](https://developer.chrome.com/docs/extensions/reference/tabs/#method-update). – Yu Zhou Aug 03 '22 at 09:05

0 Answers0