Khan Academy Custom Profile

Allows you to change the avatar image on Khan Academy.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Khan Academy Custom Profile
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Allows you to change the avatar image on Khan Academy.
// @author       ThatDoggoLover
// @match        *://www.khanacademy.org/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    function changeAvatar() {
        // Define the URL of your custom image the (only thing you need to change and don't erase the single quotes)
        var customImageUrl = 'https://i.imgur.com/g4hSoPc.gif';

        // Attempt to select the target element every 500 milliseconds until it is found
        var attemptToSelectElement = setInterval(function() {
            var avatarElement = document.querySelector('.user-avatar-background .avatar-pic');

            // If the avatar element is found, change the avatar image and stop attempting to select the element
            if (avatarElement) {
                avatarElement.src = customImageUrl;
                avatarElement.alt = 'Custom Avatar';
                clearInterval(attemptToSelectElement); // Stop the interval
            }
        }, 500); // Check every 500 milliseconds
    }

    // Run the function after the page has completely loaded
    window.addEventListener('load', changeAvatar);
})();