brave / brave-browser

Brave browser for Android, iOS, Linux, macOS, Windows.
https://brave.com
Mozilla Public License 2.0
17.62k stars 2.29k forks source link

Add ungoogled chromium patch "popups-to-tabs" to Brave. #40959

Open hyperion4 opened 3 weeks ago

hyperion4 commented 3 weeks ago

Platforms

Linux, macOS, Windows

Description

Ungoogled chromium includes a nice chromium patch that makes chromium to open popups in new tabs. It can be applied by running chromium with the commandline --popups-to-tabs

https://github.com/ungoogled-software/ungoogled-chromium/blob/master/docs/flags.md

I would love if I would be able to never see a popup in Brave ever again, I hate popups. Other browsers have support for it, you can make all popups to open as tabs in Firefox by editing dom.popup_allowed_events in about:config. Vivaldi also has an option for that. There are extensions that can do it, but it is not a good experience, the popup is opened and then it is moved to a tab.

Please have a look at the patch ungoogled chromium uses and add it to Brave too. Please:)

This is the chromium patch, only 52 lines.

https://github.com/ungoogled-software/ungoogled-chromium/blob/master/patches/extra/ungoogled-chromium/add-flag-to-convert-popups-to-tabs.patch

hyperion4 commented 2 weeks ago

Since it is a priority P5 request (Not scheduled. Don't anticipate work on this any time soon.) I ended up trying to make it work myself with a userscript.

The extensions that add this feature like Open pop-up as tab , Open link in same tab pop-up as tab do not work properly. At least not the way I want it to work, reliably like it works natively in ungoogled chromium, Vivaldi and Firefox. The extensions open the popup and then it is moved to a tab, and many times they fail to do it.

So I ended up creating this script, it works perfectly. Bacically it modifies the open function of a window and always removes the properties from it, the properties are the ones responsible for how it will open, as a popup or a normal tab.

Of course I will use it until Brave implements the chromium patch, having this option natively is the ideal solution.

// ==UserScript== // @name Open pop-up as tab // @match *://*/* // @run-at document-start // @grant unsafeWindow // ==/UserScript== window.addEventListener('click', open, true); function open(e) { const windowOpen = unsafeWindow.open; unsafeWindow.open = function(url, target = 'defaultName', windowFeatures) { return windowOpen.call(unsafeWindow, url, target, undefined); }; }