增强知乎推荐列表的视频屏蔽效果

This commit is contained in:
blackmatrix7 2021-06-16 09:44:47 +08:00
parent 87152ac7bd
commit 6291b34ccb

View File

@ -138,22 +138,6 @@ let magicJS = MagicJS(scriptName, "INFO");
// 推荐去广告与黑名单增强
case /^https:\/\/api\.zhihu\.com\/topstory\/recommend\?/.test(magicJS.request.url):
try {
let user_info = GetUserInfo();
let customBlockedUsers = magicJS.read(blockedUsersKey, user_info.id);
let keywords = magicJS.read(keywordBlockKey, user_info.id);
customBlockedUsers = !!customBlockedUsers ? customBlockedUsers : {};
keywords = !!keywords ? keywords : [];
let obj = JSON.parse(magicJS.response.body);
let data = obj["data"].filter((element) => {
// 修正由于JS number类型精度问题导致JSON.parse精度丢失引起视频无法自动播放的问题
try {
if (element.hasOwnProperty("extra") && element["extra"].hasOwnProperty("type") && element["extra"]["type"] === "zvideo") {
let video_id = element["common_card"]["feed_content"]["video"]["customized_page_url"].match(/https?:\/\/www\.zhihu\.com\/[^?]*\?(videoID|content_id)=(\d*)/)[1];
element["common_card"]["feed_content"]["video"]["id"] = video_id;
}
} catch (err) {
magicJS.logError(`修正视频自动播放失败\n异常信息:${err}\n响应数据:${JSON.stringify(element)}`);
}
// 判断是否是“盐选推荐内容”
function IsYanXuan(element) {
@ -191,12 +175,31 @@ let magicJS = MagicJS(scriptName, "INFO");
return flag;
}
let user_info = GetUserInfo();
let customBlockedUsers = magicJS.read(blockedUsersKey, user_info.id);
let keywords = magicJS.read(keywordBlockKey, user_info.id);
customBlockedUsers = !!customBlockedUsers ? customBlockedUsers : {};
keywords = !!keywords ? keywords : [];
let obj = JSON.parse(magicJS.response.body);
let data = obj["data"].filter((element) => {
// 修正由于JS number类型精度问题导致JSON.parse精度丢失引起视频无法自动播放的问题
try {
if (element.hasOwnProperty("extra") && element["extra"].hasOwnProperty("type") && element["extra"]["type"] === "zvideo") {
let video_id = element["common_card"]["feed_content"]["video"]["customized_page_url"].match(/https?:\/\/www\.zhihu\.com\/[^?]*\?(videoID|content_id)=(\d*)/)[1];
element["common_card"]["feed_content"]["video"]["id"] = video_id;
}
} catch (err) {
magicJS.logError(`修正视频自动播放失败\n异常信息:${err}\n响应数据:${JSON.stringify(element)}`);
}
let flag = !(
element["card_type"] === "slot_event_card" ||
element["card_type"] === "slot_video_event_card" ||
element.hasOwnProperty("ad") ||
// 取消以下两行注释,推荐列表拦截视频与直播
// 取消以下行注释,推荐列表拦截视频与直播
// element["extra"]["type"] === "drama" ||
// element["extra"]["type"] === "zvideo" ||
// element["extra"]["type"] === "Video" ||
// element["common_card"]["style"] === "BIG_IMAGE" ||
// 取消以下注释,推荐列表拦截“盐选推荐”
// IsYanXuan(element) ||
// 注释下行,推荐列表关闭关键字屏蔽功能