Geoguessr change Avatar to Pin/ProfilePicture

Changes the Avatar to your Pin/Profile Picture. Works in Duels, Br, Profile and many more places and not only your Avatar but also the Avatar of others

当前为 2023-09-21 提交的版本,查看 最新版本

// ==UserScript==
// @name         Geoguessr change Avatar to Pin/ProfilePicture
// @description  Changes the Avatar to your Pin/Profile Picture. Works in Duels, Br, Profile and many more places and not only your Avatar but also the Avatar of others
// @version      3.4.2
// @license      MIT
// @author       joniber
// @match        https://www.geoguessr.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=geoguessr.com
// @namespace https://greasyfork.org/users/1072330
// ==/UserScript==

//any questons, feedback, problems or feature request -> Discord joniber

//=====================================================================================\\
//    change these values however you like (make sure to hit ctrl+s afterwards)        \\
//                PIN = PROFILE PICTURE                                                \\
//=====================================================================================\\

// replace the "true" with "false" if you would like to disable the feature

const PIN_IN_OWN_PROFILE = true;

const PIN_IN_OTHERS_PROFILE = true;

const PIN_IN_DUELS_MATCHMAKING = true;

const PIN_IN_BR_MATCHMAKING = true;

const NO_AVATARS_END_OF_DUEL = true;

const PIN_IN_TEAM_DUEL_PRIVATE_LOBBY = true;

const PIN_IN_FRIEND_TAB = true;

const PIN_IN_END_OF_BRS = true;

const PIN_IN_TEAM_DUELS_LOBBY = true;

const BETTER_FRAME_QUALITY = true;

const REPLACE_YOUR_AVATAR_IN_CHAT_WITH_YOUR_PROFILEPICTURE = true;


// Doesn't work on all devices. Disable if you have problems with the script
const REPLACE_THE_3_AVATAR_PICTURES_INGAME_BOTTOM_LEFT = false;

//=====================================================================================\\
//  don't edit anything after this point unless you know what you're doing             \\
//=====================================================================================\\

const GEOGUESSR_USER_ENDPOINT = 'https://geoguessr.com/api/v3/users';
const GEOGUESSR_ENDPOINT = 'https://geoguessr.com/api/v3/social';
const CHAT_ENDPOINT = 'https://game-server.geoguessr.com/api/lobby';
const MAP_ENDPOINT = 'https://geoguessr.com/api/maps';
const SCRIPT_PREFIX = 'up__';
const USER_PIN_CLASS = SCRIPT_PREFIX + 'userPin';
const USER_PIN_ID = SCRIPT_PREFIX + 'profilePin';
let framequality;
if (BETTER_FRAME_QUALITY) {
    framequality = 'high-quality';
} else {
    framequality = 'low-quality';
}

let av = null;
let index = 0;
let index1 = 0;
let player1 = null;
let player2 = null;
let starteChatObserverIndex = 0;

async function fillPin(pin, userId, withLvl, lvl, transparent) {
    if(!transparent && transparent != null){}
    else{
        pin.parentElement.style.backgroundColor = "transparent"
    }
    pin.setAttribute('src', "data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=");
    const userData = await getUserData(userId);
    const pinURL = userData.pin.url;
    if(withLvl){
        let level = roundToNearest10(userData.progress.level);
        lvl.parentElement.style.display="none"
        await lvl.setAttribute('src', `/static/avatars/tiers/${framequality}/tier-` + level + '.webp')
        await pin.setAttribute('src', '/images/auto/144/144/ce/0/plain/' + pinURL);
        lvl.parentElement.style.display = 'block'
    }
    else if(!withLvl){
        pin.setAttribute('src', '/images/auto/144/144/ce/0/plain/' + pinURL);
    }
}

async function fillLvl(lvl, userId) {
    const userData = await getUserData(userId);
    let level = roundToNearest10(userData.progress.level);

    lvl.setAttribute('src', `/static/avatars/tiers/${framequality}/tier-` + level + '.webp');
}

function fillImageMultiple(link, id, setLvl) {
    if (!link.querySelector(`.${USER_PIN_CLASS}`)) {
        if (wrapper) {
            link.firstChild.style.display = 'none';
            let destination = link;
            fillImage(link, link, id, true, setLvl);
        }
    }
}

async function changePinInFriendTab(link) {
    if (link) {
        if (!link.querySelector(`.${USER_PIN_CLASS}`)) {
            const wrapper = link.querySelector('[class^="transparent-avatar_imageWrapper__"]');
            if (wrapper) {
                wrapper.classList.remove('transparent-avatar_imageWrapper__izUAM');
                wrapper.classList.add(
                    'styles_circle__QFYEk',
                    'styles_variantFloating__Srm_N',
                    'styles_colorTransparent__2bG5I',
                    'styles_borderColorTransparent__CwSAk',
                    'styles_borderSizeFactorZero__MEFpf'
                );
                wrapper.insertAdjacentHTML('afterbegin', wrapperFriend1());
                const destination = link.querySelector('.styles_content__otIVG');
                const pin = destination.firstChild;
                let id = link.querySelector('.anchor_variantNoUnderline__SPwsd').href;
                const userId = retrieveIdFromLink(id);

                const userData = await getUserData(userId);
                const pinURL = userData.pin.url;
                pin.setAttribute('src', '/images/auto/48/48/ce/0/plain/' + pinURL);
                wrapper.lastChild.style = 'display:none';
            }
        }
    }
}

function fillImage(destination, link, id, c, withLvl) {
    if (c) {
        destination.insertAdjacentHTML('afterbegin', wrapperDuels());
        destination = link.querySelector('.profile-header_avatarWrapper__5_jDA.up__');
        destination.insertAdjacentHTML('afterbegin', wrapper());
        destination = link.querySelector('.avatar_titleAvatarImage__A51Dx.up__');
        destination.insertAdjacentHTML('beforeend', profilePicture());
        const pin = destination.lastChild;
        destination = link.querySelector('.styles_rectangle___6gqv.up__');
        destination.insertAdjacentHTML('beforeend', levelBorder());
        const lvl = destination.lastChild;
        fillPin(pin, retrieveIdFromLink(id), withLvl, lvl);
    } else {
        destination.insertAdjacentHTML('beforeend', wrapper());
        destination = document.querySelector('.avatar_titleAvatarImage__A51Dx.up__');
        destination.insertAdjacentHTML('beforeend', profilePicture1());
        const pin = destination.lastChild;
        destination = document.querySelector('.styles_rectangle___6gqv.up__');
        destination.insertAdjacentHTML('beforeend', levelBorder1());
        const lvl = destination.lastChild;
        fillPin(pin, retrieveIdFromLink(id), withLvl, lvl);

    }
}

function changeAvatarToPin(link, avatarToRemove) {
    if (!link.querySelector(`.${USER_PIN_CLASS}`)) {
        if (link) {
            let destination = null;
            if (avatarToRemove == link) {
                link.querySelector('.styles_image__8M_kp').style = 'display: none';
                destination = link.firstChild;
            } else {
                link.querySelector('.player-card_lobbyCardInner__G_xzy').firstChild.remove();
                destination = link.querySelector('.player-card_lobbyCardInner__G_xzy');
            }
            let id = '/me/profile';
            if (link.querySelector('.player-card_userLink__HhoDo') != null) {
                id = link.querySelector('.player-card_userLink__HhoDo').href;
            }
            fillImage(destination, link, id, true, true);
        }
    }
}

let pfpToLink = {};
let nameToLink = {};

const originalSend = WebSocket.prototype.send;
WebSocket.prototype.send = function (...args) {
    window.ws = this;
    if (this.geoguessrClickablePartyCards == 0) return originalSend.call(this, ...args);
    this.geoguessrClickablePartyCards = 0;
    const originalOnmessage = this.onmessage;
    this.onmessage = ({ data }) => {
        if (originalOnmessage != null) originalOnmessage({ data });
        const received = JSON.parse(data);
        if (received.code == 'PartyUpdated') {
            let payload = JSON.parse(received.payload);
            let players = payload.players;
            for (let player of players) {
                nameToLink[player.name] = 'user/' + player.id;
            }
        }
        if (received.code == 'PartyMemberListUpdated') {
            let payload = JSON.parse(received.payload);
            let members = payload.members;
            for (let member of members) {
                if (member.pin != '') pfpToLink[member.pin] = 'user/' + member.userId;
                if (member.fullBodyPin != ''){
                    pfpToLink[member.fullBodyPin] = 'user/' + member.userId;
                }

            }
        }
    };
    return originalSend.call(this, ...args);
};

function addPinToPartyCard(wrapper) {
    const image = wrapper.querySelector('.member-card_imageWrapper__5L2DF img');
    if (image) {
        const imgPin = image.src.substr(57);
        const id = pfpToLink[imgPin];
        if (id != null) {
            const link = wrapper.querySelector('.member-card_imageWrapper__5L2DF');
            fillImageMultiple(link, id, false);
        }
    }
}

function addPinToTeamDuelsCard(wrapper) {
    const name = wrapper
    .querySelector('.user-nick_nick__y4VIt')
    .innerHTML.replace('&nbsp', '')
    .replace(';', '');
    if (name) {
        if (nameToLink.length != 0) {
            const id = nameToLink[name];

            if (id) {
                const link = wrapper.querySelector('.team-player-card_lobbyCardInner__fT8A_');
                fillImageMultiple(link, id, true);
            }
        }
    }
}
let inBattleRoyale = false;
let inDuels = false;
let inDuelsLobby = false;
let inParty = false;
let inTeamDuel = false;
let lastOpenedMapHighscoreTab = 0;
let inGame = false;

function onMutationTeamDuel(mutations, observer) {
    if (!isTeamDuel()) return;

    const cards = document.querySelectorAll('.team-player-card_lobbyCard__7p_OY');
    for (let card of cards) {
        addPinToTeamDuelsCard(card);
    }

    if (document.querySelector('.game-finished_avatarContainer__S63IS')) {
        onMutationEnd();
    }
}

async function onMutationsDuelsLobby(mutations, observer) {
    if (!isDuels() || !document.querySelector('.bars_content__UVGlL')) return;

    const cards = document.querySelectorAll('.lobby_playerContainer__gWJ0s');
    for (let card of cards) {
        if (!card.querySelector('.up__')) {
            let id = card.querySelector('.lobby_nickContainer__3o2h0').firstChild.href;
            card.querySelector('.lobby_avatarContainer__kN2RK').firstChild.style.display = 'none';
            let destination = card.querySelector('.lobby_avatarContainer__kN2RK');
            fillImage(destination, card, id, true, true);
        }
    }
}

function onMutationParty(mutations, observer) {
    if (location.pathname != '/party') return;
    const cards = document.querySelectorAll('.member-card_root__zbBxx');
    for (let card of cards) {
        addPinToPartyCard(card);
    }
}

function onMutationEnd() {
    if (NO_AVATARS_END_OF_DUEL) {
        const gameFinishedAvatarContainer = document.querySelector(
            '.game-finished_avatarContainer__S63IS'
        );
        if (gameFinishedAvatarContainer) {
            if (document.querySelector('.styles_rectangle___6gqv.up__') == null) {
                gameFinishedAvatarContainer.firstChild.remove();
                let destination = gameFinishedAvatarContainer;
                destination.style = 'height: fit-content';
                destination.insertAdjacentHTML('afterbegin', wrapperDuels());
                destination = document.querySelector('.profile-header_avatarWrapper__5_jDA.up__');
                destination.insertAdjacentHTML('afterbegin', wrapper());
                document.querySelector('.profile-header_avatar__y6vsp').style =
                    'display:flex; justify-content:center; align-items:center';
                document.querySelector('.avatar_titleAvatar__0pdL9').style = 'width:20rem';
                destination = document.querySelector('.avatar_titleAvatarImage__A51Dx.up__');
                destination.insertAdjacentHTML('beforeend', profilePicture());
                const pin = destination.lastChild;
                let id = '/me/profile';
                fillPin(pin, retrieveIdFromLink(id), false);
                destination = document.querySelector('.styles_rectangle___6gqv.up__');
                destination.insertAdjacentHTML('beforeend', levelBorder());
                const lvl = destination.lastChild;
                if (
                    document.querySelector('.shadow-text_root__o3lD9').innerHTML.startsWith('YOU')
                ) {
                    fillLvl(lvl, retrieveIdFromLink(id));
                } else {
                    lvl.setAttribute(
                        'src',
                        '/_next/static/images/laurel-wreath-gold-53fd377e1d268ce57fcd6f0dfb9f3727.png'
                    );
                }
            }
        }
    }
}

async function onMutationsChat(mutations, observer) {
    if (REPLACE_YOUR_AVATAR_IN_CHAT_WITH_YOUR_PROFILEPICTURE) {
        for (let link of document
             .querySelector('.chat-log_scrollContainer__2Bt1m')
             .querySelectorAll('.chat-message_sharedRoot__ZUUD4')) {
            if (!link.querySelector('.up__newChat')) {
                if (link.querySelector('.chat-message_nick__AWtWr')) {
                    if (location.href != "https://www.geoguessr.com/party"){
                        const lobby = await getUsersInGame(location.href.slice(-36));

                        for (const player of lobby.players) {
                            const nickElement = link.querySelector('.chat-message_nick__AWtWr');
                            const img = link.querySelector('.chat-message_fullBodyAvatar__UT2e5');
                            const isPlayerNick = nickElement.textContent === player.nick;
                            const isUserNick = nickElement.textContent === 'You';

                            if (isPlayerNick || isUserNick) {
                                const playerId = isPlayerNick
                                ? player.playerId
                                : retrieveIdFromLink('/me/profile');
                                if (img.firstChild) {
                                    img.firstChild.classList.add('up__newChat');
                                    img.firstChild.style.borderRadius = '50%';
                                    img.firstChild.style.scale = 0.9;
                                    img.classList.add('chat-message_hasNoAvatarYet__xNRu9');
                                    fillPin(img.firstChild, playerId, false, 0, false);

                                }
                                break;
                            }
                        }
                    }
                }
            }
        }
    }
}

function onMutationsDuels(mutations, observer) {
    if (player1 == null) {
        player1 = document.querySelectorAll('.lobby_avatarContainer__kN2RK')[0];
        if (player1 != null) {
            player1.children[0].firstChild.remove();
            player1.children[0].remove();
            let destination1 = player1;
            destination1.insertAdjacentHTML('afterbegin', wrapperDuels());
            destination1 = document.querySelector('.profile-header_avatarWrapper__5_jDA.up__');
            destination1.insertAdjacentHTML('afterbegin', wrapper());
            destination1 = document.querySelector('.avatar_titleAvatarImage__A51Dx.up__');
            destination1.insertAdjacentHTML('beforeend', profilePicture());
            const pin = destination1.lastChild;
            let id = player1.lastChild.firstChild.href;

            destination1 = document.querySelector('.styles_rectangle___6gqv.up__');
            destination1.insertAdjacentHTML('beforeend', levelBorder());
            const lvl = destination1.lastChild;
            fillPin(pin, retrieveIdFromLink(id), true, lvl);

        }
        player2 = document.querySelectorAll('.lobby_avatarContainer__kN2RK')[1];
        if (player2 != null) {
            player2.children[0].firstChild.remove();
            player2.children[0].remove();
            let destination2 = player2;
            destination2.insertAdjacentHTML('afterbegin', wrapperDuels());
            destination2 = document.querySelectorAll(
                '.profile-header_avatarWrapper__5_jDA.up__'
            )[1];
            destination2.insertAdjacentHTML('afterbegin', wrapper());
            destination2 = document.querySelectorAll('.avatar_titleAvatarImage__A51Dx.up__')[1];
            destination2.insertAdjacentHTML('beforeend', profilePicture());
            const pin1 = destination2.lastChild;
            let id1 = player2.lastChild.firstChild.href;

            destination2 = document.querySelectorAll('.styles_rectangle___6gqv.up__')[1];
            destination2.insertAdjacentHTML('beforeend', levelBorder());
            const lvl1 = destination2.lastChild;
            fillPin(pin1, retrieveIdFromLink(id1), true, lvl1);
        }
    }
    if (player1 != null && player2 != null) {
        player1 = null;
        player2 = null;
    }

    if (document.querySelector('.overlay_overlay__AR02x')) {
        const endOfDuelsObserver = new MutationObserver(onMutationEnd);
        if (endOfDuelsObserver) {
            endOfDuelsObserver.observe(
                document.querySelector('.overlay_overlay__AR02x'),
                OBSERVER_CONFIG
            )
        }
    }
}

async function onMutationsStandard(mutations, observer) {
    if (isDuels() && !inDuels && document.querySelector('.game_hud__fhdo5')) {
        inDuels = true;
        const duelsObserver = new MutationObserver(onMutationsDuels);
        duelsObserver.observe(document.querySelector('.game_hud__fhdo5'), OBSERVER_CONFIG);
    } else if (isDuels() && !inDuelsLobby && document.querySelector('.bars_content__UVGlL')) {
        inDuelsLobby = true;
        const duelsLobbyObserver = new MutationObserver(onMutationsDuelsLobby);
        duelsLobbyObserver.observe(document.querySelector('.lobby_root__vk5a7'), OBSERVER_CONFIG);
    } else if (inDuels && !document.querySelector('.game_hud__fhdo5')) {
        inDuels = false;
    } else if (inDuelsLobby && !document.querySelector('.bars_content__UVGlL')) {
        inDuelsLobby = false;
    } else if (isParty() && !inParty) {
        inParty = true;
        const partyObserver = new MutationObserver(onMutationParty);
        partyObserver.observe(document.body, OBSERVER_CONFIG);
    } else if (inParty && !document.querySelector('.party_root__EQz_N')) {
        inParty = false;
    } else if (isTeamDuel() && !inTeamDuel) {
        inTeamDuel = true;
        const teamDuelObserver = new MutationObserver(onMutationTeamDuel);
        teamDuelObserver.observe(document.body, OBSERVER_CONFIG1);
    } else if (inParty && !document.querySelector('.lobby_root__Z9W2f')) {
        inTeamDuel = false;
    }
    else if(isGame() && !inGame){
        inGame = true
    }
    else if(inGame && !isGame()){
        !inGame
    }
   if(REPLACE_THE_3_AVATAR_PICTURES_INGAME_BOTTOM_LEFT){
    if (document.querySelector('.friend-chat-in-game-button_root__RX197')) {
        if (!document.querySelector('.friend-chat-in-game-button_root__RX197').querySelector('.up__friendchatingame')){
            let link = document.querySelector('.friend-chat-in-game-button_root__RX197')
            let index = 0
            const friends = await getFirstThreeFriends()
            for (const link1 of link.querySelectorAll('.friend-chat-in-game-button_avatar__FKoLP')){
                let pfp = friends[index].pin.url
                if (link1){
                    if (link1.querySelector('.transparent-avatar_imageWrapper__izUAM')) {
                        let imgLink1 = link1.querySelector('.transparent-avatar_imageWrapper__izUAM')
                        let imgLink = imgLink1.querySelector('.styles_image__8M_kp')
                        if (imgLink){
                            imgLink.setAttribute('src', '/images/auto/144/144/ce/0/plain/' + pfp)
                            imgLink.classList.add('up__friendchatingame')
                            imgLink.style.borderRadius = '50%'
                            link1.querySelector('.transparent-avatar_imageWrapper__izUAM').classList.remove('transparent-avatar_imageWrapper__izUAM')
                        }
                    }
                }
                index++
            }
        }
    }
   }
    if (document.querySelector('.chat-log_scrollContainer__2Bt1m')) {
        onMutationsChat()
    }

    if (inBattleRoyale || inDuels || inDuelsLobby || inGame) {
        return
    }

    if (PIN_IN_FRIEND_TAB) {
        for (const link of document.querySelectorAll('.chat-friend_content__zbEBt')) {
            changePinInFriendTab(link)
        }
        if (document.querySelector('.friend-chat_root__jUP5_')) {
            //checks if we are in friend chat
            if (document.querySelector('.friend-chat_root__jUP5_')) {
                let link = document.querySelector('.friend-chat_root__jUP5_'); //sets link to the whole chat
                //checks if the link exist (might be redundand)
                let friendchat = link.querySelector('.friend-list_friendList__ZlaGe'); //sets the left side of the whole friend chat (the names and avatars)
                if (!friendchat.lastChild.querySelector('.up__fc1')) {
                    //checks if one of the elements on that list has the "class already". If so it doesn't enter, if not it enters
                    index1 = 0
                    for (let i = 0; i < document.querySelectorAll('.friend-list_friend__3vXb_').length; i++){
                        //goes trough the whole list of elements meaning that each element with name and avatar gets checked seperatly. Not the same list than friendchat but that is the list where the links to their profiles are
                        let link1 = document.querySelectorAll('.friend-list_friend__3vXb_')[i]
                        if (link1.querySelector('.anchor_variantNoUnderline__SPwsd')) {
                            let linkwrapper = link1.querySelector('.anchor_variantNoUnderline__SPwsd') //selects the element that contains the profile link
                            //checks if it exists
                            let linktoprofile = linkwrapper.href.substring(31) //gets the id of the profile
                            let userData = await getUserData(linktoprofile) //gets the userdata trough the id
                            if (friendchat) {
                                //checks if the friendchat list of names exist
                                let link2 = friendchat.querySelectorAll('.friend-item_friendListItem__oF6Zk')[i]; //gets the equivalent element to the id
                                let destination187 = link2.querySelector('.transparent-avatar_imageWrapper__izUAM'); //gets the avatar wrapper from it
                                if (destination187 && !link2.querySelector('.up__fc1')) {
                                    //checks if it exist and if it didn't change the avatar to pfp already
                                    if (destination187.firstChild) {
                                        //gets the avatar of the avatar wrapper
                                        destination187.firstChild.style.display = 'none' //sets the avatar to display none
                                        destination187.insertAdjacentHTML('afterbegin', friendChat2()) //adds the code for the profile picture
                                        destination187.classList.add('transparent-avatar_background__M_sZ3','transparent-avatar_colorWhite20__fmhRd')
                                        if (destination187.classList.contains('transparent-avatar_imageWrapper__izUAM')) {
                                            destination187.classList.remove('transparent-avatar_imageWrapper__izUAM')
                                        }
                                        destination187.querySelector('.up__fc1').src = '/images/auto/48/48/ce/0/plain/' + userData.pin.url //adds the profile picture
                                    }
                                }
                            }
                        }
                    }
                }

                if (link.querySelector('.empty-chat_emptyChat__fXgOw')) {
                    let avatar = link.querySelector('.empty-chat_emptyChat__fXgOw')
                    let friendAvatarLink = ''
                    if (!avatar.querySelector('.up__fc')) {
                        if (avatar.querySelector('[data-nimg="fill"]')) {
                            friendAvatarLink = avatar.querySelector('[data-nimg="fill"]')
                        }
                        if (friendAvatarLink.src) {
                            let avatarLink = friendAvatarLink.src.substring(57)
                            if (avatarLink.startsWith('/')) {
                                avatarLink = avatarLink.substring(1)
                            }
                            let done = false
                            let friendchat = document.querySelector('.friend-list_friendList__ZlaGe')
                            for (const link1 of document.querySelectorAll('.chat-friend_content__zbEBt')) {
                                let linkwrapper = link1.querySelector('.anchor_variantNoUnderline__SPwsd')
                                if (linkwrapper) {
                                    let linktoprofile = linkwrapper.href.substring(31)
                                    let userData = await getUserData(linktoprofile)
                                    let fullbodypin = userData.fullBodyPin
                                    if (avatarLink == fullbodypin) {
                                        done = true
                                        //main avatar
                                        let destination = avatar.firstChild
                                        if (destination) {
                                            if (destination.firstChild) {
                                                destination.firstChild.style.display = 'none';
                                                destination.insertAdjacentHTML('afterbegin', friendChat())
                                                destination.querySelector('.up__fc').src = '/images/auto/192/192/ce/0/plain/' + userData.pin.url
                                                destination.classList.add('empty-chat_avatar__Yx0_i')
                                                if (destination.classList.contains('empty-chat_fullBodyAvatar__dUhe_')) {
                                                    destination.classList.remove('empty-chat_fullBodyAvatar__dUhe_')
                                                }
                                                if (avatar.querySelector('[data-nimg="fill"]')) {
                                                    avatar.querySelector('[data-nimg="fill"]').style.display = 'none'
                                                }
                                            }
                                        }
                                        //picture upper left
                                        let pictureupperleft = link.querySelector('.chat-view_mobileAvatar__xkXTK')
                                        if (pictureupperleft) {
                                            let destination = pictureupperleft.firstChild
                                            if (destination) {
                                                if (destination.firstChild) {
                                                    destination.firstChild.style.display = 'none';
                                                    destination.insertAdjacentHTML('afterbegin', friendChat2())
                                                    destination.querySelector('.up__fc1').src = '/images/auto/48/48/ce/0/plain/' + userData.pin.url
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            if (done == false) {
                                if (avatar.firstChild.firstChild) {
                                    avatar.firstChild.firstChild.style.display = 'none'
                                }
                            }
                        }
                    } else {
                        link.querySelector('.up__fc').classList.remove('up__fc')
                    }
                }
            }
        }
    }

    if (inParty) return;

    if (isProfile()) {
        if (!PIN_IN_OWN_PROFILE && isOwnProfile()) {
            return
        }
        if (!PIN_IN_OTHERS_PROFILE && isOtherProfile()) {
            return
        }
        if (!document.querySelector(`#${USER_PIN_ID}`)) {
            if (document.querySelector('.profile-header_fullBodyAvatar___LRnw')) {
                document.querySelector('.profile-header_fullBodyAvatar___LRnw').remove()
                let destination = document.querySelector('.profile-header_avatarWrapper__5_jDA')
                fillImage(destination, document, location.href, false, true)
            } else {
                if (document.querySelector('.profile-header_header__zAzxu .styles_rectangle___6gqv').lastChild.src.includes(framequality)) {
                    return;
                } else {
                    fillLvl(document.querySelector('.profile-header_header__zAzxu .styles_rectangle___6gqv').lastChild, retrieveIdFromLink(location.href))
                }
            }
        }
    }
    if (PIN_IN_END_OF_BRS) {
        if (document.querySelector('.popup-view_avatarView__lTsVQ')) {
            const avatarWrapper = document.querySelector('.popup-view_avatarView__lTsVQ')
            if (!document.querySelector(`#${USER_PIN_ID}`)) {
                if (avatarWrapper.firstChild) {
                    avatarWrapper.firstChild.style.display = 'none'
                    fillImage(avatarWrapper, document, '/me/profile', false, true)
                }
            }
        }
    }
    if (PIN_IN_BR_MATCHMAKING) {
        // battle royale matchmaking
        for (const link of document.querySelectorAll('.player-card_root__NvK_s')) {
            changeAvatarToPin(link, 'player-card_lobbyCardInner__G_xzy')
        }

        //                  if(document.querySelector('.avatar-lobby_wrapper__geAOu')){
//                      let lobbyWrapper = document.querySelector('.avatar-lobby_wrapper__geAOu')

//                      lobbyWrapper.querySelector('canvas').style.display = "none"
//                      if(document.querySelector('.lobby_contentMiddle__JWTt8')){

//                         const parent = document.querySelector('.lobby_contentMiddle__JWTt8')
//                         if (!parent.querySelector('.up__newbr')){
//                          while (parent.firstChild) {
//                              parent.firstChild.remove()

//                          }

//                             parent.insertAdjacentHTML('afterbegin', newbr());


//                      }
//                         }

        //             for (let link of document
        //                  .querySelector('.avatar-lobby_wrapper__geAOu')
        //                  .querySelectorAll('.avatar-title_titleWrapper__Jwldu')) {
        //                 if (!link.querySelector('.up__userPin')) {
        //                     if (link.querySelector('.user-nick_nick__y4VIt')) {
        //                         const lobby = await getUsersInGame(location.href.slice(-36));
        //                         console.log(lobby.players)
        //                         for (const player of lobby.players) {
        //                             if (!link.querySelector('.up__userPin')) {

        //                                 const nickElement = link.querySelector('.user-nick_nick__y4VIt').textContent;
        //                                 const isPlayerNick = nickElement.trim() == player.nick;
        //                                 console.log(player)
        //                                 if (isPlayerNick) {
        //                                     console.log("worked")
        //                                     const playerId = player.playerId
        //                                     let destination = link.querySelector('.user-nick_root__DUfvc').parentElement
        //                                     fillImage(destination, link, playerId, true, true)
        //                                     let imgW = link.querySelector('.avatar_titleAvatarImage__A51Dx.up__')

        //                                     link.querySelector('.avatar_titleAvatar__0pdL9').style.scale = 2
        //                                     link.querySelector('.avatar_titleAvatar__0pdL9').style.height = "220px"
        //                                     lobbyWrapper.firstChild.style.height="70%"

        //                                 }

        //                             }
        //                         }
        //                     }
        //                 }
        //             }


        //         }

    // }
    }
    if (PIN_IN_TEAM_DUELS_LOBBY) {
        if (document.querySelectorAll('.team-members_cardContainer__7vh_O')[0]) {
            const avatarWrapper = document.querySelectorAll('.team-members_cardContainer__7vh_O')[0];
            if (!document.querySelector(`.${USER_PIN_CLASS}`)) {
                if (avatarWrapper.firstChild) {
                    avatarWrapper.firstChild.style.display = 'none'
                    fillImage(avatarWrapper, document, '/me/profile', true, true)
                }
            }
        }
    }

    if (isDuels() && PIN_IN_DUELS_MATCHMAKING) {
        if (!document.querySelector(`#${USER_PIN_ID}`)) {
            if (av == null) {
                av = document.querySelector('.lobby_avatarContainer__kN2RK')
            }
            if (av != null) {
                av.children[0].remove()
                fillImage(av, document, retrieveIdFromLink('/me/profile'), false, true)
            }
            if (av != null) {
                av = null
            }
        }
    }

    if (document.querySelector('.join-party_avatarWrapper__2WzCN')) {
        let destination = document.querySelector('.join-party_avatarWrapper__2WzCN')
        if (!destination.querySelector(`#${USER_PIN_ID}`)) {
            if (destination.firstChild) {
                destination.firstChild.style.display = 'none'
                fillImage(destination, document, retrieveIdFromLink('/me/profile'), false, true)
            }
        }
    }

    if (document.querySelector('.maprunner-start-page_avatar__YJpub')) {
        document.querySelector('.maprunner-start-page_avatar__YJpub').style.visibility = 'hidden'
    }

    if (document.querySelector('.world-progress_avatar__ZeRuq')) {
        let destination = document.querySelector('.world-progress_avatar__ZeRuq')
        if (!destination.querySelector(`#${USER_PIN_ID}`)) {
            if (destination.firstChild) {
                destination.firstChild.style.display = 'none'
                destination.style.height = 'initial'
                fillImage(destination, document, retrieveIdFromLink('/me/profile'), false, true)
            }
        }
    }

    if (isCommunity() || isCommunityMaps()) {
        if (document.querySelector('.grid_grid__Hrqu6')) {
            for (let elements of document.querySelector('.grid_grid__Hrqu6').getElementsByTagName('a')) {
                if (!elements.querySelector(`.${USER_PIN_CLASS}`)) {
                    if (!elements.querySelector('.up__community')) {
                        let img = elements.querySelector('.community-map-card_avatar__Zd55l')
                        if (img) {
                            if (img.firstChild) {
                                img.firstChild.classList.add('up__community')
                                let mapLink = elements.href
                                let mapInfo = await getMapInfo(mapLink.slice(-24))
                                img.firstChild.style.display = 'none'
                                let imgWrapper = elements.querySelector('.community-map-card_avatarWrapper__33EXf')
                                imgWrapper.style.left = '1rem'
                                imgWrapper.style.top = '0rem'
                                imgWrapper.style.overflow = 'visible'
                                img.style.height = '100%'
                                fillImage(img, elements, mapInfo.creator.id, true, true)
                            }
                        } else {
                            let wrapper = elements.querySelector('.community-map-card_avatarWrapper__33EXf')
                            if(wrapper){
                                wrapper.insertAdjacentHTML('beforeend', community())
                            }
                        }
                    }
                }
            }
        }

        if (document.querySelector('.community-landing-page_gridItem--map-of-the-day__91lk_')) {
            let elements = document.querySelector('.community-landing-page_gridItem--map-of-the-day__91lk_').querySelector('a')
            if (!elements.querySelector(`.${USER_PIN_CLASS}`)) {
                if (!elements.querySelector('.up__community')) {
                    let img = elements.querySelector('.community-map-card_avatar__Zd55l')
                    if (img) {
                        if (img.firstChild) {
                            img.firstChild.classList.add('up__community')
                            let mapLink = elements.href
                            let mapInfo = await getMapInfo(mapLink.slice(-24))
                            img.firstChild.style.display = 'none'
                            let imgWrapper = elements.querySelector('.community-map-card_avatarWrapper__33EXf')
                            imgWrapper.style.left = '2.5rem'
                            imgWrapper.style.top = '0rem'
                            imgWrapper.style.overflow = 'visible'
                            img.style.height = '100%'
                            fillImage(img, elements, mapInfo.creator.id, true, true)
                        }
                    }
                }
            }
        }
    }
}

//helpfunctions
function roundToNearest10(zahl) {
     if(zahl == 200){
        return 200
    }
    else if (zahl % 10 === 0) {
        return zahl + 10
    }
    else {
        return Math.ceil(zahl / 10) * 10
    }
}

function retrieveIdFromLink(link) {
    if (link.endsWith('/me/profile')) {
        const data = document.querySelector('#__NEXT_DATA__').text
        const json = JSON.parse(data)
        return json.props.middlewareResults[1].account.user.userId
    }
    return link.split('/').at(-1)
}

function isOtherProfile() {
    return pathMatches('user/.+')
}

function isOwnProfile() {
    return pathMatches('me/profile')
}

function isProfile() {
    return isOwnProfile() || isOtherProfile()
}

function isBattleRoyale() {
    return pathMatches('battle-royale/.+')
}

function isMaprunner() {
    return pathMatches('maprunner')
}

function isCommunity() {
    return pathMatches('community')
}

function isCommunityMaps() {
    return pathMatches('community/.+')
}

function isParty() {
    return pathMatches('party')
}

function isTeamDuel() {
    return pathMatches('team-duels/.+')
}

function isDuels() {
    return pathMatches('duels/.+')
}

function isGame(){
    return pathMatches('game/.+')
}

async function getUserData(id) {
    const response = await fetch(`${GEOGUESSR_USER_ENDPOINT}/${id}`)
    const json = await response.json()
    return json
}

async function getFirstThreeFriends() {
    const response = await fetchWithCors(`${GEOGUESSR_ENDPOINT}/friends`)
    let json = await response.json()
    json = json.slice(0, 3)
    return json
}

async function getUsersInGame(id) {
    const response = await fetch(`${CHAT_ENDPOINT}/${id}`)
    const json = await response.json()
    return json
}

async function getMapInfo(id) {
    const response = await fetch(`${MAP_ENDPOINT}/${id}`)
    const json = await response.json()
    return json
}

async function fetchWithCors(url, method, body) {
    return await fetch(url, {
        headers: {
            accept: '*/*',
            'accept-language': 'en-US,en;q=0.8',
            'content-type': 'application/json',
            'sec-fetch-dest': 'empty',
            'sec-fetch-mode': 'cors',
            'sec-fetch-site': 'same-site',
            'sec-gpc': '1',
            'x-client': 'web',
        },
        referrer: 'https://www.geoguessr.com/',
        referrerPolicy: 'strict-origin-when-cross-origin',
        body: method == 'GET' ? null : JSON.stringify(body),
        method: method,
        mode: 'cors',
        credentials: 'include',
    })
}

function friendChat() {
    return `<div class="styles_circle__QFYEk styles_variantFloating__Srm_N styles_colorTransparent__2bG5I styles_borderColorTransparent__CwSAk styles_borderSizeFactorZero__MEFpf"><div class="styles_rectangle___6gqv" style="padding-top: 100%;"><div class="styles_innerCircle__Y_L_e"><div class="styles_content__otIVG"><img class="styles_image__8M_kp up__fc" loading="auto" style="object-fit: cover;"></div></div></div></div>`
}

function community() {
    return `<div class="community-map-card_avatar__Zd55l" style="height: 100%;"><img alt="" loading="lazy" decoding="async" data-nimg="fill" class="styles_image__8M_kp" src="" style="position: absolute; height: 100%; width: 100%; inset: 0px; object-fit: contain; color: transparent;"></div>`
}

function friendChat2() {
    return `<div class="styles_circle__QFYEk styles_variantFloating__Srm_N styles_colorTransparent__2bG5I styles_borderColorTransparent__CwSAk styles_borderSizeFactorZero__MEFpf"><div class="styles_rectangle___6gqv" style="padding-top: 100%;"><div class="styles_innerCircle__Y_L_e"><div class="styles_content__otIVG"><img alt="" loading="lazy" decoding="async" data-nimg="fill" class="styles_image__8M_kp up__fc1" style="position: absolute; height: 100%; width: 100%; inset: 0px; object-fit: cover; color: transparent;"></div></div></div></div>`
}
function wrapperFriend1() {
    return `<div class="styles_rectangle___6gqv" style="padding-top: 100%"><div class="styles_innerCircle__Y_L_e"><div class="styles_content__otIVG up__userPin"><img class="styles_image__8M_kp ${USER_PIN_CLASS}" loading="auto" style="object-fit: cover"></div></div></div>`
}

function wrapperFriend() {
    return `<div class="styles_circle__QFYEk  styles_variantFloating__Srm_N styles_colorTransparent__2bG5I styles_borderColorTransparent__CwSAk styles_borderSizeFactorZero__MEFpf"><div class="styles_rectangle___6gqv" style="padding-top: 100%"><div class="styles_innerCircle__Y_L_e"><div class="styles_content__otIVG up__"></div></div></div></div>`
}
function wrapperDuels() {
    return `<div class="profile-header_avatarWrapper__5_jDA up__"></div>`
}

function wrapperEndOfDuels() {
    return `<div class="profile-header_avatar__y6vsp up__"></div>`
}

function wrapper() {
    return `<div class="profile-header_avatar__y6vsp"><div class="avatar_titleAvatar__0pdL9"><div class="styles_rectangle___6gqv up__" style="padding-top: 100%"><div class="avatar_titleAvatarImage__A51Dx up__"></div></div></div></div>`
}

function profilePicture() {
    return `<img class="styles_image__8M_kp ${USER_PIN_CLASS}" loading="auto" style="object-fit:cover">`
}
function profilePicture1() {
    return `<img class="styles_image__8M_kp" id="${USER_PIN_ID}" loading="auto" style="object-fit:cover">`
}

function levelBorder() {
    return `<img alt="" class="${USER_PIN_CLASS}" loading="eager" decoding="async" data-nimg="fill" style="position:absolute;height:100%;width:100%;left:0;top:0;right:0;bottom:0;color:transparent" src="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=">`
}

function levelBorder1() {
    return `<img alt="" loading="eager" decoding="async" data-nimg="fill" id="${USER_PIN_ID}" style="position:absolute;height:100%;width:100%;left:0;top:0;right:0;bottom:0;color:transparent" src="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=" >`
}

function newbr(){
 return `
<div class="lobby_containerGrid__6utH8">
<div class="player-card_root__NvK_s">
<div class="player-card_lobbyCard___OpUa player-card_top__9sgjt player-card_activePlayerCard__11lUf">
<div class="player-card_lobbyCardInner__G_xzy">


</div>
</div>
<div class="player-card_avatarAnnotation__g6TOf player-card_top__9sgjt">
</div></div><div class="lobby_lobbyCard__98v5j">
<div class="lobby_emptySlotCircle__xWrtq">
<div class="lobby_emptySlotCircleInner__Eg7so">2</div></div></div><div class="lobby_lobbyCard__98v5j"><div class="lobby_emptySlotCircle__xWrtq"><div class="lobby_emptySlotCircleInner__Eg7so">3</div></div></div><div class="lobby_lobbyCard__98v5j"><div class="lobby_emptySlotCircle__xWrtq"><div class="lobby_emptySlotCircleInner__Eg7so">4</div></div></div><div class="lobby_lobbyCard__98v5j"><div class="lobby_emptySlotCircle__xWrtq"><div class="lobby_emptySlotCircleInner__Eg7so">5</div></div></div><div class="lobby_lobbyCard__98v5j"><div class="lobby_emptySlotCircle__xWrtq"><div class="lobby_emptySlotCircleInner__Eg7so">6</div></div></div><div class="lobby_lobbyCard__98v5j"><div class="lobby_emptySlotCircle__xWrtq"><div class="lobby_emptySlotCircleInner__Eg7so">7</div></div></div><div class="lobby_lobbyCard__98v5j"><div class="lobby_emptySlotCircle__xWrtq"><div class="lobby_emptySlotCircleInner__Eg7so">8</div></div></div><div class="lobby_lobbyCard__98v5j"><div class="lobby_emptySlotCircle__xWrtq"><div class="lobby_emptySlotCircleInner__Eg7so">9</div></div></div><div class="lobby_lobbyCard__98v5j"><div class="lobby_emptySlotCircle__xWrtq"><div class="lobby_emptySlotCircleInner__Eg7so">10</div></div></div></div><div class="lobby_settingsWrapper__064i6 lobby_visible__Nu3xr"><div class="game-options_root__ppDoQ"><div class="game-options_optionGroup__qNKx1"><div class="section_sectionHeader__WQ7Xz section_sizeMedium__yPqLK"><div class="bars_root___G89E"><span class="bars_content__UVGlL"><h2>Settings</h2></span><div class="bars_after__Z1Rxt bars_lengthLong__XyWLx"></div></div></div><div class="game-options_options__FqkjK"><div class="game-options_wrappingGroup__u3pGi"><label class="game-options_option__eCz9o game-options_editableOption__Mpvar"><div class="game-options_optionIcon__aPDpU"><div class="game-options_mapImage__BG5Y8"><img draggable="false" alt="World" loading="lazy" width="48" height="48" decoding="async" data-nimg="1" class="styles_image__8M_kp" src="https://www.geoguessr.com/images/auto/48/48/ce/0/plain/map/3f950f0318b9086b1b9ec591206dfdd8.jpg" style="color: transparent; object-fit: cover; height: 48px;"></div></div><div class="game-options_optionLabel__dJ_Cy">World</div><div class="game-options_optionInput__TAqdI"><button type="button" class="button_button__CnARx button_variantSecondary__lSxsR button_sizeSmall__POheY"><div class="button_wrapper__NkcHZ"><span class="button_label__kpJrA">Change</span></div></button></div></label><div class="game-options_wrappingGroup__u3pGi"><div class="game-options_wrapper__Cb74X"><img alt="" loading="lazy" width="640" height="512" decoding="async" data-nimg="1" class="game-options_infiniteTime__AWyF2" src="/_next/static/media/infinity-icon.3f0ee4cd.svg" style="color: transparent;"><label class="game-options_option__eCz9o game-options_editableOption__Mpvar"><div class="game-options_optionLabel__dJ_Cy">Round time</div><div class="game-options_optionInput__TAqdI"><div class="game-options_slider__JwEe2"><div class="styles_rangeslider__y45WS styles_variantPurple__qW7Yo" aria-valuemin="10" aria-valuemax="600" aria-valuenow="60" aria-orientation="horizontal"><div class="styles_fill__wyfWR" style="width: 21px;"></div><div class="styles_handle__zYRZ7" tabindex="0" style="left: 21px;"><div></div></div><ul class="styles_labels__5Sr0N"></ul></div></div></div><div class="game-options_optionLabel__dJ_Cy">1 min</div></label></div></div><label class="game-options_option__eCz9o game-options_editableOption__Mpvar"><div><div class="game-options_lives__wNSwd"><div class="game-options_roundButton__vyzCb"><img alt="-" loading="lazy" width="20" height="20" decoding="async" data-nimg="1" src="/_next/static/media/minus.7058d931.svg" style="color: transparent;"></div><div class="game-options_optionIcon__aPDpU"><img alt="" loading="lazy" width="48" height="48" decoding="async" data-nimg="1" class="rule-icons_icon__dcLov" srcset="/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fpin-distance.3b1babda.png&amp;w=48&amp;q=75 1x, /_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fpin-distance.3b1babda.png&amp;w=96&amp;q=75 2x" src="/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fpin-distance.3b1babda.png&amp;w=96&amp;q=75" style="color: transparent;"></div><div class="game-options_roundButton__vyzCb"><img alt="+" loading="lazy" width="20" height="20" decoding="async" data-nimg="1" src="/_next/static/media/plus.9238beaa.svg" style="color: transparent;"></div></div><div class="game-options_optionLabel__dJ_Cy">3 guesses</div></div></label></div><div class="game-options_wrappingGroup__u3pGi"><label class="game-options_option__eCz9o game-options_editableOption__Mpvar"><div class="game-options_optionIcon__aPDpU"><img alt="" loading="lazy" width="48" height="48" decoding="async" data-nimg="1" class="rule-icons_icon__dcLov" srcset="/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fmoving-allowed.169a3661.png&amp;w=48&amp;q=75 1x, /_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fmoving-allowed.169a3661.png&amp;w=96&amp;q=75 2x" src="/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fmoving-allowed.169a3661.png&amp;w=96&amp;q=75" style="color: transparent;"></div><div class="game-options_optionLabel__dJ_Cy">Move</div><div class="game-options_optionInput__TAqdI"><input readonly="" type="checkbox" class="toggle_toggle__hwnyw" checked=""></div></label><label class="game-options_option__eCz9o game-options_editableOption__Mpvar"><div class="game-options_optionIcon__aPDpU"><img alt="" loading="lazy" width="48" height="48" decoding="async" data-nimg="1" class="rule-icons_icon__dcLov" srcset="/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fpanning-allowed.e9c7555a.png&amp;w=48&amp;q=75 1x, /_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fpanning-allowed.e9c7555a.png&amp;w=96&amp;q=75 2x" src="/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fpanning-allowed.e9c7555a.png&amp;w=96&amp;q=75" style="color: transparent;"></div><div class="game-options_optionLabel__dJ_Cy">Pan</div><div class="game-options_optionInput__TAqdI"><input readonly="" type="checkbox" class="toggle_toggle__hwnyw" checked=""></div></label><label class="game-options_option__eCz9o game-options_editableOption__Mpvar"><div class="game-options_optionIcon__aPDpU"><img alt="" loading="lazy" width="48" height="48" decoding="async" data-nimg="1" class="rule-icons_icon__dcLov" srcset="/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fzooming-allowed.0f46b59b.png&amp;w=48&amp;q=75 1x, /_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fzooming-allowed.0f46b59b.png&amp;w=96&amp;q=75 2x" src="/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fzooming-allowed.0f46b59b.png&amp;w=96&amp;q=75" style="color: transparent;"></div><div class="game-options_optionLabel__dJ_Cy">Zoom</div><div class="game-options_optionInput__TAqdI"><input readonly="" type="checkbox" class="toggle_toggle__hwnyw" checked=""></div></label></div></div></div></div></div><div class="lobby_copyLinkWrapper__6Bzi_"><div class="section_sectionHeader__WQ7Xz section_sizeMedium__yPqLK"><div class="bars_root___G89E"><span class="bars_content__UVGlL"><h2>Invite friends</h2></span><div class="bars_after__Z1Rxt bars_lengthLong__XyWLx"></div></div></div><div class="section_sectionMedium__yXgE6"><span class="copy-link_root__dBcXL"><input type="text" name="copy-link" class="text-input_textInput__HPC_k" placeholder="" readonly="" autocomplete="on" value="https://www.geoguessr.com/battle-royale/57764b7f-0ef0-452f-98d4-5de5c9c06a6c"><div class="copy-link_button__71gBO"><button type="button" class="button_button__CnARx button_variantSecondary__lSxsR"><div class="button_wrapper__NkcHZ"><span class="button_icon__a2L5l"><img alt="Copy" loading="lazy" width="448" height="512" decoding="async" data-nimg="1" class="copy-link_icon__dVJNJ" src="/_next/static/media/copy.9d23a17d.svg" style="color: transparent;"></span></div></button></div></span></div></div>`
}

const OBSERVER_CONFIG = {
    characterDataOldValue: false,
    subtree: true,
    childList: true,
    characterData: false,
}

const OBSERVER_CONFIG1 = {
    characterDataOldValue: false,
    subtree: true,
    childList: true,
    characterData: true,
    attributes: true,
    attributeFilter: ['style'],
}

function pathMatches(path) {
    return location.pathname.match(new RegExp(`^/(?:[^/]+/)?${path}$`))
}

const observer = new MutationObserver(onMutationsStandard)

observer.observe(document.body, OBSERVER_CONFIG)