In a stupid simple attempt to take back control of my browsing history I decided to remove every entry from search engine with an addon.

It actually is 23 loc as I hardcoded some values to fit my needs.

litterers = [
        'duckduckgo\.com$',
        'google\.com$',
        'google\.it$',
];

regexes = litterers.map((str) => { return new RegExp(str) })

function preventLittering(historyItem)
{
        console.log(historyItem.url);
        history_url = new URL(historyItem.url);
        console.log(history_url);
        if (regexes.some((regex) => { return history_url.hostname.match(regex) }))
        {
                console.log('Hostname match, will try to delete');
                var deletion = browser.history.deleteUrl({'url': historyItem.url});
        }
}

if (!browser.history.onVisited.hasListener(preventLittering))
{
        browser.history.onVisited.addListener(preventLittering)
}