Greasy Fork is available in English.

豆瓣图片自动展开

把豆瓣图片自动展开

// ==UserScript==
// @name         豆瓣图片自动展开
// @version      0.1
// @description  把豆瓣图片自动展开
// @author       ✌
// @license      GPL 3.0
// @match        https://www.douban.com/group/topic/*
// @grant        none
// @namespace https://greasyfork.org/users/1384897
// ==/UserScript==

(function() {
    'use strict';

    function modifyImages() {
        document.querySelectorAll('div.cmt-img:not(.cmt-img-large)').forEach(div => {
            div.classList.add('cmt-img-large');

            let img = div.querySelector('img');
            if (img) {
                img.setAttribute('raw-style', img.getAttribute('style'));
                img.removeAttribute('style');
            }
        });
    }

    modifyImages();

    const observer = new MutationObserver(mutations => {
        mutations.forEach(mutation => {
            if (mutation.addedNodes.length > 0) {
                modifyImages();
            }
        });
    });

    observer.observe(document.body, { childList: true, subtree: true });
})();