Always Hi-Res c.ai Avatars

Always request high-res (400px) user/character avatars all the time instead of mixing in low-res (80px) avatars in some places.

As of 21. 12. 2023. See the latest version.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Always Hi-Res c.ai Avatars
// @namespace    logan.usw
// @version      1.0
// @description  Always request high-res (400px) user/character avatars all the time instead of mixing in low-res (80px) avatars in some places.
// @author       astrov0id
// @match        https://beta.character.ai/*
// @match        https://plus.character.ai/*
// @icon         https://characterai.io/static/favicon_v2.ico
// @run-at       document-idle
// @license      Unlicense
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const observer = new MutationObserver(mList => { // set up a mutationobserver to process every new element
        mList.forEach(m => {
            const allimgs = m.target.querySelectorAll("img[src^=\"https://characterai.io/i/80\"]"); // retrieve every low-res avatar image in a new element
            allimgs.forEach(i => { // make every low-res avatar high-res by replacing /i/80 in the img's src with /i/400
                i.src = "https://characterai.io/i/400/" + i.src.slice(28);
                // console.debug(window.location.pathname + ": https://characterai.io/i/80/" + i.src.slice(29) + ' => ' + i.src); // debugging code, disabled in production
            });
        });
    });

    observer.observe(document.body, {attributes: false, childList: true, characterData: false, subtree: true}); // start the mutationobserver
})();