Facebook Marketplace Profile Link

Adds a user's Marketplace profile link to their main profile page

// ==UserScript==
// @name         Facebook Marketplace Profile Link 
// @description  Adds a user's Marketplace profile link to their main profile page
// @match        https://www.facebook.com/*
// @version      0.4
// @author       mica
// @namespace    greasyfork.org/users/12559
// @license      MIT
// @grant        GM.xmlHttpRequest
// ==/UserScript==

function makeLink(id) {
    const link = document.createElement('a');
        link.href = 'https://www.facebook.com/marketplace/profile/' + id;
        link.id = 'mpLink';
        link.style.position = 'relative';
        link.style.top = '29px';
        link.style.color = 'rgb(101, 103, 107)';
        link.style.fontSize = '15px';
        link.style.fontWeight = '600';
        link.innerText = 'Marketplace';
    document.querySelectorAll('span').forEach(e => {
        if (e.innerText == 'More') {
            e.closest('div[aria-haspopup]').parentNode.parentNode.append(link);
        }
    });
}

function getId() {
    if (location.pathname == '/profile.php') {
        makeLink(new URLSearchParams(location.search).get('id'));
    } else if (location.pathname == '/friends/suggestions/') {
        makeLink(new URLSearchParams(location.search).get('profile_id'));
    } else {
        GM.xmlHttpRequest({
            method: 'get',
            url: location.origin + location.pathname,
            onload: response => makeLink(response.responseText.match(/(?<=userID":")\d*/g)[0])
        });
    }
}

var url;
setInterval(() => {
    if (url != location.href) {
        url = location.href;
        setTimeout(() => {
            if (!document.querySelector('#mpLink') &&
                !location.pathname.match(/^\/$|\/groups*|\/messages*|\/marketplace*|\/watch*|\/reel*|\/events*|\/gaming*|\/memories*|\/saved*|\/fundraisers*|\/pages*|\/settings*|\/help*|\/ads*/g) &&
                document.querySelectorAll('circle[cx="84"]')) {
                getId();
            }
        }, 900);
    }
}, 200);