Fill in profile pictures in the Family Section

None

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         Fill in profile pictures in the Family Section
// @namespace    https://github.com/nate-kean/
// @version      20251106
// @description  None
// @author       Nate Kean
// @match        https://jamesriver.fellowshiponego.com/members/view/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=fellowshiponego.com
// @grant        none
// @license      MIT
// @run-at       document-end
// ==/UserScript==

(function() {
    for (const initial of document.querySelectorAll(".family-panel div.user-initials")) {
        const pictureLink = document.createElement("a");
        const holder = initial.parentNode;
        const entry = holder.parentNode;
        const link = entry.querySelector(`
            div.family-item-details > p:first-of-type > a,
            div:nth-child(3) > p:first-of-type > a
        `).href;
        pictureLink.href = link;
        const picture = document.createElement("img");
        // Hide it until we delete the initials element, to prevent it from showing up under the profile entry.
        picture.setAttribute("style", "visibility: hidden");
        picture.addEventListener("error", (event) => {
            // Account does not have a picture (or some other error occurred),
            // so roll back the changes and keep the initials.
            pictureLink.remove();
            return true;
        });
        picture.addEventListener("load", (event) => {
            // Success! Go ahead and remove the old initials element.
            initial.remove();
            picture.removeAttribute("style");
        });
        const uid = link.split("/").splice(-1)[0];
        picture.src = `/upload/jamesriver/profilePictures/${uid}_thumb.jpg`;
        picture.classList.add("user-picture", "img-circle");
        pictureLink.appendChild(picture);
        holder.appendChild(pictureLink);
    }
})();