Greasy Fork is available in English.

Bilibili Live Cover

Show Bilibili Live Cover

  1. // ==UserScript==
  2. // @name Bilibili Live Cover
  3. // @name:zh-CN 哔哩哔哩(bilibili.com)直播封面
  4. // @namespace hoothin
  5. // @version 0.5
  6. // @description Show Bilibili Live Cover
  7. // @description:zh-CN 在哔哩哔哩直播页面中显示封面
  8. // @grant GM_xmlhttpRequest
  9. // @run-at document-end
  10. // @author hoothin
  11. // @include http*://live.bilibili.com/*
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16. document.onreadystatechange = function(){
  17. if(document.readyState == "complete"){
  18. var anchorAvatar=document.querySelector(".head-info-section");
  19. var bigImg=document.createElement("img");
  20. bigImg.style.cssText="pointer-events: none;position:fixed;z-index:999";
  21. var uid=anchorAvatar.querySelector(".room-cover").href.replace(/[^\d]/gi,"");
  22. GM_xmlhttpRequest({
  23. method: 'GET',
  24. url: location.protocol+"//live.bilibili.com/bili/getRoomInfo/"+uid,
  25. onload: function(result) {
  26. let infoJson;
  27. try{
  28. infoJson=JSON.parse(result.responseText.replace(/^\(|\);$/g,""));
  29. }catch(e){
  30. console.log(e);
  31. return;
  32. }
  33. var coverA=document.createElement("a");
  34. coverA.href=infoJson.data.cover;
  35. coverA.target="_blank";
  36. coverA.style.marginLeft="20px";
  37. coverA.innerHTML='<div class="up-level-icon pointer" title="封面">封面</div>';
  38. document.querySelector(".room-info-down-row").appendChild(coverA);
  39. coverA.onmouseover=function(e){
  40. bigImg.src=coverA.href;
  41. document.body.appendChild(bigImg);
  42. };
  43. coverA.onmouseout=function(e){
  44. document.body.removeChild(bigImg);
  45. };
  46. coverA.onmousemove=function(e){
  47. bigImg.style.left=e.clientX+"px";
  48. bigImg.style.top=e.clientY+"px";
  49. };
  50. }
  51. });
  52. }
  53. };
  54. })();