Skip to content

Commit af3be7d

Browse files
committed
fix
1 parent cf66369 commit af3be7d

1 file changed

Lines changed: 6 additions & 19 deletions

File tree

Bilibili Bangumi Cover/Bilibili Bangumi Cover.user.js

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// ==UserScript==
22
// @name Bilibili Bangumi Cover
3-
// @name:zh-CN 哔哩哔哩(bilibili.com)番剧封面
3+
// @name:zh-CN 哔哩哔哩番剧封面
44
// @namespace hoothin
5-
// @version 0.5
5+
// @version 0.6
66
// @description Show Bilibili Bangumi Cover
77
// @description:zh-CN 在哔哩哔哩番剧页面中显示封面
88
// @grant GM_xmlhttpRequest
@@ -39,28 +39,15 @@
3939
function refreshCover(){
4040
GM_xmlhttpRequest({
4141
method: 'GET',
42-
url: bangumiIndex.href,
42+
url: "http://bangumi.bilibili.com/web_api/episode/"+location.hash.slice(1)+".json",
4343
onload: function(result) {
44-
var doc = null;
4544
try {
46-
doc = document.implementation.createHTMLDocument('');
47-
doc.documentElement.innerHTML = result.responseText;
48-
}
49-
catch (e) {
45+
var bangumiData = JSON.parse(result.responseText);
46+
coverLink.href=cover.src=bangumiData.result.currentEpisode.cover;
47+
}catch (e) {
5048
console.log(e);
5149
}
52-
if (!doc) {
53-
return;
54-
}
55-
var img=doc.querySelector("a.v1-complete-text[href='"+location.href.replace(/https?:/,"")+"']>div>img");
56-
if(img){
57-
coverLink.href=cover.src=img.getAttribute("src").replace(/\d+_\d+|_\d+x\d+\.jpg/,"");
58-
}
5950
}
6051
});
6152
}
62-
var bangumiIndex=document.querySelector(".v1-bangumi-info-title>a");
63-
if(bangumiIndex){
64-
refreshCover();
65-
}
6653
})();

0 commit comments

Comments
 (0)