|
1 | 1 | // ==UserScript== |
2 | 2 | // @name Bilibili Bangumi Cover |
3 | | -// @name:zh-CN 哔哩哔哩(bilibili.com)番剧封面 |
| 3 | +// @name:zh-CN 哔哩哔哩番剧封面 |
4 | 4 | // @namespace hoothin |
5 | | -// @version 0.6 |
| 5 | +// @version 0.7 |
6 | 6 | // @description Show Bilibili Bangumi Cover |
7 | 7 | // @description:zh-CN 在哔哩哔哩番剧页面中显示封面 |
8 | 8 | // @grant GM_xmlhttpRequest |
9 | 9 | // @author hoothin |
10 | 10 | // @include http*://bangumi.bilibili.com/anime/* |
| 11 | +// @include http*://www.bilibili.com/bangumi/play/* |
11 | 12 | // ==/UserScript== |
12 | 13 |
|
13 | 14 | (function() { |
14 | 15 | 'use strict'; |
15 | | - var vSmall=document.querySelector(".recom"); |
| 16 | + var vSmall=document.querySelector(".bangumi-recom"); |
| 17 | + console.log(vSmall); |
16 | 18 | if(!vSmall)return; |
17 | | - var title=document.createElement("h3"); |
| 19 | + var title=document.createElement("h4"); |
18 | 20 | title.id="coverTitle"; |
19 | | - title.classList.add("v1-bangumi-head-h3"); |
| 21 | + title.classList.add("recom-title"); |
20 | 22 | title.style.display="block"; |
21 | 23 | title.innerHTML="封面"; |
22 | 24 | var coverLink=document.createElement("a"); |
23 | 25 | var cover=document.createElement("img"); |
24 | 26 | cover.style.width="270px"; |
25 | 27 | coverLink.target="_blank"; |
26 | 28 | coverLink.appendChild(cover); |
27 | | - var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; |
| 29 | + /*var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; |
28 | 30 | var observer = new MutationObserver(function(records){ |
29 | | - if(!vSmall.querySelector("h3#coverTitle")){ |
30 | | - vSmall.insertBefore(coverLink,vSmall.firstChild); |
31 | | - vSmall.insertBefore(title,vSmall.firstChild); |
32 | | - refreshCover(); |
33 | | - } |
34 | 31 | }); |
35 | 32 | var option = { |
36 | 33 | 'childList': true |
37 | 34 | }; |
38 | | - observer.observe(vSmall, option); |
| 35 | + observer.observe(vSmall, option);*/ |
| 36 | + if(!vSmall.querySelector("h3#coverTitle")){ |
| 37 | + vSmall.insertBefore(coverLink,vSmall.firstChild); |
| 38 | + vSmall.insertBefore(title,vSmall.firstChild); |
| 39 | + refreshCover(); |
| 40 | + } |
39 | 41 | function refreshCover(){ |
40 | 42 | GM_xmlhttpRequest({ |
41 | 43 | method: 'GET', |
42 | | - url: "http://bangumi.bilibili.com/web_api/episode/"+location.hash.slice(1)+".json", |
| 44 | + url: "http://bangumi.bilibili.com/web_api/episode/"+location.href.replace(/.*ep/i,"")+".json", |
43 | 45 | onload: function(result) { |
| 46 | + console.log(11); |
44 | 47 | try { |
45 | 48 | var bangumiData = JSON.parse(result.responseText); |
46 | 49 | coverLink.href=cover.src=bangumiData.result.currentEpisode.cover; |
|
0 commit comments