Skip to content

Commit

Permalink
Merge pull request #377 from andywang425:dev
Browse files Browse the repository at this point in the history
6.1.3
1.适配B站更新:使用新版API,修复脚本一直报错"API.x.getAccinfo获取账号信息失败 状态码200"以及出现多个控制按钮/面板的问题。
2.调整了部分运行逻辑,在加载阶段如果脚本发生致命错误将直接停止运行而不是无限重试。
  • Loading branch information
andywang425 committed Apr 30, 2023
2 parents 0d0dd4b + 868c544 commit 8d369e1
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 25 deletions.
16 changes: 11 additions & 5 deletions B站直播间挂机助手.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// @compatible firefox 77 or later
// @compatible opera 69 or later
// @compatible safari 13.1 or later
// @version 6.1.2
// @version 6.1.3
// @match *://live.bilibili.com/*
// @exclude *://live.bilibili.com/?*
// @run-at document-start
Expand All @@ -29,7 +29,7 @@
// @require https://fastly.jsdelivr.net/gh/andywang425/BLTH@bca9261faa84ffd8f804c85c1a5153d3aa27a9a3/assets/js/library/Ajax-hook.min.js
// @require https://fastly.jsdelivr.net/npm/jquery@3.2.1/dist/jquery.min.js
// @require https://fastly.jsdelivr.net/gh/andywang425/BLTH@4dbe95160c430bc64757580f07489bb11e766fcb/assets/js/library/bliveproxy.min.js
// @require https://fastly.jsdelivr.net/gh/andywang425/BLTH@4235a14b9dd4d0d498ee89068a5916b95b65ab27/assets/js/library/BilibiliAPI_Mod.min.js
// @require https://fastly.jsdelivr.net/gh/andywang425/BLTH@3405976768951e35af4433ed0f563cbf26aece9f/assets/js/library/BilibiliAPI_Mod.min.js
// @require https://fastly.jsdelivr.net/gh/andywang425/BLTH@4368883c643af57c07117e43785cd28adcb0cb3e/assets/js/library/layer.min.js
// @require https://fastly.jsdelivr.net/gh/andywang425/BLTH@f9fc6466ae78ead12ddcd2909e53fcdcc7528f78/assets/js/library/Emitter.min.js
// @require https://fastly.jsdelivr.net/npm/hotkeys-js@3.8.7/dist/hotkeys.min.js
Expand Down Expand Up @@ -513,14 +513,15 @@
return window.toast(`直播间礼物数据获取失败 ${response.message}\n使用默认数据`, 'warning');
}
});
let reqFailed = false;
await BAPI.getuserinfo().then((re) => {
MYDEBUG('InitData: API.getuserinfo', re);
if (re.code === 'REPONSE_OK') {
Live_info.uname = re.data.uname;
Live_info.user_level = re.data.user_level;
} else {
window.toast(`API.getuserinfo 获取用户信息失败 ${re.message}`, 'error');
return delayCall(() => loadInfo());
reqFailed = true;
}
});
await BAPI.x.getAccInfo(Live_info.uid).then((re) => {
Expand All @@ -530,9 +531,11 @@
Live_info.vipStatus = re.data.vip.status;
} else {
window.toast(`API.x.getAccInfo 获取账号信息失败 ${re.message}`, 'error');
return delayCall(() => loadInfo());
reqFailed = true;
}
});
if (reqFailed)
return window.toast(`缺少必要的数据,挂机助手停止运行`, 'error')
Live_info.bili_jct = BAPI.getCookie('bili_jct');
Live_info.ruid = W.BilibiliLive.ANCHOR_UID;
Live_info.rnd = W.BilibiliLive.RND;
Expand Down Expand Up @@ -816,7 +819,10 @@
const cache = SP_CONFIG.lastShowUpdateMsgVersion || '0';
if (versionStringCompare(cache, version) === -1) {
// cache < version
const clientMliList = [`【自动切换最高清晰度】出于性能和兼容性考虑改为选择<code>原画</code>。`];
const clientMliList = [
`适配B站更新:使用新版API,修复脚本一直报错"API.x.getAccinfo获取账号信息失败 状态码200"以及出现多个控制按钮/面板的问题。`,
`调整了部分运行逻辑,在加载阶段如果脚本发生致命错误将直接停止运行而不是无限重试。`
];
function createHtml(mliList) {
if (mliList.length === 0) return '无';
let mliHtml = '';
Expand Down
6 changes: 3 additions & 3 deletions B站直播间挂机助手.user.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

## 一些建议

- 请确保能正常访问 `gcore.jsdelivr.net` 这个网站,脚本每次安装后初次运行时会从该网站获取依赖。[可以点我](https://gcore.jsdelivr.net/npm/lodash@4.17.10/core.min.js)测试你能否正常访问。若不能,请在脚本每次安装后初次运行时想办法让依赖被获取到,之后即可正常使用。
- 请确保能正常访问 `fastly.jsdelivr.net` 这个网站,脚本每次安装后初次运行时会从该网站获取依赖。[可以点我](https://fastly.jsdelivr.net/npm/lodash@4.17.10/core.min.js)测试你能否正常访问。若不能,请在脚本每次安装后初次运行时想办法让依赖被获取到,之后即可正常使用。
- 初次使用时若出现看不到控制面板的情况,请等待一会或尝试刷新(`ctrl+F5`)页面。
- 部分设置更改后需要刷新页面才能生效。
- 使用前建议先关闭广告拦截插件,并确认相关浏览器设置(如 cookie 权限,脚本拦截)否则该脚本可能无法正常运行。
Expand Down Expand Up @@ -85,7 +85,7 @@

#### 控制台日志

- 打开控制台(Chrome 可以按`F12``ctrl + shift + i`,再点击`Console`)在 Filter 中输入`BLTH`即可过滤出本脚本的控制台日志。
- 打开控制台(Chrome 可以按`F12``ctrl + shift + i`,再点击`Console`)在 Filter 中输入`BLTH`即可过滤出本脚本的控制台日志。
_注:某些意料之外的报错不会带有`BLTH`字样,反馈 bug 时请多加注意。_
- 脚本默认关闭控制台日志。勾选控制面板上的`其他设置 - 控制台日志`即可开启。

Expand All @@ -103,8 +103,8 @@

## 已知问题

1. [#12](https://github.com/andywang425/BLTH/issues/12)
本脚本可能与[Bilibili-Evolved](https://github.com/the1812/Bilibili-Evolved)存在兼容性问题导致脚本窗口无法正确加载。若出现此问题,请尝试在 Bilibili-Evolved 设置-其它中,将`加载模式`设置为延后。
1. [#12](https://github.com/andywang425/BLTH/issues/12)
本脚本可能与[Bilibili-Evolved](https://github.com/the1812/Bilibili-Evolved)存在兼容性问题导致脚本窗口无法正确加载。若出现此问题,请尝试在 Bilibili-Evolved 设置-其它中,将`加载模式`设置为延后。
开启`简化直播间`功能后聊天栏顶部的日志文字无法正确地被隐藏/显示成黄色,不过不影响使用。
2. 脚本每次更新后第一次运行可能会不工作,`shift+F5`刷新一下页面即可。
3. 可能和[SteamWebIntegration](https://github.com/Revadike/SteamWebIntegration)存在冲突导致同时运行时页面无响应。可以在 SteamWebIntegration 的设置中把 B 站直播间添加到黑名单。
Expand Down
23 changes: 18 additions & 5 deletions assets/js/library/BilibiliAPI_Mod.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name BilibiliAPI_mod
// @namespace https://github.com/SeaLoong
// @version 3.1.5
// @version 3.1.6
// @description BilibiliAPI,PC端抓包研究所得,原作者是SeaLoong。我在此基础上补充新的API。
// @author SeaLoong, andywang425
// @require https://code.jquery.com/jquery-3.6.0.min.js
Expand Down Expand Up @@ -1192,7 +1192,7 @@ var BAPI = {
}
});
},
getAccInfo: (mid, jsonp = 'jsonp') => {
getAccInfoOld: (mid, jsonp = 'jsonp') => {
return BAPI.ajax({
url: '//api.bilibili.com/x/space/acc/info',
data: {
Expand All @@ -1201,6 +1201,19 @@ var BAPI = {
}
})
},
getAccInfo: (mid, token = '', platform = 'web', web_location = '1550101') => {
return BAPI.ajax({
url: '//api.bilibili.com/x/space/wbi/acc/info',
data: {
mid: mid,
platform: platform,
token: token,
web_location: web_location,
wts: BAPI_ts_s(),
w_rid: CryptoJS.MD5(BAPI_ts_ms()).toString() // fake w_rid
}
})
},
getCoinInfo: (callback, jsonp, aid, _) => { //获取视频投币状态
return BAPI.ajax({
url: '//api.bilibili.com/x/web-interface/archive/coins',
Expand Down Expand Up @@ -1556,7 +1569,7 @@ var BAPI = {
}
});
},
likeReportV3: (roomid, anchor_id ) => {
likeReportV3: (roomid, anchor_id) => {
return BAPI.ajaxWithCommonArgs({
method: 'POST',
url: '/xlive/app-ucenter/v1/like_info_v3/like/likeReportV3',
Expand Down Expand Up @@ -1715,7 +1728,7 @@ var BAPI = {
/**
* 发私信
* @param
{
{
{
sender_uid: number,
receiver_id: number,
Expand Down Expand Up @@ -1762,7 +1775,7 @@ var BAPI = {
},
/**
* 发起 GM_xmlhttpRequest 请求
* @param {*} config
* @param {*} config
* @returns {Promise}
*/
GMR: (config) => {
Expand Down
4 changes: 2 additions & 2 deletions assets/js/library/BilibiliAPI_Mod.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/json/notice.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "6.1.2"
"version": "6.1.3"
}
2 changes: 1 addition & 1 deletion assets/json/notice.min.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"6.1.2"}
{"version":"6.1.3"}
8 changes: 4 additions & 4 deletions assets/markdown/greasyfork_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

## 一些建议

- 请确保能正常访问 `gcore.jsdelivr.net` 这个网站,脚本每次安装后初次运行时会从该网站获取依赖。[可以点我](https://gcore.jsdelivr.net/npm/lodash@4.17.10/core.min.js)测试你能否正常访问。若不能,请在脚本每次安装后初次运行时想办法让依赖被获取到,之后即可正常使用。
- 请确保能正常访问 `fastly.jsdelivr.net` 这个网站,脚本每次安装后初次运行时会从该网站获取依赖。[可以点我](https://fastly.jsdelivr.net/npm/lodash@4.17.10/core.min.js)测试你能否正常访问。若不能,请在脚本每次安装后初次运行时想办法让依赖被获取到,之后即可正常使用。
- 初次使用时若出现看不到控制面板的情况,请等待一会或尝试刷新(`ctrl+F5`)页面。
- 部分设置更改后需要刷新页面才能生效。
- 使用前建议先关闭广告拦截插件,并确认相关浏览器设置(如 cookie 权限,脚本拦截)否则该脚本可能无法正常运行。
Expand Down Expand Up @@ -77,7 +77,7 @@

#### 控制台日志

- 打开控制台(Chrome 可以按`F12``ctrl + shift + i`,再点击`Console`)在 Filter 中输入`BLTH`即可过滤出本脚本的控制台日志。
- 打开控制台(Chrome 可以按`F12``ctrl + shift + i`,再点击`Console`)在 Filter 中输入`BLTH`即可过滤出本脚本的控制台日志。
_注:某些意料之外的报错不会带有`BLTH`字样,反馈 bug 时请多加注意。_
- 脚本默认关闭控制台日志。勾选控制面板上的`其他设置 - 控制台日志`即可开启。

Expand All @@ -100,8 +100,8 @@

## 已知问题

1. [#12](https://github.com/andywang425/BLTH/issues/12)
本脚本可能与[Bilibili-Evolved](https://github.com/the1812/Bilibili-Evolved)存在兼容性问题导致脚本窗口无法正确加载。若出现此问题,请尝试在 Bilibili-Evolved 设置-其它中,将`加载模式`设置为延后。
1. [#12](https://github.com/andywang425/BLTH/issues/12)
本脚本可能与[Bilibili-Evolved](https://github.com/the1812/Bilibili-Evolved)存在兼容性问题导致脚本窗口无法正确加载。若出现此问题,请尝试在 Bilibili-Evolved 设置-其它中,将`加载模式`设置为延后。
开启`简化直播间`功能后聊天栏顶部的日志文字无法正确地被隐藏/显示成黄色,不过不影响使用。
2. 脚本每次更新后第一次运行可能会不工作,`shift+F5`刷新一下页面即可。
3. 可能和[SteamWebIntegration](https://github.com/Revadike/SteamWebIntegration)存在冲突导致同时运行时页面无响应。可以在 SteamWebIntegration 的设置中把 B 站直播间添加到黑名单。
Expand Down
2 changes: 2 additions & 0 deletions assets/markdown/update-log.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
## 完整更新日志
> ### 6.1.3
> 1.适配B站更新:使用新版API,修复脚本一直报错"API.x.getAccinfo获取账号信息失败 状态码200"以及出现多个控制按钮/面板的问题。2.调整了部分运行逻辑,在加载阶段如果脚本发生致命错误将直接停止运行而不是无限重试。
> ### 6.1.2
> 1.【自动切换最高清晰度】出于性能和兼容性考虑改为选择原画。
> ### 6.1.1
Expand Down

0 comments on commit 8d369e1

Please sign in to comment.