深度社区图片优化

将深度社区帖子中查看图片的功能优化,让其具有放大缩小等功能,美化图片和标题排版。

// ==UserScript==
// @name         深度社区图片优化
// @namespace    deepin
// @version      0.1
// @description  将深度社区帖子中查看图片的功能优化,让其具有放大缩小等功能,美化图片和标题排版。
// @author       thepoy
// @match        https://bbs.deepin.org*/post/*
// @icon         https://bbs.deepin.org/favicon.ico
// @grant        none
// @license      MIT
// ==/UserScript==

(function () {
    'use strict';

    var new_style = document.createElement('style')
    new_style.innerHTML = `.imgBox {display:none!important;}
    .post_edit img:not(.emoji), .vditor-reset img:not(.emoji){display: block;
box-shadow: 0px 8px 16px 1px hsla(0, 0%, 0%, 0.3);
border-radius: 5px;
margin: 3rem auto;
max-width: 95% !important;
image-orientation: from-image;}
.post_edit h1, .vditor-reset  h1 {
text-align: center;
font-family: serif !important;
font-size: 2.5em !important;
font-weight: 900 !important;
margin-top: 1.5em !important;
}
.post_edit code, .vditor-reset code {
font-family: "Courier", Monaco, Consolas,"Liberation Mono",Menlo,Courier,monospace,"Apple Color Emoji","Segoe UI Emoji","Noto Color Emoji","Segoe UI Symbol","Android Emoji","EmojiSymbols" !important;
}
    `
    document.getElementsByTagName("head")[0].appendChild(new_style);

    var viewer_style = document.createElement("link");
    viewer_style.setAttribute('rel', 'stylesheet');
    viewer_style.setAttribute('href', 'https://cdn.jsdelivr.net/gh/fengyuanchen/viewerjs/dist/viewer.min.css');
    document.getElementsByTagName("head")[0].appendChild(viewer_style);

    var viewerjs = document.createElement("script");
    viewerjs.setAttribute("src", "https://cdn.jsdelivr.net/gh/fengyuanchen/viewerjs/dist/viewer.min.js");
    document.getElementsByTagName("head")[0].appendChild(viewerjs);

    const timer = () => {
        setTimeout(function () {
            if (!Viewer) {
                timer()
                return
            }

            const imgs = document.getElementsByClassName('post_edit')[0].querySelectorAll('img')
            for (const i of imgs) {
                const viewer = new Viewer(i, {
                    focus: false,
                    inline: false,
                    navbar: false,
                });

            }
        }, 500);
    }
    timer()

})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址