// ==UserScript== // @name Bilibili 哔哩哔哩动态查看原图 // @icon https://t.bilibili.com/favicon.ico // @namespace https://lolico.moe/ // @version 2.0 // @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 // @downloadURL none // ==/UserScript== (function() { 'use strict'; const sleep = ms => new Promise(resolve => setTimeout(resolve, ms)); const findBtn = async $imagesbox => { for (let i = 0; i < 200; i++) { const $btn = $imagesbox.find('.bp-v-middle:contains(查看大图)'); if ($btn.length > 0) return $btn; await sleep(50); } return null; }; $(document).click(async ({ target }) => { if (target.className !== 'img-content') return; const $imagesbox = $('.imagesbox:hover'); const $btn = await findBtn($imagesbox); if (!$btn) return; 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); }); })();