// ==UserScript== // @name Bilibili 哔哩哔哩动态查看原图 // @icon https://t.bilibili.com/favicon.ico // @namespace https://lolico.moe/ // @version 0.2 // @description 使新版哔哩哔哩动态可以查看原图以保存图片等 // @author Jindai Kirin // @match https://t.bilibili.com/ // @license GPL-3.0 // @grant none // @downloadURL none // ==/UserScript== (function() { 'use strict'; var origBtnHtml = '
  • 查看原图
  • '; //移除按钮 function removeBtn() { $(this).parent().find('.orig-btn').remove(); } //添加按钮 function setOrigBtn() { $('.imagesbox').each(function (i, ele) { //完成标志 if ($(ele).hasClass('orig-done')) return; else $(ele).addClass('orig-done'); //点击监听事件 $(ele).click(function () { //等待DOM完成渲染 setTimeout(function () { //按钮栏 var bc = $(ele).find('.boost-control'); if (bc.find('.orig-btn').length === 0) { $(bc.children()[1]).after(origBtnHtml); bc.find('.orig-btn').click(function () { window.open($(ele).find('.boost-img>img').attr('src').replace(/@.*/, '')); }); } $(bc.children()[0]).click(removeBtn); $(ele).find('.boost-img').click(removeBtn); }, 200); }); }); } window.onload = function () { var running = false; function run() { if (running) return; running = true; setOrigBtn(); setTimeout(function () { running = false; }, 2000); } //等待DOM完成渲染 setTimeout(run, 500); window.onscroll = run; } })();