Acfun-hls
// ==UserScript==
// @name Acfun-hls
// @namespace https://greasyfork.org/zh-CN/users/135090
// @version 3.1.0
// @description Acfun跳转到M3U8地址,需配合Chrome浏览器的扩展HLS-Playback使用(支持西瓜视频)
// @author zwb83925462
// @match https://www.acfun.cn/v/ac*
// @match https://www.acfun.cn/player/*
// @match https://www.ixigua.com/1*
// @match https://www.ixigua.com/2*
// @match https://www.ixigua.com/3*
// @match https://www.ixigua.com/4*
// @match https://www.ixigua.com/5*
// @match https://www.ixigua.com/6*
// @match https://www.ixigua.com/7*
// @match https://www.ixigua.com/8*
// @match https://www.ixigua.com/9*
// @match https://www.ixigua.com/pseries/*
// @grant unsafeWindow
// @run-at document-end
// @license CC
// @noframes
// ==/UserScript==
'use strict';
(function(){
//acfun
if (location.hostname == 'www.acfun.cn') {
var oldurl="old",newurl="new";
document.addEventListener("mousedown", function() {
oldurl=location.pathname;
});
document.addEventListener("mouseup", function() {
setTimeout(loop,1000);
});
function loop() {
if (unsafeWindow.videoInfo?.currentVideoInfo?.ksPlayJson == undefined) {
setTimeout(loop, 500);
}
newurl=location.pathname;
if (oldurl == newurl){
if(document.querySelector("video").paused){
console.info(newurl.substring(newurl.lastIndexOf("/")+1));
}
} else {
var ksjs=JSON.parse(unsafeWindow.videoInfo?.currentVideoInfo?.ksPlayJson);
var acdata = ksjs.adaptationSet[0].representation;
var acvid=newurl.substring(newurl.lastIndexOf("/")+1);
var idelement=`<span style="color:deeppink;margin:0 1vw">${acvid}>></span>`;
if (location.pathname.indexOf("v") == 1) {
document.querySelector("#movie-player").innerHTML=idelement;
document.querySelector("#movie-player").style.height = "fit-content";
document.querySelector("#movie-player").align = "center";
} else {
document.querySelector("#player").innerHTML=idelement;
document.querySelector("#player").align = "center";
}
acdata.forEach(function (item, r) {
var uhd = item.qualityLabel;
var ddiv = document.createElement("a");
ddiv.style.color = "#11AA11";
ddiv.style.font = "caption";
ddiv.style.margin = "0 2vw";
ddiv.id = "hls" + r;
ddiv.href = item.url;
ddiv.innerText = "#" + uhd;
ddiv.target = "_blank";
if (location.pathname.indexOf("v") == 1) {
document.querySelector("#movie-player").appendChild(ddiv);
} else {
document.querySelector("#player").appendChild(ddiv);
}
});
}
}
loop();
}
//ixigua
if (location.hostname == 'www.ixigua.com'){
/**
* var pdata=_SSR_HYDRATED_DATA?.anyVideo?.gidInformation?.packerData;
* var guid=pdata?.video?.item_id?.length>0?pdata?.video?.item_id:pdata?.episodeInfo?.episodeId;
*/
function xgloop(){
if (!document.querySelector("video")){ setTimeout(xgloop,1000);}
var gidim=unsafeWindow._SSR_HYDRATED_DATA?.anyVideo?.gidInformation;
var guid=gidim.gid?.length>0?gidim.gid:(gidim.episodeId?.length>0?gidim.episodeId:gidim.packerData?.episodeInfo?.episodeId);
var gidpath="/".concat(guid);
var pdata=gidim.packerData;
if (gidpath !=location.pathname || location.search.length>0){location=gidpath;}else{
var pd=document.createElement("a");
pd.innerText="嵌入式播放器";pd.href="/embed?group_id="+guid;
pd.target="_self";
pd.style="position:fixed;bottom:1%;left:1%";pd.style.display="table";
pd.style.fontSize="1em";pd.style.margin="0 2em";
document.body.appendChild(pd);
var video_url=null,vd="MP4",vlist=[];
if (pdata.video?.videoResource == undefined){
vlist=Object.values(pdata.videoResource?.normal?.video_list).sort((a,b)=>b.vheight-a.vheight);
}else{
vlist=Object.values(pdata.video?.videoResource?.normal?.video_list).sort((a,b)=>b.vheight-a.vheight);
}
vd=vlist[0].definition;
video_url=vlist[0].main_url;
var videourl=(video_url==null)?"#":video_url;
var pp=document.createElement("a");pp.style.display="table";
pp.innerText=vd;pp.href=videourl;pp.target="_self";pp.style.color="#22AA11";
pp.style="position:fixed;bottom:1%;left:11%";
pp.style.fontSize="1em";pp.style.margin="0 2em";
document.body.appendChild(pp);
}
}
setTimeout(xgloop,500);
}
})();