Mozilla Firefox’s one of the best features is the ability to use multiple logins on a specific website at the time, using the Multi-account containers feature. This feature is available as an extension for Firefox on the desktop, since Firefox 57.0, Firefox Quantum.
Cookies are contained with the color-coded tabs on the same browser session, allowing one to use multiple logins of a particular website at the same time. You can learn more on how this feature works here.
The Facebook container is made by Mozilla, while the Google container is a fork by another developer.
When you activate these extensions on your Firefox browser, your Facebook and Google cookies are deleted. The next time you visit Google or Facebook, the respective content will open on a tab that is contained within this container.
This means, Facebook and Google will no longer will able to read your activities on other websites. You can safely contain to browser other websites that you need, as usual, and these tabs will open on your regular container.
Only Facebook and Google sites will load on their specific containers.
Something even better is that, these extensions do not necessarily apply only to
I read the code a bit, and it looks like most Facebook-owned domains are listed which includes WhatsApp and Instagram.
blogspot domains are contained within the Google container.
It should be possible that you can extend this code to other domains that Facebook and Google own as well, or fork the original Mozilla code for Facebook container and write your extension.