mirror of
https://github.com/blackmatrix7/ios_rule_script.git
synced 2024-12-25 00:29:14 +08:00
refactor(bilibili): 修复首页动画tab,兼容国际版我的tab,首页竖屏播放器屏蔽,会员购开关 (#611)
修复首页追番标签页重命名为动画 兼容国际版 我的tab 配合boxjs设置将首页推 荐中的竖屏播放器替换回普通播放器 配合boxjs设置在我的tab页面添加会员购
This commit is contained in:
parent
e54156e2f1
commit
53c4454b68
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,3 +3,4 @@ to_blackmatrix7.js
|
||||
magic.json
|
||||
debug/
|
||||
script/magicjs/server/
|
||||
.DS_Store
|
||||
|
@ -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) {
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user