Fill in profile pictures in the Family Section

None

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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