Greasy Fork

Greasy Fork is available in English.

it之家评论区显示图片

it之家评论区自动显示图片,无需跳转到手机版

目前为 2024-06-12 提交的版本,查看 最新版本

// ==UserScript==
// @name        it之家评论区显示图片
// @namespace   http://tampermonkey.net/
// @version     1.0
// @description it之家评论区自动显示图片,无需跳转到手机版
// @author      daimiaopeng
// @match       https://*.ithome.com/*
// @icon        https://img.ithome.com/img/soft/ithome.svg
// ==/UserScript==

(function() {
    'use strict';

    // 找到所有 class 为 post-img-list c-1 的元素
    const elements = document.querySelectorAll('.post-img-list.c-1');

    // 遍历每个找到的元素
    elements.forEach(element => {
        // 获取 data-s 属性值
        const base64Data = element.getAttribute('data-s');

        // 如果存在 base64Data
        if (base64Data) {
            // 解码 base64Data
            const decodedData = atob(base64Data);

            // 创建 img 元素
            const imgElement = document.createElement('img');

            // 设置 img 元素的 src 为解码后的内容
            imgElement.src = decodedData;

            // 将 img 元素插入到当前元素的内部
            element.appendChild(imgElement);
        }
    });
})();