Clash/source/script/7f3c8323580b2d79dfe42a315656355a.js

69 lines
1.9 KiB
JavaScript
Raw Normal View History

2021-06-16 09:45:45 +08:00
const enabled_live = false; // 开启直播推荐,默认关闭
2021-04-09 19:34:05 +08:00
try {
let body = $response.body.replace(/\"room_id\":(\d{2,})/g,'"room_id":"$1"');
let obj = JSON.parse(body);
if (obj.data) obj.data = filter_data(obj.data);
2021-06-16 09:45:45 +08:00
if (obj.aweme_list) obj.aweme_list = filter_aweme_list(obj.aweme_list);
if (obj.aweme_detail) obj.aweme_detail = filter_aweme_detail(obj.aweme_detail);
2021-04-09 19:34:05 +08:00
$done({ body: JSON.stringify(obj) });
} catch (error) {
2021-06-16 09:45:45 +08:00
console.log("脚本运行错误,跳过处理。\n" + error);
2021-04-09 19:34:05 +08:00
$done({});
}
function filter_data(data) {
2021-06-16 09:45:45 +08:00
if (data && data.length > 0) {
let i = data.length;
while (i--) {
let element = data[i].aweme;
if (element.images) filter_images(element.images);
if (element.video) filter_videos(element);
2021-04-09 19:34:05 +08:00
}
}
return data;
}
2021-06-16 09:45:45 +08:00
function filter_aweme_list(aweme_list) {
if (aweme_list && aweme_list.length > 0) {
let i = aweme_list.length;
while (i--) {
let element = aweme_list[i];
if (element.is_ads == true) {
aweme_list.splice(i, 1);
} else if (element.images) {
filter_images(element.images);
} else if (element.video) {
filter_videos(element);
} else {
if (!enabled_live) aweme_list.splice(i, 1);
}
2021-04-09 19:34:05 +08:00
}
}
2021-06-16 09:45:45 +08:00
return aweme_list;
2021-04-09 19:34:05 +08:00
}
2021-06-16 09:45:45 +08:00
function filter_aweme_detail(aweme_detail) {
if (aweme_detail.images) filter_images(aweme_detail.images);
if (aweme_detail.video) filter_videos(aweme_detail);
return aweme_detail;
2021-04-09 19:34:05 +08:00
}
2021-06-16 09:45:45 +08:00
function filter_images(images) {
let j = images.length;
while (j--) {
images[j].download_url_list = images[j].url_list;
2021-04-09 19:34:05 +08:00
}
2021-06-16 09:45:45 +08:00
return images;
}
function filter_videos(videos) {
videos.status.reviewed = 1;
videos.video_control.allow_download = true;
videos.video_control.prevent_download_type = 0;
delete videos.video.misc_download_addrs;
const play_url = videos.video.play_addr;
videos.video.download_addr = play_url;
videos.video.download_suffix_logo_addr = play_url;
return videos;
2021-04-09 19:34:05 +08:00
}