VIP
自动解析功能说明:
1、自动解析功能默认关闭(自动解析只支持内嵌播放源)
2、开启自动解析,网页打开后脚本将根据当前选中的解析源自动解析视频。如解析失败,请手动选择不同的解析源尝试
3、没有选中解析源将随机选取一个
4、如某些网站有会员可以关闭自动解析功能
${autoPlay}
`);
return new Promise((resolve, reject) => resolve(container));
}
bindEvent(container) {
const vipBox = $(`#${_CONFIG_.vipBoxId}`);
if (_CONFIG_.isMobile) {
vipBox.find(".vip_icon").on("click", () => vipBox.find(".vip_list").toggle());
vipBox.find(".money").on("click", () => vipBox.find(".vip_list2").toggle());
} else {
vipBox.find(".vip_icon").on("mouseover", () => vipBox.find(".vip_list").show());
vipBox.find(".vip_icon").on("mouseout", () => vipBox.find(".vip_list").hide());
vipBox.find(".money").on("mouseover", () => vipBox.find(".vip_list2").show());
vipBox.find(".money").on("mouseout", () => vipBox.find(".vip_list2").hide());
}
let _this = this;
vipBox.find(".vip_list .nq-li").each((liIndex, item) => {
item.addEventListener("click", () => {
const index = parseInt($(item).attr("data-index"));
GM_setValue(_CONFIG_.autoPlayerVal, index);
GM_setValue(_CONFIG_.flag, "true");
_this.showPlayerWindow(_CONFIG_.videoParseList[index]);
vipBox.find(".vip_list li").removeClass("selected");
$(item).addClass("selected");
});
});
vipBox.find(".vip_list .tc-li").each((liIndex, item) => {
item.addEventListener("click", () => {
const index = parseInt($(item).attr("data-index"));
const videoObj = _CONFIG_.videoParseList[index];
let url = videoObj.url + window.location.href;
GM_openInTab(url, {
active: true,
insert: true,
setParent: true
});
});
});
//右键移动位置
vipBox.mousedown(function (e) {
if (e.which !== 3) {
return;
}
e.preventDefault()
vipBox.css("cursor", "move");
const positionDiv = $(this).offset();
let distenceX = e.pageX - positionDiv.left;
let distenceY = e.pageY - positionDiv.top;
$(document).mousemove(function (e) {
let x = e.pageX - distenceX;
let y = e.pageY - distenceY;
const windowWidth = $(window).width();
const windowHeight = $(window).height();
if (x < 0) {
x = 0;
} else if (x > windowWidth - vipBox.outerWidth(true) - 100) {
x = windowWidth - vipBox.outerWidth(true) - 100;
}
if (y < 0) {
y = 0;
} else if (y > windowHeight - vipBox.outerHeight(true)) {
y = windowHeight - vipBox.outerHeight(true);
}
vipBox.css("left", x);
vipBox.css("top", y);
});
$(document).mouseup(function () {
$(document).off('mousemove');
vipBox.css("cursor", "pointer");
});
$(document).contextmenu(function (e) {
e.preventDefault();
})
});
return new Promise((resolve, reject) => resolve(container));
}
autoPlay(container) {
const vipBox = $(`#${_CONFIG_.vipBoxId}`);
vipBox.find("#vip_auto").on("click", function () {
if (!!GM_getValue(_CONFIG_.autoPlayerKey, null)) {
GM_setValue(_CONFIG_.autoPlayerKey, null);
$(this).html("关");
$(this).attr("title", "是否打开自动解析。若自动解析失败,请手动选择其它接口尝试!!");
} else {
GM_setValue(_CONFIG_.autoPlayerKey, "true");
$(this).html("开");
}
setTimeout(function () {
window.location.reload();
}, 200);
});
if (!!GM_getValue(_CONFIG_.autoPlayerKey, null)) {
this.selectPlayer(container);
}
return new Promise((resolve, reject) => resolve(container));
}
selectPlayer(container) {
let index = GM_getValue(_CONFIG_.autoPlayerVal, 2);
let autoObj = _CONFIG_.videoParseList[index];
let _th = this;
if (autoObj.type.includes("1")) {
setTimeout(function () {
_th.showPlayerWindow(autoObj);
const vipBox = $(`#${_CONFIG_.vipBoxId}`);
vipBox.find(`.vip_list [title="${autoObj.name}1"]`).addClass("selected");
$(container).find("#vip_auto").attr("title", `自动解析源:${autoObj.name}`);
}, 2500);
}
}
showPlayerWindow(videoObj) {
util.findTargetEle(_CONFIG_.currentPlayerNode.container)
.then((container) => {
const type = videoObj.type;
let url = videoObj.url + window.location.href;
if (type.includes("1")) {
util.reomveVideo();
$(container).empty();
$(container).empty();
let iframeDivCss = "width:100%;height:100%;z-index:999999;";
if (_CONFIG_.isMobile) {
iframeDivCss = "width:100%;height:220px;z-index:999999;";
}
if (_CONFIG_.isMobile && window.location.href.indexOf("iqiyi.com") !== -1) {
iframeDivCss = "width:100%;height:220px;z-index:999999;margin-top:-56.25%;";
}
$(container).append(`
`);
}
});
}
postHandle(container) {
if (!!GM_getValue(_CONFIG_.autoPlayerKey, null)) {
util.urlChangeReload();
} else {
let oldHref = window.location.href;
let interval = setInterval(() => {
let newHref = window.location.href;
if (oldHref !== newHref) {
oldHref = newHref;
if (!!GM_getValue(_CONFIG_.flag, null)) {
clearInterval(interval);
window.location.reload();
}
}
}, 1000);
}
}
}
class DefaultConsumer extends BaseConsumer { }
return {
start: () => {
GM_setValue(_CONFIG_.flag, null);
let mallCase = 'Default';
let playerNode = _CONFIG_.playerContainers.filter(value => value.host === window.location.host);
if (playerNode === null || playerNode.length <= 0) {
console.warn(window.location.host + "该网站暂不支持,请联系作者,作者将会第一时间处理(注意:请记得提供有问题的网址)");
return;
}
_CONFIG_.currentPlayerNode = playerNode[0];
mallCase = _CONFIG_.currentPlayerNode.name;
const targetConsumer = eval(`new ${mallCase}Consumer`);
targetConsumer.parse();
}
}
})();
(function () {
superVip.start();
})();