您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
右侧广告区域显示视频封面图
// ==UserScript== // @name bilibili显示封面 // @namespace http://tampermonkey.net/ // @version 0.1 // @description 右侧广告区域显示视频封面图 // @author You // @match https://www.bilibili.com/video/* // @grant none // ==/UserScript== (function() { 'use strict'; const coverImgUrl = document.head.querySelector('[itemprop="image"]').getAttribute('content').replace('http','https') const link = document.createElement('a') const title = document.querySelector('h1.video-title').innerText link.href = coverImgUrl link.setAttribute('target','_blank') link.id = 'link' const coverImg = document.createElement('img') coverImg.id='coverImg' coverImg.src = coverImgUrl coverImg.width = '320' coverImg.style.height = 'auto' coverImg.style.minHeight = '186px' coverImg.setAttribute('title',title) link.appendChild(coverImg) const targetNode = document.getElementById('slide_ad'); targetNode.innerHTML = '' targetNode.appendChild(link) const config = { attributes: true, childList: true, subtree: true }; const callback = function(mutationsList) { mutationsList.forEach(function (item, index) { if(Array.from(item.removedNodes).find((item)=>item.id==='link')){ targetNode.innerHTML = '' targetNode.appendChild(link) observer.disconnect(); } }); }; const observer = new MutationObserver(callback); observer.observe(targetNode, config); })();