FeatureFM Remove Tracking

Removes trackers from FeatureFM (ffm.to) platform links

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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;
    }
})