/* The domain names Facebook phones home with, lowercased. */
const DOMAINS = ['facebook.com', 'facebook.net', 'fbcdn.net'];
/*
Determines whether any of a bucket of domains is part of a URL, regex free.
*/
function isMatching(url, domains) {
const DOMAIN_COUNT = domains.length;
for (var i = 0; i < DOMAIN_COUNT; i++) if (url.toLowerCase().indexOf(domains[i], 7) >= 7) return true;
// A valid URL has seven-plus characters ("http://"), then the domain.
}
/* Traps and selectively cancels a request. */
if (!isMatching(location.href, DOMAINS)) {
document.addEventListener("beforeload", function(event) {
if (isMatching(event.url, DOMAINS)) event.preventDefault();
}, true);
}