MrOtherGuy / firefox-csshacks

Collection of userstyles affecting the browser
Mozilla Public License 2.0
3.13k stars 310 forks source link

Can the close button be disabled? #291

Open teknowledgist opened 1 year ago

teknowledgist commented 1 year ago

This is a crazy question and apologies if it is outside the scope of these CSS hacks.

I'm looking for a way to prevent accidental closure of a single-tab browser window. There is a nice AHK script/app called NoClose that will disable the close button for windows using standard (Windows) system window controls. It works in Windows for Firefox if the title bar is displayed. It doesn't prevent closure in numerous other ways, but does stop accidental clicks on the "X" in the corner.

Could something similar be done for Firefox using CSShacks when the title bar isn't displayed and/or in non-Windows?

Thanks!

MrOtherGuy commented 1 year ago

Certainly, you can simply use .titlebar-close{ display: none }

teknowledgist commented 1 year ago

Is that something that can be toggled on/off without a restart or possibly even per window?

MrOtherGuy commented 1 year ago

You can't achieve something like that with simply CSS. You could have an extension that toggles some specific window title for specific window if you like, and then use the existence of that window title prefix as a condition in your CSS to determine if the window close button should be hidden for that window. But yes, you would need an extension for that

teknowledgist commented 1 year ago

Got it. Not sure I want to learn how to make extensions just for this, but it's good to know.

Thanks!