// ==UserScript==
// @name 我只想好好观影
// @namespace liuser.betterworld.love
// @match https://movie.douban.com/subject/*
// @match https://m.douban.com/movie/*
// @grant GM_addStyle
// @grant GM_xmlhttpRequest
// @connect *
// @run-at document-end
// @require https://cdn.jsdelivr.net/npm/xy-ui@1.10.7/index.js
// @require https://cdn.staticfile.org/mux.js/6.3.0/mux.min.js
// @require https://cdn.staticfile.org/shaka-player/4.3.5/shaka-player.compiled.js
// @require https://cdn.staticfile.org/artplayer/4.6.2/artplayer.min.js
// @version 2.0
// @author liuser, modify by ray
// @description 想看就看
// @license MIT
// @downloadURL none
// ==/UserScript==
(function () {
const _debug = !1;
let art = {}; //播放器
let seriesNum = 0;
const {query: $, queryAll: $$, isMobile} = Artplayer.utils;
const tip = (message) => XyMessage.info(message);
//获取豆瓣影片名称
const videoName = isMobile ? $(".sub-title").innerText : document.title.slice(0, -5);
const log = (function() {
if (_debug) return console.log.bind(console);
return function() {};
})();
//将html转为element
function htmlToElement(html) {
const template = document.createElement('template');
template.innerHTML = html.trim();
return template.content.firstChild;
}
//搜索源
const searchSource = [
// {"name":"闪电资源","searchUrl":"https://sdzyapi.com/api.php/provide/vod/"},//不太好,格式经常有错
// { "name": "卧龙资源", "searchUrl": "https://collect.wolongzyw.com/api.php/provide/vod/" }, 非常恶心的广告
{ "name": "非凡资源", "searchUrl": "http://cj.ffzyapi.com/api.php/provide/vod/" },
{ "name": "量子资源", "searchUrl": "https://cj.lziapi.com/api.php/provide/vod/" },
{ "name": "ikun资源", "searchUrl": "https://ikunzyapi.com/api.php/provide/vod/from/ikm3u8/at/json/" },
{ "name": "光速资源", "searchUrl": "https://api.guangsuapi.com/api.php/provide/vod/from/gsm3u8/" },
{ "name": "高清资源", "searchUrl": "https://api.1080zyku.com/inc/apijson.php/" },
{ "name": "188资源", "searchUrl": "https://www.188zy.org/api.php/provide/vod/" },
// { "name": "飞速资源", "searchUrl": "https://www.feisuzyapi.com/api.php/provide/vod/" },//经常作妖或者没有资源
{ "name": "红牛资源", "searchUrl": "https://www.hongniuzy2.com/api.php/provide/vod/from/hnm3u8/" },
// {"name":"天空资源","searchUrl":"https://m3u8.tiankongapi.com/api.php/provide/vod/from/tkm3u8/"},//有防火墙,垃圾
// { "name": "8090资源", "searchUrl": "https://api.yparse.com/api/json/m3u8/" },垃圾 可能有墙
// { "name": "百度云资源", "searchUrl": "https://api.apibdzy.com/api.php/provide/vod/" },
// { "name": "酷点资源", "searchUrl": "https://kudian10.com/api.php/provide/vod/" },
// { "name": "淘片资源", "searchUrl": "https://taopianapi.com/home/cjapi/as/mc10/vod/json/" },
// { "name": "ck资源", "searchUrl": "https://ckzy.me/api.php/provide/vod/" },
// { "name": "快播资源", "searchUrl": "https://caiji.kczyapi.com/api.php/provide/vod/" },
// { "name": "海外看资源", "searchUrl": "http://api.haiwaikan.com/v1/vod/" }, // 说是屏蔽了所有中国的IP,所以如果你有外国的ip可能比较好
// { "name": "68资源", "searchUrl": "https://caiji.68zyapi.com/api.php/provide/vod/" },
// https://caiji.kczyapi.com/api.php/provide/vod/
// {"name":"鱼乐资源","searchUrl":"https://api.yulecj.com/api.php/provide/vod/"},//速度太慢
// {"name":"无尽资源","searchUrl":"https://api.wujinapi.me/api.php/provide/vod/"},//资源少
];
//处理搜索到的结果:从返回结果中找到对应片子
function handleResponse(r) {
if (!r || r.list.length == 0) {
log("未搜索到结果");
return 0
}
let video, found = false;
for (let item of r.list) {
log("正在对比剧集年份");
let yearEqual = getVideoYear(item.vod_year);
if (yearEqual === 0) return 0;
if (yearEqual) {
video = item;
found = true;
break
}
}
if (found == false) {
log("没有找到匹配剧集的影片,怎么回事哟!");
return 0
}
let playList = video.vod_play_url.split("$$$").filter(str => str.includes("m3u8"));
if (playList.length == 0) {
log("没有m3u8资源,无法测速,无法播放");
return 0
}
playList = playList[0].split("#");
playList = playList.map(str => {
let index = str.indexOf("$");
return { "name": str.slice(0, index), "url": str.slice(index + 1) }
});
return playList
}
//到电影网站搜索电影
const search = (url) => new Promise((resolve, reject) => {
GM_xmlhttpRequest({
method: "GET",
url: encodeURI(`${url}?ac=detail&wd=${videoName}`),
timeout: 3000,
responseType: 'json',
onload(r) {
try {
resolve(handleResponse(r.response, videoName));
} catch (e) {
log("垃圾资源,解析失败了,可能有防火墙");
log(e);
reject()
}
},
onerror: reject,
ontimeout: reject
});
});
//播放按钮
class PlayBtn {
constructor() {
const e = htmlToElement(`