Don't use apps. It's a simple as that. 95% of the time they are not worth the incredible privacy invasion they impose on users.
https://www.mozillafoundation.org/en/privacynotincluded/cate...
Of course Facebook's JS won't add itself to websites, so half of the blame goes to webmasters willingly sending malware to browsers.