HD BlueSky

Improves BlueSky's image quality by replacing image formats. When clicking an image, JPEGs are replaced with lossless PNGs. While browsing the site, JPEG thumbnails are replaced with full-sized AVIF images.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         HD BlueSky
// @author       Duskdyr
// @description  Improves BlueSky's image quality by replacing image formats. When clicking an image, JPEGs are replaced with lossless PNGs. While browsing the site, JPEG thumbnails are replaced with full-sized AVIF images.
// @match        *://*.bsky.app/*
// @grant        none
// @namespace    dskdr
// @license      MIT
// @version      1.0
// ==/UserScript==

(function() {
    'use strict';

    function imgrplcr() {
        document.querySelectorAll('img').forEach(img => {
            let url = img.src;

            if (url.includes('/feed_thumbnail') && url.includes('@jpeg')) {
                url = url.replace('@jpeg', '@avif');
                url = url.replace('/feed_thumbnail', '/feed_fullsize');
            }
            else if (url.includes('/feed_fullsize') && url.includes('@jpeg')) {
                url = url.replace('@jpeg', '@png');
            }
            if (img.src !== url) {
                img.src = url;
            }
        });
    }

    imgrplcr();

    const observer = new MutationObserver(imgrplcr);
    observer.observe(document.body, { childList: true, subtree: true });
})();