Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

多搜几次就卡住了,无法工作 #5

Open
KwToPA opened this issue Apr 19, 2024 · 1 comment
Open

多搜几次就卡住了,无法工作 #5

KwToPA opened this issue Apr 19, 2024 · 1 comment

Comments

@KwToPA
Copy link

KwToPA commented Apr 19, 2024

chrome 123
脚本 1.2
油猴 5.1

控制面板反馈

bili-header.umd.js:3 document.domain mutation is ignored because the surrounding agent cluster is origin-keyed.
biliMirror.umd.mini.js:1 333.337-没有对应配置,返回默认配置
biliMirror.umd.mini.js:1 bili-fe-mirror:1.6.3
video?keyword=%E6%A1…2400_1590854400:122 白屏检测是否正常 
{status: 'ok', loop: 0, data: {…}}

userscript.html?name…25-f6948908107b:146 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'data')
    at userscript.html?name…f6948908107b:146:34
    at new Promise (<anonymous>)
    at response.json (userscript.html?name…f6948908107b:145:24)
    at To (index.dc1b9335.js:1:6916)
    at index.dc1b9335.js:1:10555

TypeError: Cannot read properties of null (reading 'data') 这个报错内容,在综合或者视频 两个栏目中,均有发生

无论点击搜索栏中的什么指标,都会报错

谢谢

@KwToPA
Copy link
Author

KwToPA commented Apr 19, 2024

AI反馈

从你提供的错误信息来看,这个错误是在尝试读取一个为null的对象的’data’属性时发生的。这通常意味着你的脚本试图访问一个尚未初始化或者不存在的对象。这个错误出现在你的脚本的第146行

根据你提供的脚本,这个错误可能是在以下这段代码中产生的

let _responseJson = await originFetch(url, options).then(response => {
return response.json();
}).catch(err => {
return {
error: true
}
});
if(_responseJson.error) {
return;
}
if (_responseJson.data && _responseJson.data.result) {
if (_responseJson.data.result.length < pageSize) {
finished = true;
maxPage = actualPage;
}
responseJson = _responseJson;
let list = responseJson.data.result.filter(ele => ele.pubdate >= dateRange[0] && ele.pubdate <= dateRange[1]);
result = result.concat(list);
} else {
finished = true;
maxPage = actualPage;
}

在这段代码中,_responseJson是通过异步请求获取的。如果这个请求失败,_responseJson可能会是一个没有’data’属性的对象,这就可能导致你遇到的错误。

为了解决这个问题,你可以在访问_responseJson.data之前,先检查_responseJson是否存在。如果_responseJson不存在,你可以让你的函数返回一个错误信息,或者进行其他的错误处理

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant