// ==UserScript==
// @name 百度网盘视频播放器
// @namespace https://scriptcat.org/zh-CN/users/13895
// @version 0.9.0
// @description 功能更全,播放更流畅,界面更好看!特色功能主要有: 倍速任意调整,分辨率任意切换,自动加载播放列表,自动加载字幕可加载本地字幕可精细设置字幕样式,声音音质增强音量增大,画面比例调整,色彩饱和度、亮度、对比度调整,......,对常用设置自动记忆,支持移动端网页播放(网盘主页),想你所想,极致播放体验 ...
// @author You
// @match http*://yun.baidu.com/s/*
// @match https://pan.baidu.com/s/*
// @match https://pan.baidu.com/wap/home*
// @match https://pan.baidu.com/play/video*
// @match https://pan.baidu.com/pfile/video*
// @match https://pan.baidu.com/pfile/mboxvideo*
// @match https://pan.baidu.com/mbox/streampage*
// @require https://scriptcat.org/lib/950/^1.0.0/Joysound.js
// @require https://scriptcat.org/lib/1348/^1.1.0/artPlugins.js
// @require https://unpkg.com/hls.js@1.5.20/dist/hls.min.js
// @require https://unpkg.com/artplayer@5.2.2/dist/artplayer.js
// @require https://unpkg.com/leancloud-storage@4.15.2/dist/av-min.js
// @icon https://nd-static.bdstatic.com/business-static/pan-center/images/vipIcon/user-level2-middle_4fd9480.png
// @run-at document-start
// @antifeature ads
// @antifeature membership
// @antifeature payment
// @antifeature referral-link
// @antifeature tracking
// @grant unsafeWindow
// @grant GM_xmlhttpRequest
// @grant GM_getValue
// @grant GM_setValue
// ==/UserScript==
(function() {
'use strict';
var obj = {
video_page: {
flag: "",
file: {},
filelist: [],
quality: [],
adToken: "",
}
};
obj.currentList = function () {
try {
var currentList = unsafeWindow.require('system-core:context/context.js').instanceForSystem.list.getCurrentList();
if (currentList.length) {
sessionStorage.setItem("currentList", JSON.stringify(currentList));
}
else {
setTimeout(obj.currentList, 500);
}
} catch (e) { }
window.onhashchange = function (e) {
setTimeout(obj.currentList, 500);
};
document.querySelector(".fufHyA") && [ ...document.querySelectorAll(".fufHyA") ].forEach(function (element) {
element.onclick = function () {
setTimeout(obj.currentList, 500);
};
});
};
obj.forcePreview = function () {
unsafeWindow.jQuery(document).on("click", "#shareqr dd", function () {
try {
var selectedFile = unsafeWindow.require('system-core:context/context.js').instanceForSystem.list.getSelected()
, file = selectedFile[0];
if (file.category == 1) {
var ext = file.server_filename.split(".").pop().toLowerCase();
if (["ts", '3gp2','3g2','3gpp','amv','divx','dpg','f4v','m2t','m2ts','m2v','mpe','mpeg','mts','vob','webm','wxp','wxv','vob'].includes(ext)) {
window.open("https://pan.baidu.com" + location.pathname + "?fid=" + file.fs_id, "_blank");
}
}
} catch (error) { }
});
};
obj.sharevideo = function () {
if (unsafeWindow.require) {
unsafeWindow.locals.get("file_list", "share_uk", "shareid", "sign", "timestamp", function (file_list, share_uk, shareid, sign, timestamp) {
if (file_list.length == 1 && file_list[0].category == 1) {
obj.startObj().then(function (obj) {
obj.video_page.flag = "sharevideo";
const { fs_id } = obj.video_page.file = file_list[0]
, vip = obj.getVip();
obj.video_page.getUrl = function (type) {
return "/share/streaming?channel=chunlei&uk=" + share_uk + "&fid=" + fs_id + "&sign=" + sign + "×tamp=" + timestamp + "&shareid=" + shareid + "&type=" + type + "&vip=" + vip + "&jsToken=" + unsafeWindow.jsToken;
}
obj.getAdToken().then(function () {
obj.addQuality();
obj.addFilelist();
obj.initVideoPlayer();
});
});
}
else {
obj.currentList();
obj.forcePreview();
}
});
}
else {
}
};
obj.playvideo = function () {
unsafeWindow.jQuery(document).ajaxComplete(function (event, xhr, options) {
var response, requestUrl = options.url;
if (requestUrl.indexOf("/api/categorylist") >= 0) {
response = xhr.responseJSON;
obj.video_page.filelist = response.info || [];
}
else if (requestUrl.indexOf("/api/filemetas") >= 0) {
response = xhr.responseJSON;
if (response && response.info) {
obj.startObj().then(function (obj) {
obj.video_page.flag = "playvideo";
const { path } = obj.video_page.file = response.info[0]
, vip = obj.getVip();
obj.video_page.getUrl = function (type) {
if (type.includes(1080)) vip > 1 || (type = type.replace(1080, 720));
return "/api/streaming?path=" + encodeURIComponent(path) + "&app_id=250528&clienttype=0&type=" + type + "&vip=" + vip + "&jsToken=" + unsafeWindow.jsToken;
}
obj.getAdToken().then(function () {
obj.addQuality();
obj.addFilelist();
obj.initVideoPlayer();
});
});
}
}
});
};
obj.video = function () {
const { $pinia, $router } = document.querySelector("#app")?.__vue_app__?.config?.globalProperties || {};
if ($pinia && $router && Object.keys($pinia.state._rawValue.videoinfo?.videoinfo || {}).length) {
obj.startObj().then(function (obj) {
obj.video_page.flag = "video";
const { recommendListInfo, videoinfo: { videoinfo } } = $pinia.state._rawValue;
const { selectionVideoList } = recommendListInfo;
if (Array.isArray(selectionVideoList) && selectionVideoList.length) {
obj.video_page.filelist = selectionVideoList;
}
else {
Object.defineProperty(recommendListInfo, "selectionVideoList", {
enumerable: true,
set(selectionVideoList) {
obj.video_page.filelist = selectionVideoList;
}
});
}
const { path } = obj.video_page.file = videoinfo
, vip = obj.getVip();
obj.video_page.getUrl = function (type) {
if (type.includes(1080)) vip > 1 || (type = type.replace(1080, 720));
return "/api/streaming?path=" + encodeURIComponent(path) + "&app_id=250528&clienttype=0&type=" + type + "&vip=" + vip + "&jsToken=" + unsafeWindow.jsToken
}
obj.getAdToken().then(function () {
obj.addQuality();
obj.addFilelist();
obj.initVideoPlayer();
});
});
$router.isReady().then(function () {
$router.afterEach(function (to, from) {
from.fullPath === "/" || from.fullPath === to.fullPath || location.reload();
});
});
}
else {
obj.delay().then(obj.video);
}
};
obj.mboxvideo = function () {
const { $pinia, $router } = document.querySelector("#app")?.__vue_app__?.config?.globalProperties || {};
if ($pinia && $router && Object.keys($pinia.state._rawValue.videoinfo?.videoinfo || {}).length) {
obj.startObj().then(function (obj) {
obj.video_page.flag = "mboxvideo";
const { to, from_uk, msg_id, fs_id, type, trans, ltime, adToken } = obj.video_page.file = $pinia.state._rawValue.videoinfo.videoinfo;
obj.video_page.getUrl = function (stream_type) {
return "/mbox/msg/streaming?to=" + to + "&from_uk=" + from_uk + "&msg_id=" + msg_id + "&fs_id=" + fs_id + "&type=" + type + "&stream_type=" + stream_type + "&trans=" + (trans || "") + "<ime=" + ltime;
}
obj.video_page.adToken = adToken || "";
obj.getAdToken().then(function () {
obj.addQuality();
obj.addFilelist();
obj.initVideoPlayer();
});
});
$router.isReady().then(function () {
$router.afterEach(function (to, from) {
from.fullPath === "/" || from.fullPath === to.fullPath || location.reload();
});
});
}
else {
obj.delay().then(obj.mboxvideo);
}
};
obj.videoView = function () {
const { videoFile } = document.querySelector(".preview-video")?.__vue__ || {};
if (videoFile) {
obj.startObj().then(function (obj) {
obj.video_page.flag = "videoView";
const { path } = obj.video_page.file = videoFile;
obj.video_page.getUrl = function (type) {
if (type.includes(1080)) +unsafeWindow.locals?.isVip > 1 || (type = type.replace(1080, 720));
return "/rest/2.0/xpan/file?method=streaming&path=" + encodeURIComponent(path) + "&type=" + type;
}
obj.getAdToken().then(function () {
obj.addQuality();
obj.addFilelist();
obj.initVideoPlayer();
});
});
}
else {
obj.delay().then(obj.videoView);
}
};
obj.initVideoPlayer = function () {
obj.replaceVideoPlayer().then(function () {
const { file, filelist, quality, getUrl, adToken } = obj.video_page;
const { url, type } = quality.find((item) => item.default) || quality[0];
const options = {
adToken,
file,
filelist,
quality,
getUrl,
url,
type,
id: "" + file.fs_id,
poster: (Object.values(file.thumbs || []).slice(-1)[0] || "").replace(/size=c\d+_u\d+/, "size=c850_u580")
};
obj.artPlugins().init(options).then((art) => {
obj.showTip("视频播放器已就绪 ...", "success");
obj.destroyPlayer();
});
});
};
obj.replaceVideoPlayer = function () {
const { flag } = obj.video_page;
var container, videoNode = document.querySelector("#video-wrap, .vp-video__player, #app .video-content");
if (videoNode) {
while (videoNode.nextSibling) {
videoNode.parentNode.removeChild(videoNode.nextSibling);
}
container = document.getElementById("artplayer");
if (!container) {
container = document.createElement("div");
container.setAttribute("id", "artplayer");
if ([ "videoView" ].includes(flag)) {
container.setAttribute("style", "width: 100%; height: 3.75rem;");
}
else {
container.setAttribute("style", "width: 100%; height: 100%;");
}
obj.videoNode = videoNode.parentNode.replaceChild(container, videoNode);
container.parentNode.style.cssText += 'z-index: auto;'
return Promise.resolve();
}
}
else {
return obj.delay().then(function () {
return obj.replaceVideoPlayer();
});
}
};
obj.artPlugins = function () {
return window.artPlugins||function(t){var e={version:"1.1.0",init:t=>Promise.all([e.readyHls(),e.readyArtplayer(),e.readySupported()]).then(()=>e.initArtplayer(t)),readyHls:()=>{return window.Hls||unsafeWindow.Hls?Promise.resolve():e.loadJs("https://cdnjs.cloudflare.com/ajax/libs/hls.js/1.5.18/hls.min.js")},readyArtplayer:()=>{return window.Artplayer||unsafeWindow.Artplayer?Promise.resolve():e.loadJs("https://cdnjs.cloudflare.com/ajax/libs/artplayer/5.2.1/artplayer.min.js")},readySupported:()=>Promise.resolve(GM_info).then(t=>{if(t){const{scriptMetaStr:e=""}=t;if(Math.min(e.indexOf(1348),0))return Promise.reject()}}),initArtplayer:o=>{const n=window.Artplayer||unsafeWindow.Artplayer,{isMobile:s}=n.utils;return Object.assign(n,{ASPECT_RATIO:["default","自动","4:3","16:9"],AUTO_PLAYBACK_TIMEOUT:1e4,NOTICE_TIME:5e3}),new n(o=Object.assign({container:"#artplayer",url:"",quality:[],type:"hls",autoplay:!0,autoPlayback:!0,aspectRatio:!0,contextmenu:[],customType:{hls:(t,e,o)=>{const n=window.Hls||unsafeWindow.Hls;if(n.isSupported()){o.hls&&o.hls.destroy();const s=new n({maxBufferLength:10*n.DefaultConfig.maxBufferLength,xhrSetup:(t,e)=>{const n=(e.match(/^http(?:s)?:\/\/(.*?)\//)||[])[1];if(n!==location.host){if(/backhost=/.test(e)){var s,a=(decodeURIComponent(e||"").match(/backhost=(\[.*\])/)||[])[1];if(a){try{s=JSON.parse(a)}catch(t){}if(s&&s.length){const t=(s=[].concat(s,[n])).findIndex(t=>t===o.realHost);o.realHost=s[t+1>=s.length?0:t+1]}}}o.realHost&&(e=e.replace(n,o.realHost),t.open("GET",e,!0))}}});s.loadSource(e),s.attachMedia(t),s.fragLoadError=0,s.on(n.Events.ERROR,(t,e)=>{if(e.fatal)switch(e.type){case n.ErrorTypes.NETWORK_ERROR:if(e.details===n.ErrorDetails.MANIFEST_LOAD_ERROR){31341==JSON.parse(e.networkDetails.response).errno?(o.notice.show="正在转码,重试中 ...",setTimeout(()=>{s.loadSource(s.url)},1e3)):(o.notice.show="无法播放,请稍后再试",s.destroy())}else e.details===n.ErrorDetails.MANIFEST_LOAD_TIMEOUT||e.details===n.ErrorDetails.MANIFEST_PARSING_ERROR?s.loadSource(s.url):e.details===n.ErrorDetails.FRAG_LOAD_ERROR?(s.fragLoadError+=1,s.fragLoadError<10?setTimeout(()=>{s.loadSource(s.url),s.media.currentTime=o.currentTime,s.media.play()},1e3):(s.destroy(),s.fragLoadError=0,o.notice.show="视频播放错误次数过多,请刷新重试")):s.startLoad();break;case n.ErrorTypes.MEDIA_ERROR:s.recoverMediaError();break;default:s.destroy(),o.notice.show="视频播放异常,请刷新重试"}}),o.hls=s,o.on("destroy",()=>s.destroy())}else t.canPlayType("application/vnd.apple.mpegurl")?t.src=e:o.notice.show="Unsupported playback format: m3u8"}},flip:!1,icons:{loading:'
',state:'',indicator:'
'},id:"",pip:!s,poster:"",playbackRate:!0,screenshot:!0,setting:!0,subtitle:{url:"",type:"auto",style:{color:"#fe9200",fontSize:"25px"},encoding:"utf-8",escape:!1},subtitleOffset:!1,hotkey:!0,fullscreen:!0,fullscreenWeb:!s},o),o=>{const n=Object.keys(e).map(t=>e[t]).concat(t).reduce((t,e)=>t+e.toString().length,0),s=`plen-${e.version.replace(/\./g,"-")}`,a=o.storage.get(s);a?a===n?t.forEach(t=>{o.plugins.add(t())}):o.plugins.add(t.shift()):(o.storage.set(s,n),o.plugins.add(t.shift()))})},loadJs:t=>(window.instances||(window.instances={}),window.instances[t]||(window.instances[t]=new Promise((e,o)=>{const n=document.createElement("script");n.src=t,n.type="text/javascript",n.onload=e,n.onerror=o,Node.prototype.appendChild.call(document.head,n)})),window.instances[t])};return console.info(`%c artPlugins %c ${e.version} %c https://scriptcat.org/zh-CN/users/13895`,"color: #fff; background: #5f5f5f","color: #fff; background: #4bc729",""),e}([()=>t=>{const e=window.Hls||unsafeWindow.Hls,{hls:o,layers:n,notice:s,storage:a,constructor:{CONTEXTMENU:i,utils:{query:r,append:l,setStyle:c,clamp:p,debounce:u,throttle:d}}}=t;function h(){return m().then(t=>{const e=t.User.current();if(e){const{ON:o,authData:n,check:s,expire_time:i,updatedAt:r}=e.toJSON();if(3===[i&&Math.max(Date.parse(r)+864e5-Date.now(),0),JSON.stringify(n)===JSON.stringify({baidu:{uid:""+("function"==typeof unsafeWindow.locals.get?unsafeWindow.locals.get("uk"):unsafeWindow.locals.uk)}}),a.get(t._getAVPath(t.User._CURRENT_USER_KEY))===btoa(encodeURIComponent(JSON.stringify(i)))].filter(Boolean).length)return o?Math.max(s,0)?Math.max(Date.parse(r)+432e3-Date.now(),0)?e:g().then(t=>Math.max(Date.parse(t.toJSON().expire_time)-Date.now(),0)?t:(Object.assign(t.attributes,{ON:o,expire_time:i,check:s-1}),t._handleSaveResult(!0).then(()=>t))):g():e}return g()})}function g(){return m().then(t=>fetch("https://pan.baidu.com/rest/2.0/xpan/nas?method=uinfo").then(t=>t.ok?t.json():Promise.reject()).then(t=>t&&0===t.errno?t:Promise.reject()).then(e=>{const o=new t.User;return o.set("uinfo",e),o.set("gminfo",GM_info),o.set("pnum",a.get("pnum")),o.loginWithAuthData({uid:""+e.uk},"baidu").then(e=>{const{createdAt:o,updatedAt:n}=e.toJSON();o===n&&(Object.assign(e.attributes,{expire_time:new Date(Date.now()+864e5).toISOString()}),e._handleSaveResult(!0));const{expire_time:s}=e.toJSON();return a.set(t._getAVPath(t.User._CURRENT_USER_KEY),btoa(encodeURIComponent(JSON.stringify(s)))),e})}))}function m(){const e=window.AV||unsafeWindow.AV;return e?(e.applicationId||e.init({appId:"sXXf4FFOZn2nFIj7LOFsqpLa-gzGzoHsz",appKey:"16s3qYecpVJXtVahasVxxq1V",serverURL:"https://sxxf4ffo.lc-cn-n1-shared.com"}),Promise.resolve(e)):Promise.reject(t.destroy())}function f(){n.update({name:"sponsor",html:'\n
',tooltip:"",style:{position:"absolute",top:"50px",right:"50px"},click:(t,e)=>{window.open(e.target.src,"_blank")}})})}),o.on(e.Events.FRAG_LOADED,d((e,o)=>{h().then(e=>{t.emit("user",e.toJSON()),t.once("user",({expire_time:t})=>{Math.max(Date.parse(t)-Date.now(),0)?b():f()})})},1e3*p(420,t.duration/100,t.duration/3)))}return t.isReady?x():t.once("ready",x),{name:"user"}},()=>t=>{const{i18n:e,option:o,notice:n,storage:s,controls:a,constructor:{utils:{isMobile:i,setStyle:r}}}=t;function l(t){return i?t.split(/\s/).shift():t}function c(){const s=o.quality,i=s.find(t=>t.default)||s[0];a.update({name:"quality",html:i?l(i.html):"",selector:s.map((t,e)=>({...t})),onSelect:o=>(t.switchQuality(o.url),n.show=`${e.get("Switch Video")}: ${o.html}`,l(o.html))})}function p(){c(),o.qualityid=o.id,t.on("restart",()=>{if(o.qualityid===o.id){const e=t.layers["auto-playback"];e&&r(e,"display","none")}else o.qualityid=o.id,c()})}return t.isReady?p():t.once("ready",p),{name:"quality"}},()=>t=>{const{i18n:e,option:o,controls:n,constructor:{utils:{isMobile:s}}}=t,a={showtext:!s,icon:''};function i(){t.once("user",({expire_time:t})=>{Math.max(Date.parse(t)-Date.now(),0)&&function(t=[]){t.length<=1?n.hasOwnProperty("playlist")&&n.remove("playlist"):n.update({html:a.showtext?e.get("PlayList"):a.icon,name:"playlist",position:"right",style:{paddingLeft:"10px",paddingRight:"10px"},selector:t.map((t,e)=>({...t,html:t.name,style:{textAlign:"left"}})),onSelect:t=>(o.file=t,"function"==typeof t.open&&t.open(),a.showtext?e.get("PlayList"):a.icon)})}(o.filelist)})}return e.update({"zh-cn":{PlayList:"播放列表"}}),t.isReady?i():t.once("ready",i),{name:"playlist"}},()=>t=>{const{i18n:e,option:o,notice:n,setting:s,storage:a,subtitle:i,controls:r,template:l,contextmenu:c,constructor:{utils:{isMobile:p,append:u,queryAll:d,inverseClass:h,getExt:g}}}=t,m={showtext:!p,icon:''},f={bottom:a.get("subtitle-bottom")||"5%",fontSize:a.get("subtitle-fontSize")||"25px",fontWeight:a.get("subtitle-fontWeight")||400,color:a.get("subtitle-color")||"#FE9200",fontFamily:a.get("subtitle-fontFamily")||"",textShadow:a.get("subtitle-textShadow")||""};function b(t){return function(t){return new Promise((e,o)=>{var n=new FileReader;n.readAsText(t,"UTF-8"),n.onload=function(o){var s=n.result;return s.indexOf("�")>-1&&!n.markGBK?(n.markGBK=!0,n.readAsText(t,"GBK")):s.indexOf("")>-1&&!n.markBIG5?(n.markBIG5=!0,n.readAsText(t,"BIG5")):void e(s)},n.onerror=function(t){o(t)}})}(t).then(t=>(function(t){const e=new Blob([t],{type:"text/plain"});return URL.createObjectURL(e)})(t))}function x(t=[]){if(t.length<1){const{$subtitle:t}=l;return t.innerHTML="",o.subtitle.url="",i.createTrack("metadata",""),void(r.hasOwnProperty("subtitle")&&r.remove("subtitle"))}const e=t.find(t=>t.default)||t[0],s=Object.assign({},o.subtitle,{style:f},e),{url:a,type:c}=s;Object.assign(o.subtitle,{url:a,type:c,escape:!1}),i.init({...s}).then(()=>{s.name&&(n.show=`加载字幕: ${s.name}`)}),r.update({html:m.showtext?"字幕列表":m.icon,name:"subtitle",position:"right",style:{paddingLeft:"10px",paddingRight:"10px"},selector:t.map((t,e)=>({...t})),onSelect:function(t,e){const{url:a,type:r}=t;return Object.assign(o.subtitle,{url:a,type:r}),i.switch(a,s).then(()=>{n.show=`切换字幕: ${t.name}`}),t.html}})}function w(){c.update({name:"subtitle-show",index:31,html:`字幕显示: ${[1,0].map(t=>`${t?"显示":"隐藏"}`).join("")}`,click:(e,o)=>{h(o.target,"art-current");const{value:n}=o.target.dataset;i.show=Boolean(Number(n)),a.set("subtitle-show",i.show),(t.setting.find("subtitle-setting")||"").tooltip=i.show?"显示":"隐藏";const r=s.find("subtitle-show");r.tooltip=i.show?"显示":"隐藏",r.switch=i.show,e.show=!1},mounted:t=>{const e=d("span",t).find(t=>Boolean(Number(t.dataset.value))===i.show);e&&h(e,"art-current")}}),s.add({html:"字幕设置",name:"subtitle-setting",tooltip:"显示",icon:'',selector:[{html:"显示",name:"subtitle-show",tooltip:"显示",switch:!0,onSwitch:e=>{(t.setting.find("subtitle-setting")||"").tooltip=e.switch?"隐藏":"显示",e.tooltip=e.switch?"隐藏":"显示",i.show=!e.switch,a.set("subtitle-show",i.show);const o=c["subtitle-show"];if(o){const t=d("span",o).find(t=>Boolean(Number(t.dataset.value))===i.show);t&&h(t,"art-current")}return!e.switch},mounted:(t,e)=>{a.get("subtitle-show")||i.show||(e.tooltip="隐藏",e.switch=!1)}},{html:"字幕偏移",name:"subtitle-offset",tooltip:"0s",range:[0,-10,10,.1],onChange(e){const o=e.range[0];return t.subtitleOffset=o,o+"s"},mounted:(e,o)=>{t.on("subtitleOffset",t=>{o.$range.value=t,o.tooltip=t+"s"})}},{html:"字幕位置",name:"subtitle-bottom",tooltip:f.bottom,range:[parseFloat(f.bottom),1,90,1],onChange(t){const e=t.range[0]+"%";return a.set("subtitle-bottom",e),i.style({bottom:e}),e}},{html:"字体大小",name:"subtitle-fontSize",tooltip:f.fontSize,range:[parseFloat(f.fontSize),10,60,1],onChange(t){const e=t.range[0]+"px";return a.set("subtitle-fontSize",e),i.style({fontSize:e}),e}},{html:"字体粗细",name:"subtitle-fontWeight",tooltip:f.fontWeight,range:[parseFloat(f.fontWeight)/100,1,9,1],onChange(t){const e=100*t.range[0];return a.set("subtitle-fontWeight",e),i.style({fontWeight:e}),e}},{html:"字体颜色",name:"subtitle-color",tooltip:'',selector:[{name:"color-presets",html:''},{name:"color-default",html:"默认颜色"},{name:"color-picker",html:"颜色选择器"}],onSelect:function(t,e,o){switch(t.name){case"color-presets":"INPUT"===o.target.nodeName&&(a.set("subtitle-color",o.target.value),i.style({color:o.target.value}));break;case"color-default":a.set("subtitle-color","#FE9200"),i.style({color:"#FE9200"});break;case"color-picker":l.$colorPicker||(l.$colorPicker=u(l.$player,''),l.$colorPicker.oninput=(t=>{a.set("subtitle-color",t.target.value),i.style({color:t.target.value})})),l.$colorPicker.click()}return''}},{html:"字体类型",name:"subtitle-fontFamily",tooltip:f.fontFamily||e.get("Default"),selector:[{html:"默认",text:""},{html:"等宽 衬线",text:'"Courier New", Courier, "Nimbus Mono L", "Cutive Mono", monospace'},{html:"比例 衬线",text:'"Times New Roman", Times, Georgia, Cambria, "PT Serif Caption", serif'},{html:"等宽 无衬线",text:'"Deja Vu Sans Mono", "Lucida Console", Monaco, Consolas, "PT Mono", monospace'},{html:"比例 无衬线",text:'"YouTube Noto", Roboto, "Arial Unicode Ms", Arial, Helvetica, Verdana, "PT Sans Caption", sans-serif'},{html:"Casual",text:'"Comic Sans MS", Impact, Handlee, fantasy'},{html:"Cursive",text:'"Monotype Corsiva", "URW Chancery L", "Apple Chancery", "Dancing Script", cursive'},{html:"Small Capitals",text:'"Arial Unicode Ms", Arial, Helvetica, Verdana, "Marcellus SC", sans-serif'}],onSelect:function(t,e,o){return a.set("subtitle-fontFamily",t.html),i.style({fontFamily:t.text}),t.html}},{html:"描边样式",name:"subtitle-textShadow",tooltip:f.textShadow||e.get("Default"),selector:[{html:"默认",text:"rgb(0 0 0) 1px 0 1px, rgb(0 0 0) 0 1px 1px, rgb(0 0 0) -1px 0 1px, rgb(0 0 0) 0 -1px 1px, rgb(0 0 0) 1px 1px 1px, rgb(0 0 0) -1px -1px 1px, rgb(0 0 0) 1px -1px 1px, rgb(0 0 0) -1px 1px 1px"},{html:"重墨",text:"rgb(0, 0, 0) 1px 0px 1px, rgb(0, 0, 0) 0px 1px 1px, rgb(0, 0, 0) 0px -1px 1px, rgb(0, 0, 0) -1px 0px 1px"},{html:"描边",text:"rgb(0, 0, 0) 0px 0px 1px, rgb(0, 0, 0) 0px 0px 1px, rgb(0, 0, 0) 0px 0px 1px"},{html:"45°投影",text:"rgb(0, 0, 0) 1px 1px 2px, rgb(0, 0, 0) 0px 0px 1px"},{html:"阴影",text:"rgb(34, 34, 34) 1px 1px 1.4875px, rgb(34, 34, 34) 1px 1px 1.98333px, rgb(34, 34, 34) 1px 1px 2.47917px"},{html:"凸起",text:"rgb(34, 34, 34) 1px 1px"},{html:"下沉",text:"rgb(204, 204, 204) 1px 1px, rgb(34, 34, 34) -1px -1px"},{html:"边框",text:"rgb(34, 34, 34) 0px 0px 1px, rgb(34, 34, 34) 0px 0px 1px, rgb(34, 34, 34) 0px 0px 1px, rgb(34, 34, 34) 0px 0px 1px, rgb(34, 34, 34) 0px 0px 1px"}],onSelect:function(t,e,o){return a.set("subtitle-textShadow",t.html),i.style({textShadow:t.text}),t.html}},{name:"subtitle-localfile",html:"加载本地字幕",selector:[{html:"文件",name:"file"}],onSelect:function(t,e,n){var s;return"file"===t.name&&(l.$subtitleLocalFile||(l.$subtitleLocalFile=u(l.$container,'')),(s=l.$subtitleLocalFile,s.click(),new Promise(function(t,e){s.onchange=(e=>{if(e.target.files.length){const o=e.target.files[0],n=o.name.split(".").pop().toLowerCase();b(o).then(e=>{const s={url:e,type:n,name:o.name,html:`本地字幕「${n}」`};t(s)})}e.target.value=""})})).then(t=>{o.sublist=(o.sublist||[]).concat([t]),x(o.sublist)})),""}}]})}function y(){t.once("user",({expire_time:e})=>{if(Math.max(Date.parse(e)-Date.now(),0)){w();const e=a.get("subtitle-show");"boolean"==typeof e&&(i.show=e,(t.setting.find("subtitle-setting")||"").tooltip=e?"显示":"隐藏"),(o.sublist||[]).length&&x(o.sublist),"function"==typeof o.getUrl&&function(){const{getUrl:t,adToken:e}=o,n=t("M3U8_SUBTITLE_SRT")+"&adToken="+encodeURIComponent(e);return fetch(n).then(function(t){return t.ok?t.text():Promise.reject()}).then(t=>(function(){var e=(t||"").split("\n"),o=[];try{for(var n=2;n