FeatureFM Remove Tracking

Removes trackers from FeatureFM (ffm.to) platform links

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

You will need to install an extension such as Tampermonkey to install this script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name        FeatureFM Remove Tracking
// @description Removes trackers from FeatureFM (ffm.to) platform links
// @namespace   https://github.com/JunkiEDM
// @author      JunkiEDM
// @version     1.0
// @match       https://*.ffm.to/*
// @grant       none
// @license     GPLv3
// ==/UserScript==

document.querySelectorAll('a[href^="https://api.ffm.to"]').forEach((elm) => {
    let url = new URL(elm.href);
    if (url.searchParams.has('cd')) {
        let data = url.searchParams.get('cd').replaceAll('_','/').replaceAll('-','+');
        data = atob(data);
        data = JSON.parse(data);
        let destUrl = new URL(data.destUrl);
        if (destUrl.hostname == 'ffm.prf.hn') {
            let pathname = destUrl.pathname.split('/').splice(1);
            if (pathname[0] == 'click') {
                pathname.splice(1).forEach((opt) => {
                    opt = opt.split(':');
                    if (opt.length > 1 && opt[0] == 'destination') {
                        destUrl = new URL(decodeURIComponent(opt[1]));
                    }
                })
            }
        } else if (destUrl.hostname.includes('app.link')) {
            if (destUrl.searchParams.has('$desktop_url')) {
                destUrl = new URL(destUrl.searchParams.get('$desktop_url'));
            }
        }
        let trackingParams = ['ref','tag','ct','at','ls']
        trackingParams.forEach((p)=>{
            if (destUrl.searchParams.has(p)) {
                destUrl.searchParams.delete(p)
            }
        })
        elm.href = destUrl.href;
    }
})