Khan Academy Custom Profile

Allows you to change the avatar image on Khan Academy.

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

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

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

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

您需要先安装一款用户脚本管理器扩展,例如 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);
})();