From 53c4454b687072da64f8db8d1197cf76ea85b0b9 Mon Sep 17 00:00:00 2001 From: chouchoui <14866249+chouchoui@users.noreply.github.com> Date: Mon, 27 Jun 2022 22:44:36 +0800 Subject: [PATCH] =?UTF-8?q?refactor(bilibili):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E9=A6=96=E9=A1=B5=E5=8A=A8=E7=94=BBtab=EF=BC=8C=E5=85=BC?= =?UTF-8?q?=E5=AE=B9=E5=9B=BD=E9=99=85=E7=89=88=E6=88=91=E7=9A=84tab?= =?UTF-8?q?=EF=BC=8C=E9=A6=96=E9=A1=B5=E7=AB=96=E5=B1=8F=E6=92=AD=E6=94=BE?= =?UTF-8?q?=E5=99=A8=E5=B1=8F=E8=94=BD=EF=BC=8C=E4=BC=9A=E5=91=98=E8=B4=AD?= =?UTF-8?q?=E5=BC=80=E5=85=B3=20(#611)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复首页追番标签页重命名为动画 兼容国际版 我的tab 配合boxjs设置将首页推 荐中的竖屏播放器替换回普通播放器 配合boxjs设置在我的tab页面添加会员购 --- .gitignore | 1 + script/bilibili/bilibili_plus.js | 57 ++++++++++++++++++++------------ script/boxjs.json | 16 ++++++++- 3 files changed, 52 insertions(+), 22 deletions(-) diff --git a/.gitignore b/.gitignore index e12d753f7..bbdcdd1d4 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ to_blackmatrix7.js magic.json debug/ script/magicjs/server/ +.DS_Store diff --git a/script/bilibili/bilibili_plus.js b/script/bilibili/bilibili_plus.js index b965425ec..ef3d5a35c 100644 --- a/script/bilibili/bilibili_plus.js +++ b/script/bilibili/bilibili_plus.js @@ -1,6 +1,8 @@ const scriptName = "BiliBili"; const storyAidKey = "bilibili_story_aid"; const blackKey = "bilibili_feed_black"; +const bilibili_disable_index_story = "bilibili_disable_index_story"; +const bilibili_enable_mall = "bilibili_enable_mall"; let magicJS = MagicJS(scriptName, "INFO"); //Customize blacklist @@ -13,6 +15,9 @@ if (magicJS.read(blackKey)) { blacklist = defaultList.split(";"); } +const disableIndexStory = Boolean(magicJS.read(bilibili_disable_index_story)); +const enableMall = Boolean(magicJS.read(bilibili_enable_mall)); + (() => { let body = null; if (magicJS.isResponse) { @@ -24,25 +29,18 @@ if (magicJS.read(blackKey)) { let items = []; for (let item of obj["data"]["items"]) { if (item.hasOwnProperty("banner_item")) { - let bannerItems = []; - for (let banner of item["banner_item"]) { - if (banner["type"] === "ad") { - continue; - } else if (banner["static_banner"] && banner["static_banner"]["is_ad_loc"] != true) { - bannerItems.push(banner); - } - } - // 去除广告后,如果banner大于等于1个才添加到响应体 - if (bannerItems.length >= 1) { - item["banner_item"] = bannerItems; - items.push(item); - } + continue; } else if ( !item.hasOwnProperty("ad_info") && !blacklist.includes(item["args"]["up_name"]) && item.card_goto.indexOf("ad") === -1 && (item["card_type"] === "small_cover_v2" || item["card_type"] === "large_cover_v1") ) { + if (disableIndexStory) { + if (item.uri.includes("bilibili://story")) { + item.uri = item.uri.replace("bilibili://story", "bilibili://video"); + } + } items.push(item); } } @@ -86,7 +84,7 @@ if (magicJS.read(blackKey)) { // 545 首页追番tab,442 开始为概念版id 适配港澳台代理模式 const tabList = new Set([39, 40, 41, 545, 151, 442, 99, 100, 101, 554, 556]); // 尝试使用tab name直观修改 - const tabNameList = new Set(["直播", "推荐", "热门", "追番", "影视"]); + const tabNameList = new Set(["直播", "推荐", "热门", "动画", "影视"]); // 107 概念版游戏中心,获取修改为Story模式 const topList = new Set([176, 222, 107]); // 102 开始为概念版id @@ -131,14 +129,21 @@ if (magicJS.read(blackKey)) { try { let obj = JSON.parse(magicJS.response.body); // 622 为会员购中心, 425 开始为概念版id - const itemList = new Set([396, 397, 398, 399, 171, 172, 534, 8, 4, 428, 352, 1, 405, 402, 404, 544, 407, 410, 622, 425, 426, 427, 428, 171, 430, 431, 432]); + /* + 国际版 + 494 离线缓存 + 495 历史记录 + 496 我的收藏 + 497 稍后再看 + 500 联系客服 + 501 设置 + 741 我的钱包 + 742 稿件管理 + */ + const itemList = new Set([ + 396, 397, 398, 399, 171, 172, 534, 8, 4, 428, 352, 1, 405, 402, 404, 544, 407, 410, 425, 426, 427, 428, 171, 430, 431, 432, 494, 495, 496, 497, 500, 501, 741, 742, + ]); obj["data"]["sections_v2"].forEach((element, index) => { - element["items"].forEach((e) => { - if (e["id"] === 622) { - e["title"] = "会员购"; - e["uri"] = "bilibili://mall/home"; - } - }); let items = element["items"].filter((e) => { return itemList.has(e.id); }); @@ -147,6 +152,16 @@ if (magicJS.read(blackKey)) { delete obj["data"]["sections_v2"][index].tip_icon; delete obj["data"]["sections_v2"][index].tip_title; obj["data"]["sections_v2"][index]["items"] = items; + + if (element.title === "更多服务" && enableMall) { + element.items.unshift({ + id: 999, + title: "会员购", + icon: "http://i0.hdslb.com/bfs/archive/19c794f01def1a267b894be84427d6a8f67081a9.png", + common_op_item: {}, + uri: "bilibili://mall/home", + }); + } }); body = JSON.stringify(obj); } catch (err) { diff --git a/script/boxjs.json b/script/boxjs.json index 1ee697571..fe71ef19d 100644 --- a/script/boxjs.json +++ b/script/boxjs.json @@ -17,7 +17,7 @@ { "id": "blackmatrix7.bilibili", "name": "哔哩哔哩去广告", - "keys": ["bilibili_story_aid", "bilibili_feed_black"], + "keys": ["bilibili_story_aid", "bilibili_feed_black", "bilibili_disable_index_story", "bilibili_enable_mall"], "settings": [ { "id": "bilibili_feed_black", @@ -28,6 +28,20 @@ "autoGrow": true, "rows": 5, "desc": "以英文逗号分隔多个号码" + }, + { + "id": "bilibili_disable_index_story", + "name": "停用首页竖屏播放器", + "val": false, + "type": "boolean", + "desc": "首页推荐竖屏视频转为普通播放器" + }, + { + "id": "bilibili_enable_mall", + "name": "启用会员购", + "val": false, + "type": "boolean", + "desc": "我的tab-更多服务-添加会员购入口" } ], "author": "@blackmatrix7",