Skip to content

Commit

Permalink
修复错误
Browse files Browse the repository at this point in the history
  • Loading branch information
Eternaldeath committed Jun 29, 2022
1 parent 1f0bfe7 commit 1e6926d
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions whereToWatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// @icon https://www.google.com/s2/favicons?sz=64&domain=douban.com
// @grant GM_xmlhttpRequest
// @grant GM_addStyle
// @connect https://www.yysub.net/*
// @connect yysub.net
// @license MIT
// ==/UserScript==

Expand All @@ -19,7 +19,6 @@ function getMovieNameFromDouBan() {
const returnAns = new Promise(function (resolve, reject) {
getMovieId(movieName, resolve, reject)
}).then(function (val) {
console.log("返回值:", val)
if (val[0] === 1) {
createHTML(val[1])
createCss()
Expand All @@ -28,6 +27,10 @@ function getMovieNameFromDouBan() {
createHTML(val[1])
createCss()
displayNoneByRes(val[0])
} else if (val[0] === -1) {
createHTML(val[1])
createCss()
displayNoneByRes(val[0])
}
})
}
Expand All @@ -51,7 +54,7 @@ function createHTML(url) {
)
</span>
</h2>
<ul>
<ul class="ulInfo">
<li>
<span>人人影视</span>
<span>
Expand All @@ -60,7 +63,13 @@ function createHTML(url) {
<span>暂无资源</span>
<span></span>
</li>
</ul>`
</ul>
<ul class="ulError">
<li>
<span>请求失败</span>
</li>
</ul>
`

aside.insertBefore(wrap, subject_doulist)
}
Expand Down Expand Up @@ -110,14 +119,23 @@ function createCss() {
*/
function displayNoneByRes(res) {
let span = document.querySelectorAll(".subject-wheretowatch ul span")
console.log(span)
let ulError = document.querySelector(".subject-wheretowatch .ulError")
let ulInfo = document.querySelector(".subject-wheretowatch .ulInfo")


if (res === 1) {
// 隐藏“暂无资源”
span[2].style.cssText = 'display: none'
// 隐藏请求失败模块
ulError.style.cssText = 'display: none'
} else if (res === 0) {
// 隐藏“资源链接”
span[1].style.cssText = 'display: none'
span[2].style.cssText = 'color: #FF0000; font-weight: bold'
// 隐藏请求失败模块
ulError.style.cssText = 'display: none'
} else if (res === -1) {
ulInfo.style.cssText = 'display: none'
}
}

Expand Down Expand Up @@ -149,12 +167,11 @@ function getMovieId(movieName, resolve, reject) {
// 传递的数组
info = [1, "https://www.yysub.net/resource/list/" + movieId]
}

resolve(info)
},
onerror: function (response) {
console.log("请求失败");
let info = [0, ""]
console.log("请求失败", response);
let info = [-1, ""]
reject(info)
}
});
Expand Down

0 comments on commit 1e6926d

Please sign in to comment.