Sync all projects
This commit is contained in:
@@ -0,0 +1,283 @@
|
||||
// ==UserScript==
|
||||
// @name gaze
|
||||
// @namespace gmspider
|
||||
// @version 2024.12.01
|
||||
// @description gaze GMSpider
|
||||
// @author Luomo
|
||||
// @match https://gaze.run/*
|
||||
// @require https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.slim.min.js
|
||||
// @require https://cdn.jsdelivr.net/npm/[email protected]/dist/ajaxhook.umd.min.js
|
||||
// @require https://cdn.jsdelivr.net/npm/[email protected]/dist/blob-util.min.js
|
||||
// @grant unsafeWindow
|
||||
// @run-at document-end
|
||||
// ==/UserScript==
|
||||
console.log(JSON.stringify(GM_info));
|
||||
(function () {
|
||||
Object.defineProperty(Object.prototype, '_detectLoopStopped', {
|
||||
set: function () {
|
||||
return true;
|
||||
},
|
||||
get: function () {
|
||||
console.log("devtools-detector disabled");
|
||||
return false;
|
||||
}
|
||||
});
|
||||
})();
|
||||
(function () {
|
||||
const GMSpiderArgs = {};
|
||||
if (typeof GmSpiderInject !== 'undefined') {
|
||||
let args = JSON.parse(GmSpiderInject.GetSpiderArgs());
|
||||
GMSpiderArgs.fName = args.shift();
|
||||
GMSpiderArgs.fArgs = args;
|
||||
} else {
|
||||
GMSpiderArgs.fName = "detailContent";
|
||||
GMSpiderArgs.fArgs = [true];
|
||||
}
|
||||
Object.freeze(GMSpiderArgs);
|
||||
|
||||
let _gotData = function (data) {
|
||||
console.log("_gotData hook failed", data)
|
||||
};
|
||||
let hookRequestUrl = "";
|
||||
const {unProxy, originXhr} = proxy({
|
||||
onRequest: (config, handler) => {
|
||||
let params = {};
|
||||
switch (GMSpiderArgs.fName) {
|
||||
case "categoryContent":
|
||||
let filter = GMSpiderArgs.fArgs[3];
|
||||
params = {
|
||||
mform: GMSpiderArgs.fArgs[0],
|
||||
mcountry: filter?.mcountry ?? "all",
|
||||
"tag_arr[]": filter?.mtag ?? "all",
|
||||
page: GMSpiderArgs.fArgs[1],
|
||||
sort: filter?.sort ?? "updatetime",
|
||||
album: "all",
|
||||
title: "",
|
||||
years: filter?.years ?? "all",
|
||||
};
|
||||
break;
|
||||
case "searchContent":
|
||||
let title = GMSpiderArgs.fArgs[0];
|
||||
params = {
|
||||
mform: "all",
|
||||
mcountry: "all",
|
||||
"tag_arr[]": "all",
|
||||
page: GMSpiderArgs.fArgs[2],
|
||||
sort: "updatetime",
|
||||
album: "all",
|
||||
title: GMSpiderArgs.fArgs[0],
|
||||
years: "all",
|
||||
};
|
||||
break;
|
||||
}
|
||||
if (config.url.includes("filter_movielist")) {
|
||||
if (!$.isEmptyObject(params)) {
|
||||
config.body = $.param(params)
|
||||
}
|
||||
}
|
||||
handler.next(config);
|
||||
},
|
||||
onResponse: (response, handler) => {
|
||||
if (response.config.url.includes("filter_movielist")) {
|
||||
let data = JSON.parse(response.response);
|
||||
_gotData(data);
|
||||
}
|
||||
handler.next(response);
|
||||
}
|
||||
}, unsafeWindow)
|
||||
|
||||
let _gotSrc = function (src) {
|
||||
console.log("_gotSrc hook failed", data)
|
||||
};
|
||||
let _player;
|
||||
Object.defineProperty(unsafeWindow, 'player', {
|
||||
configurable: true,
|
||||
get: () => _player,
|
||||
set: (player) => {
|
||||
_player = new Proxy(player, {
|
||||
get(target, prop) {
|
||||
if (prop === "src") {
|
||||
// console.log("src", src);
|
||||
return new Proxy(target[prop], {
|
||||
apply: (target, thisArg, argumentsList) => {
|
||||
_gotSrc(argumentsList[0]);
|
||||
// return false;
|
||||
return Reflect.apply(target, thisArg, argumentsList);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
return Reflect.get(target, prop);
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
});
|
||||
const GmSpider = (function () {
|
||||
function listVideos(result) {
|
||||
return new Promise(function (resolve) {
|
||||
_gotData = resolve;
|
||||
}).then(async (movieList) => {
|
||||
console.log("movelist", movieList);
|
||||
movieList.mlist.forEach(function (item) {
|
||||
result.list.push({
|
||||
vod_id: item.mid,
|
||||
vod_name: item.title,
|
||||
vod_pic: item.cover_img,
|
||||
vod_remarks: "豆瓣 " + item.grade,
|
||||
vod_year: item.definition
|
||||
})
|
||||
})
|
||||
result.pagecount = movieList.pages;
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
||||
async function getPlay(src) {
|
||||
let playData = {};
|
||||
if (src.startsWith("blob:")) {
|
||||
let blob = await fetch(src).then(r => r.blob());
|
||||
await blobUtil.blobToBinaryString(blob).then(function (fileData) {
|
||||
fileData = fileData.replaceAll('Â ', "");
|
||||
playData = {
|
||||
type: "file",
|
||||
ext: {
|
||||
header: {
|
||||
"User-Agent": window.navigator.userAgent,
|
||||
"Referer": window.location.href
|
||||
},
|
||||
file: fileData
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
playData = {
|
||||
type: "match"
|
||||
}
|
||||
}
|
||||
return playData;
|
||||
}
|
||||
|
||||
return {
|
||||
homeContent: function (filter) {
|
||||
const defaultFilters = [{
|
||||
key: "mcountry",
|
||||
name: "地区",
|
||||
value: []
|
||||
}, {
|
||||
key: "mtag",
|
||||
name: "类型",
|
||||
value: []
|
||||
}, {
|
||||
key: "sort",
|
||||
name: "排序",
|
||||
value: []
|
||||
}];
|
||||
defaultFilters.forEach((item) => {
|
||||
$(`.${item.key} .filter-item a`).each(function () {
|
||||
item.value.push({
|
||||
n: $(this).text(),
|
||||
v: $(this).data("filter")
|
||||
});
|
||||
})
|
||||
})
|
||||
let yearFilter = [{
|
||||
n: "全部年份",
|
||||
v: "all"
|
||||
}];
|
||||
let thisYear = new Date().getFullYear();
|
||||
for (let i = 0; i <= 20; i++) {
|
||||
yearFilter.push({
|
||||
n: thisYear - i,
|
||||
v: thisYear - i,
|
||||
})
|
||||
}
|
||||
defaultFilters.push({
|
||||
key: "years",
|
||||
name: "年份",
|
||||
value: yearFilter
|
||||
})
|
||||
const result = {
|
||||
class: [
|
||||
{type_id: "1", type_name: "电影"},
|
||||
{type_id: "2", type_name: "电视剧"},
|
||||
{type_id: "bangumi", type_name: "番剧"},
|
||||
{type_id: "chinese_cartoon", type_name: "国漫"},
|
||||
],
|
||||
filters: {
|
||||
"1": defaultFilters,
|
||||
"2": defaultFilters,
|
||||
"bangumi": defaultFilters,
|
||||
"chinese_cartoon": defaultFilters,
|
||||
},
|
||||
list: []
|
||||
};
|
||||
return listVideos(result);
|
||||
},
|
||||
categoryContent: function (tid, pg, filter, extend) {
|
||||
console.log(tid, pg, filter, JSON.stringify(extend));
|
||||
let result = {
|
||||
list: [],
|
||||
limit: 24,
|
||||
pagecount: 0
|
||||
};
|
||||
return listVideos(result);
|
||||
},
|
||||
detailContent: function (ids) {
|
||||
let media = [];
|
||||
$("#btngroup .playbtn").each(function () {
|
||||
media.push({
|
||||
name: $(this).text().trim(),
|
||||
type: "webview",
|
||||
ext: {
|
||||
replace: {
|
||||
mcid: unsafeWindow.mcid,
|
||||
path: $(this).data("path")
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
return {
|
||||
vod_id: ids[0],
|
||||
vod_name: $(".d-flex .grade:first").text().trim(),
|
||||
vod_pic: $(".d-flex .pimgs").attr("src"),
|
||||
vod_remarks: $(".d-flex .grade:eq(1)").text().trim(),
|
||||
vod_content: $(".d-flex p").text().trim(),
|
||||
vod_play_data: [{
|
||||
from: "注视影视",
|
||||
media: media
|
||||
}]
|
||||
};
|
||||
},
|
||||
playerContent: function (flag, id, vipFlags) {
|
||||
console.log(flag, id, unsafeWindow.mid);
|
||||
localStorage.setItem('mobj' + unsafeWindow.mid, JSON.stringify({
|
||||
video_index: window.location.hash.split("#").at(1),
|
||||
video_time: 1
|
||||
}));
|
||||
return new Promise(function (resolve) {
|
||||
_gotSrc = resolve;
|
||||
}).then(async (playerSrc) => {
|
||||
return await getPlay(playerSrc.src);
|
||||
});
|
||||
},
|
||||
searchContent: function (key, quick, pg) {
|
||||
const result = {
|
||||
list: [],
|
||||
page: pg,
|
||||
pagecount: 0
|
||||
};
|
||||
return listVideos(result);
|
||||
}
|
||||
};
|
||||
})();
|
||||
$(unsafeWindow).on("load", async function () {
|
||||
if (document.readyState === 'complete') {
|
||||
const result = await GmSpider[GMSpiderArgs.fName](...GMSpiderArgs.fArgs);
|
||||
console.log(GMSpiderArgs.fName, JSON.stringify(result));
|
||||
if (typeof GmSpiderInject !== 'undefined') {
|
||||
GmSpiderInject.SetSpiderResult(JSON.stringify(result));
|
||||
}
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -0,0 +1,261 @@
|
||||
// ==UserScript==
|
||||
// @name hitv
|
||||
// @namespace gmspider
|
||||
// @version 2024.11.12
|
||||
// @description Hi视频 GMSpider
|
||||
// @author Luomo
|
||||
// @match https://www.upfuhn.com/*
|
||||
// @require https://cdn.jsdelivr.net/gh/CatVodSpider-GM/Spiders-Lib@main/lib/browser-extension-url-match-1.2.0.min.js
|
||||
// @require https://cdn.jsdelivr.net/gh/CatVodSpider-GM/SFW-Spiders@main/Spiders-Lib/ajaxHooker-1.4.3.js
|
||||
// @grant GM_setValue
|
||||
// @grant GM_getValue
|
||||
// @grant unsafeWindow
|
||||
// @run-at document-start
|
||||
// ==/UserScript==
|
||||
console.log(JSON.stringify(GM_info));
|
||||
(function () {
|
||||
const GMSpiderArgs = {};
|
||||
if (typeof GmSpiderInject !== 'undefined') {
|
||||
let args = JSON.parse(GmSpiderInject.GetSpiderArgs());
|
||||
GMSpiderArgs.fName = args.shift();
|
||||
GMSpiderArgs.fArgs = args;
|
||||
} else {
|
||||
GMSpiderArgs.fName = "searchContent";
|
||||
GMSpiderArgs.fArgs = [true];
|
||||
// GMSpiderArgs.fName = "categoryContent";
|
||||
// GMSpiderArgs.fArgs = ["82", 2, true, {tag: "动作", y: "2024", o: "1", a: "大陆"}];
|
||||
}
|
||||
Object.freeze(GMSpiderArgs);
|
||||
let hookConfigs = {
|
||||
"homeContent": [{
|
||||
matcher: matchPattern("https://*/v1/report_channel_data").assertValid(),
|
||||
onResponseHook: function (response) {
|
||||
Array.from(document.querySelectorAll(".left-wrap .tab-box:nth-child(2) .swiper-slide span"))
|
||||
.find(el => el.textContent === "全部").dispatchEvent(new Event("click"));
|
||||
}
|
||||
}, {
|
||||
dataKey: "ys_video_sites", matcher: matchPattern("https://*/v1/ys_video_sites?*").assertValid()
|
||||
}], "categoryContent": [{
|
||||
matcher: matchPattern("https://*/v1/report_channel_data").assertValid(),
|
||||
onResponseHook: function (response) {
|
||||
const extend = GMSpiderArgs.fArgs[3];
|
||||
let tag = extend?.tag ?? "全部"
|
||||
Array.from(document.querySelectorAll(".left-wrap .tab-box:nth-child(2) .swiper-slide span"))
|
||||
.find(el => el.textContent === tag).dispatchEvent(new Event("click"));
|
||||
}
|
||||
}, {
|
||||
dataKey: "ys_video_sites",
|
||||
matcher: matchPattern("https://*/v1/ys_video_sites?*").assertValid(),
|
||||
onRequestHook: function (response) {
|
||||
const page = GMSpiderArgs.fArgs[1];
|
||||
const filter = GMSpiderArgs.fArgs[2];
|
||||
const extend = GMSpiderArgs.fArgs[3];
|
||||
const url = new URL(response.url);
|
||||
const params = new URLSearchParams(url.search);
|
||||
params.set("pn", page)
|
||||
if (filter) {
|
||||
params.set("a", extend?.a ?? "");
|
||||
params.set("y", extend?.y ?? "");
|
||||
params.set("o", extend?.o ?? 0);
|
||||
}
|
||||
url.search = params.toString();
|
||||
response.url = url.toString();
|
||||
}
|
||||
}],
|
||||
"detailContent": [{
|
||||
dataKey: "meta", matcher: matchPattern("https://*/v1/report_channel_data").assertValid()
|
||||
}],
|
||||
"searchContent": [{
|
||||
dataKey: "meta", matcher: matchPattern("https://*/v1/report_channel_data").assertValid()
|
||||
}],
|
||||
};
|
||||
const GmSpider = (function () {
|
||||
const categoryFilterCachePrefix = "category_";
|
||||
const filterTag = {
|
||||
key: "tag", name: "分类", value: []
|
||||
};
|
||||
const filterArea = {
|
||||
key: "o", name: "地区", value: []
|
||||
};
|
||||
const filterYear = {
|
||||
key: "y", name: "年份", value: []
|
||||
};
|
||||
const filterSort = {
|
||||
key: "o",
|
||||
name: "排序",
|
||||
value: [{n: "综合", v: "0"}, {n: "最新", v: "2"}, {n: "最热", v: "1"}, {n: "评分", v: "5"},]
|
||||
};
|
||||
return {
|
||||
homeContent: function (filter) {
|
||||
let result = {
|
||||
class: [{type_id: "85", type_name: "短剧"}, {type_id: "81", type_name: "电影"}, {
|
||||
type_id: "82",
|
||||
type_name: "电视剧"
|
||||
}, {type_id: "83", type_name: "综艺"}, {type_id: "84", type_name: "动漫"},], filters: {}, list: []
|
||||
};
|
||||
document.querySelectorAll(".left-wrap .tab-box:nth-child(3) .swiper-slide span").forEach((filter) => {
|
||||
filterArea.value.push({
|
||||
n: filter.textContent, v: filter.textContent,
|
||||
})
|
||||
});
|
||||
document.querySelectorAll(".left-wrap .tab-box:nth-child(4) .swiper-slide span").forEach((filter) => {
|
||||
filterYear.value.push({
|
||||
n: filter.textContent, v: filter.textContent,
|
||||
})
|
||||
});
|
||||
result.class.forEach((category) => {
|
||||
const categoryFilter = [];
|
||||
const cacheFilter = localStorage.getItem(categoryFilterCachePrefix + category.type_id);
|
||||
if (typeof cacheFilter !== "undefined" && cacheFilter !== null) {
|
||||
categoryFilter.push(JSON.parse(cacheFilter));
|
||||
}
|
||||
categoryFilter.push(filterArea, filterYear, filterSort);
|
||||
result.filters[category.type_id] = categoryFilter;
|
||||
})
|
||||
hookResult.ys_video_sites.data.data.forEach((media) => {
|
||||
result.list.push({
|
||||
vod_id: media.video_site_id,
|
||||
vod_name: media.video_name,
|
||||
vod_pic: media.video_vertical_url,
|
||||
vod_remarks: "评分:" + media.score,
|
||||
vod_year: media.years
|
||||
})
|
||||
});
|
||||
return result;
|
||||
}, categoryContent: function (tid, pg, filter, extend) {
|
||||
let result = {
|
||||
list: [], pagecount: Math.ceil(hookResult.ys_video_sites.data.total / 21)
|
||||
};
|
||||
document.querySelectorAll(".left-wrap .tab-box:nth-child(2) .swiper-slide span").forEach((filter) => {
|
||||
filterTag.value.push({
|
||||
n: filter.textContent, v: filter.textContent,
|
||||
})
|
||||
});
|
||||
localStorage.setItem(categoryFilterCachePrefix + tid, JSON.stringify(filterTag));
|
||||
hookResult.ys_video_sites.data.data.forEach((media) => {
|
||||
result.list.push({
|
||||
vod_id: media.video_site_id,
|
||||
vod_name: media.video_name,
|
||||
vod_pic: media.video_vertical_url,
|
||||
vod_remarks: "评分:" + media.score,
|
||||
vod_year: media.years
|
||||
})
|
||||
})
|
||||
return result;
|
||||
}, detailContent: function (ids) {
|
||||
let playUrl = [];
|
||||
let vod = {};
|
||||
const formatData = JSON.parse(document.getElementById("__NUXT_DATA__").innerHTML);
|
||||
formatData.forEach((data) => {
|
||||
if (typeof (vod?.vod_id) == "undefined" && typeof (data?.video_desc) === "number") {
|
||||
vod = {
|
||||
vod_id: formatData[data.video_site_id],
|
||||
vod_name: formatData[data.video_name],
|
||||
vod_content: formatData[data.video_desc],
|
||||
vod_year: formatData[data.years],
|
||||
vod_area: formatData[data.area],
|
||||
vod_actor: formatData[data.main_actor],
|
||||
type_name: formatData[data.tag],
|
||||
vod_play_data: [{
|
||||
from: "Hi视频",
|
||||
media: playUrl
|
||||
}]
|
||||
};
|
||||
}
|
||||
if (typeof (data?.series_num) === "number") {
|
||||
playUrl.push({
|
||||
name: formatData[data.series_num],
|
||||
type: "finalUrl",
|
||||
ext: {
|
||||
header: {
|
||||
"User-Agent": window.navigator.userAgent,
|
||||
"Referer": window.location.href
|
||||
},
|
||||
url: formatData[data.video_url]
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
return vod;
|
||||
}, searchContent: function (key, quick, pg) {
|
||||
const result = {
|
||||
list: [],
|
||||
page: pg,
|
||||
pagecount: 1
|
||||
};
|
||||
const formatData = JSON.parse(document.getElementById("__NUXT_DATA__").innerHTML);
|
||||
console.log(formatData);
|
||||
formatData.forEach((data) => {
|
||||
if (typeof (data?.first_video_series) === "number") {
|
||||
let firstVideo = formatData[data.first_video_series];
|
||||
result.list.push({
|
||||
vod_id: formatData[firstVideo.video_site_id],
|
||||
vod_name: formatData[firstVideo.video_name],
|
||||
vod_pic: formatData[firstVideo.video_vertical_url],
|
||||
vod_remarks: formatData[firstVideo.tag],
|
||||
vod_year: formatData[firstVideo.years]
|
||||
})
|
||||
formatData[data.video_sites].forEach((videoIndex) => {
|
||||
let video = formatData[videoIndex];
|
||||
result.list.push({
|
||||
vod_id: formatData[video.video_site_id],
|
||||
vod_name: formatData[video.video_name],
|
||||
vod_pic: formatData[video.video_vertical_url],
|
||||
vod_remarks: formatData[video.tag],
|
||||
vod_year: formatData[video.years]
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
return result;
|
||||
}
|
||||
};
|
||||
})();
|
||||
let spiderExecuted = false;
|
||||
let dataReadyCount = 0;
|
||||
let hookResult = {};
|
||||
ajaxHooker.hook(request => {
|
||||
hookConfigs[GMSpiderArgs.fName].forEach((hookConfig) => {
|
||||
if (typeof hookConfig.onRequestHook === "function" && hookConfig.matcher.match(request.url)) {
|
||||
hookConfig.onRequestHook(request);
|
||||
}
|
||||
});
|
||||
if (!spiderExecuted) {
|
||||
let dataTodoCount = 0;
|
||||
hookConfigs[GMSpiderArgs.fName].forEach((hookConfig) => {
|
||||
if (typeof hookConfig.dataKey !== "undefined") {
|
||||
if (hookConfig?.require !== false) {
|
||||
dataTodoCount++;
|
||||
}
|
||||
}
|
||||
if (hookConfig.matcher.match(request.url)) {
|
||||
request.response = res => {
|
||||
if (typeof hookConfig.onResponseHook === "function") {
|
||||
hookConfig.onResponseHook(res);
|
||||
}
|
||||
if (typeof hookConfig.dataKey !== "undefined") {
|
||||
if (hookConfig?.require !== false) {
|
||||
dataReadyCount++;
|
||||
}
|
||||
let data = JSON.parse(res.text);
|
||||
if (typeof data === 'object' && data) {
|
||||
hookResult[hookConfig.dataKey] = data;
|
||||
} else {
|
||||
hookResult[hookConfig.dataKey] = res.text;
|
||||
}
|
||||
if (dataTodoCount === dataReadyCount) {
|
||||
spiderExecuted = true;
|
||||
const result = GmSpider[GMSpiderArgs.fName](...GMSpiderArgs.fArgs);
|
||||
console.log(result);
|
||||
if (typeof GmSpiderInject !== 'undefined' && spiderExecuted) {
|
||||
GmSpiderInject.SetSpiderResult(JSON.stringify(result));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
})();
|
||||
@@ -0,0 +1,324 @@
|
||||
// ==UserScript==
|
||||
// @name yfsp
|
||||
// @namespace gmspider
|
||||
// @version 2024.11.12
|
||||
// @description 爱壹帆 GMSpider
|
||||
// @author Luomo
|
||||
// @match https://m.yfsp.tv/*
|
||||
// @require https://cdn.jsdelivr.net/gh/CatVodSpider-GM/Spiders-Lib@main/lib/browser-extension-url-match-1.2.0.min.js
|
||||
// @require https://cdn.jsdelivr.net/npm/[email protected]/dist/ajaxhook.umd.min.js
|
||||
// @grant GM_setValue
|
||||
// @grant GM_getValue
|
||||
// @grant unsafeWindow
|
||||
// @run-at document-start
|
||||
// ==/UserScript==
|
||||
console.log(JSON.stringify(GM_info));
|
||||
(function () {
|
||||
const GMSpiderArgs = {};
|
||||
if (typeof GmSpiderInject !== 'undefined') {
|
||||
let args = JSON.parse(GmSpiderInject.GetSpiderArgs());
|
||||
GMSpiderArgs.fName = args.shift();
|
||||
GMSpiderArgs.fArgs = args;
|
||||
} else {
|
||||
// GMSpiderArgs.fName = "homeContent";
|
||||
// GMSpiderArgs.fArgs = [true];
|
||||
// GMSpiderArgs.fName = "categoryContent";
|
||||
// GMSpiderArgs.fArgs = ["movie", 2, true, {}];
|
||||
// GMSpiderArgs.fName = "detailContent";
|
||||
// GMSpiderArgs.fArgs = [["XOkJ0XqSwI2"]];
|
||||
GMSpiderArgs.fName = "searchContent";
|
||||
GMSpiderArgs.fArgs = ["小巷人家", false, 1];
|
||||
}
|
||||
Object.freeze(GMSpiderArgs);
|
||||
(function () {
|
||||
switch (GMSpiderArgs.fName) {
|
||||
case "searchContent":
|
||||
localStorage.setItem("historyList", JSON.stringify([GMSpiderArgs.fArgs [0]]));
|
||||
break;
|
||||
}
|
||||
})();
|
||||
let hookConfigs = {
|
||||
"homeContent": [{
|
||||
dataKey: "navigationbar",
|
||||
matcher: matchPattern("https://*.yfsp.tv/api/list/navigationbar?*").assertValid()
|
||||
}, {
|
||||
dataKey: "index",
|
||||
matcher: matchPattern("https://*.yfsp.tv/api/list/index?*").assertValid()
|
||||
}],
|
||||
"categoryContent": [{
|
||||
dataKey: "filtertagsdata",
|
||||
matcher: matchPattern("https://*.yfsp.tv/api/list/getfiltertagsdata?*").assertValid()
|
||||
}, {
|
||||
dataKey: "conditionfilterdata",
|
||||
matcher: matchPattern("https://*.yfsp.tv/api/list/getconditionfilterdata?*").assertValid(),
|
||||
onRequestHook: function (config, handler) {
|
||||
let url = new URL(config.url);
|
||||
url.searchParams.set('page', GMSpiderArgs.fArgs[1]);
|
||||
config.url = url.toString();
|
||||
}
|
||||
}],
|
||||
"detailContent": [{
|
||||
dataKey: "videodetails",
|
||||
matcher: matchPattern("https://*.yfsp.tv/api/video/videodetails?*").assertValid()
|
||||
}, {
|
||||
dataKey: "playdata",
|
||||
matcher: matchPattern("https://*.yfsp.tv/api/video/getplaydata?*").assertValid()
|
||||
}, {
|
||||
dataKey: "videochoosegather",
|
||||
require: false,
|
||||
matcher: matchPattern("https://*.yfsp.tv/api/video/videochoosegather?*").assertValid()
|
||||
}],
|
||||
"playerContent": [{
|
||||
dataKey: "playdata",
|
||||
matcher: matchPattern("https://*.yfsp.tv/api/video/getplaydata?*").assertValid()
|
||||
}],
|
||||
"searchContent": [{
|
||||
dataKey: "titlegetdata",
|
||||
matcher: matchPattern("https://*.yfsp.tv/api/list/gettitlegetdata?*").assertValid()
|
||||
}, {
|
||||
matcher: matchPattern("https://*.yfsp.tv/api/home/gethotsearch?*").assertValid(),
|
||||
onResponseHook: function (response, handler) {
|
||||
document.querySelector(".search-log span").dispatchEvent(new Event("click"));
|
||||
}
|
||||
}],
|
||||
};
|
||||
const GmSpider = (function () {
|
||||
const categoryFilterCachePrefix = "category.";
|
||||
return {
|
||||
homeContent: function (filter) {
|
||||
let result = {
|
||||
class: [],
|
||||
filters: {},
|
||||
list: []
|
||||
};
|
||||
let categoryIds = [];
|
||||
hookResult.navigationbar.data.list.forEach((item) => {
|
||||
if (item.type === 1) {
|
||||
result.class.push({
|
||||
type_id: item.routeName,
|
||||
type_name: item.name
|
||||
});
|
||||
categoryIds.push(item.categoryId);
|
||||
// const cacheFilter = GM_getValue(item.routeName);
|
||||
// console.log("cacheFilter", item.routeName, cacheFilter);
|
||||
const cacheFilter = localStorage.getItem(categoryFilterCachePrefix + item.routeName);
|
||||
console.log("localStorage", item.routeName, localStorage.getItem(item.routeName));
|
||||
if (typeof cacheFilter !== "undefined" && cacheFilter !== null) {
|
||||
result.filters[item.routeName] = JSON.parse(cacheFilter);
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
hookResult.index.data.list.forEach((item) => {
|
||||
if (categoryIds.includes(item.type)) {
|
||||
item.list.forEach((media) => {
|
||||
if (!media.isRecommend) {
|
||||
result.list.push({
|
||||
vod_id: media.mediaKey,
|
||||
vod_name: media.title,
|
||||
vod_pic: media.coverImgUrl,
|
||||
vod_remarks: media.updateStatus,
|
||||
vod_year: media.mediaType
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
return result;
|
||||
},
|
||||
categoryContent: function (tid, pg, filter, extend) {
|
||||
let result = {
|
||||
list: [],
|
||||
pagecount: 1000
|
||||
};
|
||||
let cacheFilters = [];
|
||||
hookResult.filtertagsdata.data.list.forEach(classify => {
|
||||
let cacheFilter = {
|
||||
key: "index-" + classify.list[0].index,
|
||||
name: classify.name,
|
||||
value: []
|
||||
}
|
||||
classify.list.forEach((item) => {
|
||||
cacheFilter.value.push({
|
||||
n: item.classifyName,
|
||||
v: (item.index > 0 ? "," : "") + item.classifyId
|
||||
});
|
||||
})
|
||||
cacheFilters.push(cacheFilter);
|
||||
})
|
||||
// GM_setValue(tid, JSON.stringify(cacheFilters));
|
||||
localStorage.setItem(categoryFilterCachePrefix + tid, JSON.stringify(cacheFilters));
|
||||
console.log("cacheFilter", tid, cacheFilters);
|
||||
hookResult.conditionfilterdata.data.list.forEach((media) => {
|
||||
result.list.push({
|
||||
vod_id: media.mediaKey,
|
||||
vod_name: media.title,
|
||||
vod_pic: media.coverImgUrl,
|
||||
vod_remarks: media.updateStatus,
|
||||
vod_year: media.regional
|
||||
})
|
||||
})
|
||||
return result;
|
||||
},
|
||||
detailContent: function (ids) {
|
||||
const videodetails = hookResult.videodetails.data.detailInfo;
|
||||
let mediaUrl = "";
|
||||
let episodeKey = "";
|
||||
hookResult.playdata.data.list.forEach((item) => {
|
||||
if (mediaUrl === "" && item.mediaUrl !== "") {
|
||||
mediaUrl = item.mediaUrl;
|
||||
episodeKey = item.episodeKey;
|
||||
}
|
||||
})
|
||||
let media = [];
|
||||
if (videodetails.videoType !== 0) {
|
||||
if (typeof hookResult.videochoosegather !== "undefined") {
|
||||
hookResult.videochoosegather.data.list.forEach((item) => {
|
||||
if (videodetails.episodeTitle === item.episodeTitle) {
|
||||
media.push({
|
||||
name: item.episodeTitle,
|
||||
type: "finalUrl",
|
||||
ext: {
|
||||
"header": {
|
||||
"User-Agent": window.navigator.userAgent,
|
||||
"Referer": window.location.href
|
||||
},
|
||||
"url": mediaUrl
|
||||
}
|
||||
});
|
||||
} else {
|
||||
media.push({
|
||||
name: item.episodeTitle,
|
||||
type: "webview",
|
||||
ext: {
|
||||
replace: {
|
||||
mediaKey: item.mediaKey,
|
||||
episodeKey: item.episodeKey
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
} else {
|
||||
spiderExecuted = false;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
media.push({
|
||||
name: videodetails.episodeTitle,
|
||||
type: "finalUrl",
|
||||
ext: {
|
||||
"header": {
|
||||
"User-Agent": window.navigator.userAgent,
|
||||
"Referer": window.location.href
|
||||
},
|
||||
"url": mediaUrl
|
||||
}
|
||||
})
|
||||
}
|
||||
return {
|
||||
vod_id: videodetails.mediaKey,
|
||||
vod_name: videodetails.title,
|
||||
vod_pic: videodetails.coverImgUrl,
|
||||
vod_actor: videodetails.actor,
|
||||
vod_director: videodetails.director,
|
||||
vod_tag: videodetails.cidMapper,
|
||||
vod_area: videodetails.regional,
|
||||
vod_content: videodetails.introduce,
|
||||
vod_play_data: [{
|
||||
from: "爱壹帆",
|
||||
media: media
|
||||
}]
|
||||
};
|
||||
},
|
||||
playerContent: function (flag, id, vipFlags) {
|
||||
let mediaUrl = "";
|
||||
hookResult.playdata.data.list.forEach((item) => {
|
||||
if (mediaUrl === "" && item.mediaUrl !== "") {
|
||||
mediaUrl = item.mediaUrl;
|
||||
}
|
||||
})
|
||||
return {
|
||||
type: "finalUrl",
|
||||
ext: {
|
||||
"header": {
|
||||
"User-Agent": window.navigator.userAgent,
|
||||
"Referer": window.location.href
|
||||
},
|
||||
"url": mediaUrl
|
||||
}
|
||||
};
|
||||
},
|
||||
searchContent: function (key, quick, pg) {
|
||||
console.log(hookResult);
|
||||
let result = {
|
||||
list: [],
|
||||
pagecount: 1
|
||||
};
|
||||
if (pg == 1) {
|
||||
hookResult.titlegetdata.data.list.forEach((media) => {
|
||||
result.list.push({
|
||||
vod_id: media.mediaKey,
|
||||
vod_name: media.title,
|
||||
vod_pic: media.coverImgUrl,
|
||||
vod_remarks: media.updateStatus,
|
||||
vod_year: media.regional
|
||||
})
|
||||
})
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
})();
|
||||
let spiderExecuted = false;
|
||||
let dataReadyCount = 0;
|
||||
let hookResult = {};
|
||||
const {unProxy, originXhr} = proxy({
|
||||
onRequest: (config, handler) => {
|
||||
hookConfigs[GMSpiderArgs.fName].forEach((hookConfig) => {
|
||||
if (typeof hookConfig.onRequestHook === "function" && hookConfig.matcher.match(config.url)) {
|
||||
hookConfig.onRequestHook(config, handler);
|
||||
}
|
||||
});
|
||||
handler.next(config);
|
||||
},
|
||||
onResponse: (response, handler) => {
|
||||
if (!spiderExecuted) {
|
||||
let dataTodoCount = 0;
|
||||
hookConfigs[GMSpiderArgs.fName].forEach((hookConfig) => {
|
||||
if (typeof hookConfig.dataKey !== "undefined") {
|
||||
if (hookConfig?.require !== false) {
|
||||
dataTodoCount++;
|
||||
}
|
||||
if (hookConfig.matcher.match(response.config.url)) {
|
||||
if (hookConfig?.require !== false) {
|
||||
dataReadyCount++;
|
||||
}
|
||||
try {
|
||||
let data = JSON.parse(response.response);
|
||||
if (typeof data === 'object' && data) {
|
||||
hookResult[hookConfig.dataKey] = data;
|
||||
} else {
|
||||
hookResult[hookConfig.dataKey] = response.response;
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (typeof hookConfig.onResponseHook === "function" && hookConfig.matcher.match(response.config.url)) {
|
||||
hookConfig.onResponseHook(response, handler);
|
||||
}
|
||||
});
|
||||
if (dataTodoCount === dataReadyCount) {
|
||||
spiderExecuted = true;
|
||||
const result = GmSpider[GMSpiderArgs.fName](...GMSpiderArgs.fArgs);
|
||||
console.log(result);
|
||||
if (typeof GmSpiderInject !== 'undefined' && spiderExecuted) {
|
||||
GmSpiderInject.SetSpiderResult(JSON.stringify(result));
|
||||
}
|
||||
}
|
||||
}
|
||||
handler.next(response);
|
||||
}
|
||||
}, unsafeWindow)
|
||||
})();
|
||||
Reference in New Issue
Block a user