gabrielmaldi / chrome-lock-tab

Chrome extension to prevent a tab from being closed accidentally
https://chrome.google.com/webstore/detail/lock-tab/nhbdiieigbgalknjplfpgmjnpbnkchnb
16 stars 1 forks source link

Addon works only after first interact with website #4

Closed kamilpastwa closed 1 year ago

kamilpastwa commented 1 year ago

How to reproduce

  1. Open new website
  2. Click Lock button
  3. 🔒 icon appears in tab
  4. Try to close tab (X button or ctrl+W or middle mouse button)

Expected result: page doesn't close, popup shows up. Actual result: page closes. Workaround: Interact with website (click anywhere on webpage).

Is there any way to fix it?

Windows 10
Chrome 108.0.5359.125 64-bit
Source of addon: https://chrome.google.com/webstore/detail/lock-tab/nhbdiieigbgalknjplfpgmjnpbnkchnb
gabrielmaldi commented 1 year ago

Hi, @kamilpastwa, thanks for using Lock Tab!

Unfortunately, from my experience, Chrome requires user interaction with the page to allow the extension to execute the beforeunload handler. I guess it'd be a security concern to allow an extension to prevent closing tabs just by executing code in the background, without the using clicking on the page.

I have tried a lot but haven't found another way to make the extension work (and don't think there is). But of course if you, or anyone, can suggest another approach, I'd love to try it! ❤️

Thanks again