Greasy Fork

Greasy Fork is available in English.

Bilibili 哔哩哔哩动态查看原图

使哔哩哔哩动态可以查看原图以保存图片等,同时也支持空间中的动态

当前为 2019-11-01 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Bilibili 哔哩哔哩动态查看原图
// @icon         https://t.bilibili.com/favicon.ico
// @namespace    https://lolico.moe/
// @version      2.1
// @description  使哔哩哔哩动态可以查看原图以保存图片等,同时也支持空间中的动态
// @author       Jindai Kirin
// @match        https://t.bilibili.com/*
// @match        https://space.bilibili.com/*
// @license      GPL-3.0
// @grant        none
// @run-at       document-end
// @require      https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js
// ==/UserScript==

(function() {
    'use strict';

    const findBtn = $imagesbox =>
        new Promise(resolve => {
            const $btn = $imagesbox.find('.bp-v-middle:contains(查看大图)');
            if ($btn.length > 0) {
                resolve($btn);
                return;
            }
            new MutationObserver((mutations, self) => {
                mutations.forEach(({ addedNodes }) => {
                    if (addedNodes.length > 0 && addedNodes[0].className === 'boost-wrap') {
                        self.disconnect();
                        resolve($imagesbox.find('.bp-v-middle:contains(查看大图)'));
                    }
                });
            }).observe($imagesbox[0], { childList: true });
        });

    $(document).click(async ({ target }) => {
        if (target.className !== 'img-content') return;
        const $imagesbox = $('.imagesbox:hover');
        const $btn = await findBtn($imagesbox);
        console.log($btn);
        const $newBtn = $($btn.prop('outerHTML').replace('大', '原'));
        $newBtn.click(() => {
            window.open(
                $imagesbox
                    .find('.boost-img img')
                    .attr('src')
                    .replace(/@.*/, '')
            );
        });
        $btn.after($newBtn);
        const removeBtn = () => $newBtn.remove();
        $imagesbox.find('.bp-v-middle:contains(收起)').one('click', removeBtn);
        $imagesbox.find('.boost-img').one('click', removeBtn);
    });
})();