├── Fonts
├── Microsoft_YaHei_UI.TTF
├── NotoSansSC-Regular.otf
└── SourceHanSansCN-Bold.woff2
├── Joysound.js
├── PipLyric.js
├── README.md
├── Secp256k1.js
├── alipanArtPlugins.js
├── alipanThirdParty.js
├── appreciation.png
├── 天翼云盘-下载不求人.user.js
├── 天翼云盘音乐播放器.user.js
├── 夸克网盘.user.js
├── 我是网盘管家婆 .user.js
├── 百度网盘视频播放器.user.js
├── 百度网盘音频播放器.user.js
└── 阿里云盘.user.js
/Fonts/Microsoft_YaHei_UI.TTF:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tampermonkeyStorage/Self-use/21a11fdb1a9dbc59fd3017e0e5f733def2e16a9d/Fonts/Microsoft_YaHei_UI.TTF
--------------------------------------------------------------------------------
/Fonts/NotoSansSC-Regular.otf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tampermonkeyStorage/Self-use/21a11fdb1a9dbc59fd3017e0e5f733def2e16a9d/Fonts/NotoSansSC-Regular.otf
--------------------------------------------------------------------------------
/Fonts/SourceHanSansCN-Bold.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tampermonkeyStorage/Self-use/21a11fdb1a9dbc59fd3017e0e5f733def2e16a9d/Fonts/SourceHanSansCN-Bold.woff2
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 一个网盘云盘综合性的油猴脚本
2 | 功能有:在各个主流网盘主页和分享链接页面增加资源搜索选项,收集了全网所有资源搜索站点
3 |
--------------------------------------------------------------------------------
/alipanArtPlugins.js:
--------------------------------------------------------------------------------
1 | window.alipanArtPlugins=window.alipanArtPlugins||function(t){var e={version:"1.0.3",init:t=>Promise.all([e.readyHls(),e.readyArtplayer(),e.readySupported()]).then(()=>e.initArtplayer(t)),readyHls:()=>{return window.Hls||unsafeWindow.Hls?Promise.resolve():e.loadScript("https://cdnjs.cloudflare.com/ajax/libs/hls.js/1.5.15/hls.min.js")},readyArtplayer:()=>{return window.Artplayer||unsafeWindow.Artplayer?Promise.resolve():e.loadScript("https://cdnjs.cloudflare.com/ajax/libs/artplayer/5.2.2/artplayer.min.js")},readySupported:()=>Promise.resolve(t).then(t=>{const{version:o}=e,n=GM_getValue("art-"+o,0),s=t.reduce((t,e)=>t+e.toString().length,0);if(n){if(2===new Set([n,s]).size)return Promise.reject()}else GM_setValue("art-"+o,s)}),readyM3u8Parser:()=>{return window.m3u8Parser||unsafeWindow.m3u8Parser?Promise.resolve():e.loadScript("https://cdn.staticfile.org/m3u8-parser/7.2.0/m3u8-parser.min.js")},initArtplayer:o=>{if(o=e.initOption(o),!Array.isArray(o.quality)||!o.quality.find(t=>t&&t.url))return alert("获取播放信息失败,请刷新网页重试"),Promise.reject("No available playUrl");const n=window.Artplayer||unsafeWindow.Artplayer;return Object.assign(n,{ASPECT_RATIO:["default","自动","4:3","16:9"],AUTO_PLAYBACK_TIMEOUT:1e4,NOTICE_TIME:5e3}),Object.assign(n.utils,{loadScript:e.loadScript}),new n(o,o=>{t.forEach(t=>{o.plugins.add(t())}),o.on("resumeed",t=>{const{option:n}=o,{quality:s}=e.initOption({video_info:t});n.quality=s,e.readyM3u8Parser().thrn(()=>{e.loadStreaming(o)})}),o.on("reloaded",t=>{const{option:n,notice:s,i18n:i}=o,{url:a,type:r,quality:l,sublist:c}=e.initOption({video_info:t});if(Object.assign(n,{url:a,type:r,quality:l,sublist:c}),a)return o.switchUrl(a),void(s.show=`${i.get("Switch Video")}: ${n.file.name}`);s.show=`${i.get("Switch Video")}: ERRORR 视频地址不可用`})})},initOption:t=>{const e={container:"#artplayer",url:"",quality:[],type:"hls",autoplay:!0,autoPlayback:!0,aspectRatio:!0,contextmenu:[{html:"打赏作者",index:51,click:(t,e)=>{window.open("https://jsd.nn.ci/gh/tampermonkeyStorage/Self-use@master/appreciation.png","_blank"),t.show=!1}},{html:"检查更新",index:52,click:(t,e)=>{window.open("https://scriptcat.org/zh-CN/script-show-page/162","_blank"),t.show=!1}}],customType:{hls:(t,e,o)=>{const n=window.Hls||unsafeWindow.Hls;if(n.isSupported()){o.hls&&o.hls.destroy();const s=new n({maxBufferLength:60});s.loadSource(e),s.attachMedia(t),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:!0,icons:{loading:'
',state:'
',indicator:'
'},id:"",pip:!0,playbackRate:!0,screenshot:!0,setting:!0,subtitle:{url:"",type:"vtt",style:{color:"#fe9200"},escape:!1,encoding:"utf-8"},subtitleOffset:!1,hotkey:!0,fullscreen:!0,fullscreenWeb:!0},{video_info:o,video_file:n,video_items:s}=t||{};if(n){const{file_id:t,thumbnail:o=""}=n;Object.assign(e,{file:n,id:t,poster:o})}if(s&&((s.find(t=>t.file_id===e.id)||{}).default=!0,Object.assign(e,{filelist:s})),o){const{live_transcoding_task_list:t,live_transcoding_subtitle_task_list:n,meta:s,quick_video_list:i,quick_video_subtitle_list:a}=o.video_preview_play_info,r={QHD:"1440 超清",FHD:"1080 全高清",HD:"720 高清",SD:"540 标清",LD:"360 流畅"},l=(i||t||[]).map((t,e)=>t.url&&{...t,html:r[t.template_id],type:"hls"}).filter(Boolean);l.sort((t,e)=>e.template_height-t.template_height),(l.find(t=>t.url)||l[0]||{}).default=!0;const{url:c,type:u}=l.find(t=>t.default)||l[0];Object.assign(e,{quality:l,url:c,type:u});const p={chi:"中文字幕",zho:"中文字幕",eng:"英文字幕",jpn:"日文字幕"},d=(a||n||[]).map((t,e)=>t.url&&{...t,html:`${p[t.language]||t.language||"未知语言"}`,name:`${p[t.language]||t.language||"未知语言"} - 内镶字幕「vtt」`,type:"vtt"}).filter(Boolean);(d.find(t=>["chi","zho"].includes(t.language))||d[0]||{}).default=!0,Object.assign(e,{sublist:d})}return e},loadStreaming:t=>{const{hls:e,notice:o,i18n:n,option:{quality:s}}=t,i=s.find(t=>t&&t.default)||s.findLast(t=>t&&t.url);if(!i.url)return void(o.show=`${n.get("Switch Video")}: ERRORR 视频地址不可用`);const a=e.url=i.url;fetch(a).then(t=>t.ok?t.text():Promise.reject()).then(o=>{const n=new(window.m3u8Parser||unsafeWindow.m3u8Parser).Parser;n.push(o),n.end();const s=a.replace(/media.m3u8.+/,""),i=n.manifest.segments;e.bufferController.details.fragments.forEach((t,e)=>{const o=i[e];Object.assign(t,{baseurl:a,relurl:o.uri,url:s+o.uri})}),e.startLoad(t.currentTime)}).catch(t=>{throw o.show=t,t})},loadScript: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 alipanArtPlugins %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:i,constructor:{CONTEXTMENU:a,utils:{query:r,append:l,setStyle:c,clamp:u,debounce:p,throttle:d}}}=t;function h(){return f().then(t=>{const e=t.User.current();if(e){const{ON:o,authData:n,check:s,expire_time:a,updatedAt:r}=e.toJSON();if(3===[Math.max(Date.parse(r)+864e5-Date.now(),0),JSON.stringify(n)===JSON.stringify({aliyundrive:{uid:""+function(){try{return JSON.parse(localStorage.getItem("token")).user_id}catch(t){return""}}()}}),i.get(t._getAVPath(t.User._CURRENT_USER_KEY))===btoa(encodeURIComponent(JSON.stringify(a)))].filter(Boolean).length)return o?Math.max(s,0)?Math.max(Date.parse(r)+432e3-Date.now(),0)?e:m().then(t=>Math.max(Date.parse(t.toJSON().expire_time)-Date.now(),0)?t:(Object.assign(t.attributes,{ON:o,expire_time:a,check:s-1}),t._handleSaveResult(!0).then(()=>t))):m():e}return m()})}function m(){return f().then(t=>Promise.resolve().then(()=>{try{return JSON.parse(localStorage.getItem("token"))}catch(t){return Promise.reject()}}).then(e=>{const o=new t.User;return o.set("uinfo",e),o.set("gminfo",GM_info),o.set("pnum",i.get("pnum")),o.loginWithAuthData({uid:""+e.user_id},"aliyundrive").then(e=>{delete e.attributes.uinfo,delete e.attributes.gminfo;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 i.set(t._getAVPath(t.User._CURRENT_USER_KEY),btoa(encodeURIComponent(JSON.stringify(s)))),e})}))}function f(){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 g(){w()||n.update({name:"sponsor",html:'\n
\n \n \n \n \n
\n \n \n \n \n
\n ',tooltip:"感谢支持,赞助后不再提示",style:{position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)",background:"rgba(0, 0, 0, 0.7)",border:"1px solid #c6c6c6",borderRadius:"8px",textAlign:"center"},click:(e,o)=>{o.isTrusted||t.destroy(),t.mask.show=!1,t.loading.show=!1},mounted:e=>{t.pause();try{o.pauseBuffering()}catch(t){o.stopLoad()}setTimeout(()=>{t.mask.show=!1,t.loading.show=!1,t.controls.show=!1,t.setting.show=!1,t.constructor.CONTEXTMENU=!1},500);const n=r("#open-afdian",e),a=r("#copy-order",e),l=r("#update-script",e);t.proxy(n,"click",()=>{window.open("https://afdian.com/order/create?plan_id=be4f4d0a972811eda14a5254001e7c00","_blank")}),t.proxy(a,"click",()=>{window.open("https://afdian.com/dashboard/order","_blank")}),t.proxy(l,"click",()=>{window.open("https://scriptcat.org/scripts/code/162/%E9%98%BF%E9%87%8C%E4%BA%91%E7%9B%98.user.js","_blank")});const c=r("#order-input",e),p=r("#cancel-order",e),d=r("#submit-order",e);t.proxy(p,"click",({isTrusted:t})=>{t&&b()}),t.proxy(d,"click",()=>{if(c.value){const t=c.value.trim();if(t.match(/^202[\d]{22,25}$/)){if(t.match(/(\d)\1{7,}/g))return;(function(t){t=t.slice(0,14);const[,e,o,n,s,i,a]=(t.match(/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/)||[]).map(Number);return 5===[u(o,1,12)===o,u(n,1,31)===n,u(s,0,23)===s,u(i,0,59)===i,u(a,0,59)===a].filter(Boolean).length})(t)&&function(t){const e=i.get(t)||0;if(i.set(t,e+1),!(e>33))f().then(e=>h().then(o=>{const{authData:n,expire_time:s,shortId:a,username:r}=o.toJSON(),l=new(e.Object.extend("aliyundrive"));l.set("ON",t),l.set("pnum",i.get(t));for(let[t,e]of Object.entries({authData:n,expire_time:s,shortId:a,username:r}))l.set(t,e);return l.save().then(n=>{Object.assign(o.attributes,{ON:t,check:3,expire_time:new Date(Date.now()+864e3).toISOString()});const{expire_time:s}=o.toJSON();return i.set(e._getAVPath(e.User._CURRENT_USER_KEY),btoa(encodeURIComponent(JSON.stringify(s)))),o._handleSaveResult(!0)})}))}(t),b()}else s.show="此订单号不合规范,请重试"}else s.show="请输入订单号"})}})}function b(){if(w()){n.remove("sponsor"),t.constructor.CONTEXTMENU=a;try{o.resumeBuffering()}catch(t){o.startLoad()}}}function w(){if(n.hasOwnProperty("sponsor")){const{display:e,visibility:o,opacity:s}=window.getComputedStyle(n.sponsor);return"none"!==e&&"hidden"!==o&&0!==parseFloat(s)||t.destroy(),!0}return!1}function y(){t.contextmenu.update({index:53,html:"更多功能",click:()=>{g(),t.contextmenu.show=!1}}),t.setting.update({html:"更多功能",name:"more-setting",tooltip:"",selector:[{html:"更多功能",value:0},{html:"打赏作者",value:1}],onSelect:t=>(0===t.value?g():1===t.value&&window.open("https://jsd.nn.ci/gh/tampermonkeyStorage/Self-use@master/appreciation.png","_blank"),"")});let n=Number(i.get("pnum")||0);i.set("pnum",++n),t.on("video:ended",()=>{h().then(e=>{const{expire_time:o}=e.toJSON();Math.max(Date.parse(o)-Date.now(),0)||t.layers.update({name:"potser",html:'
',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,n)=>{h().then(e=>{t.emit("user",e.toJSON()),t.once("user",({expire_time:t})=>{Math.max(Date.parse(t)-Date.now(),0)?b():g(),f().then(e=>{new Set([i.get(e._getAVPath(e.User._CURRENT_USER_KEY)),btoa(encodeURIComponent(JSON.stringify(t)))]).size>1&&o.destroy()})})})},1e3*u(420,t.duration/100,t.duration/3)))}return t.isReady?y():t.once("ready",y),{name:"user",userJSON:function(){return h().then(t=>t.toJSON())},show:g}},()=>t=>{const e=window.Hls||unsafeWindow.Hls,{hls:o,option:n,notice:s}=t;var i=Date.now(),a=0;return o.on(e.Events.ERROR,(r,l)=>{if(l.fatal)switch(s.show=`当前带宽: ${Math.round(o.bandwidthEstimate/1024/1024/8*100)/100} MBps/s`,l.type){case e.ErrorTypes.NETWORK_ERROR:l.details===e.ErrorDetails.MANIFEST_LOAD_ERROR||l.details===e.ErrorDetails.MANIFEST_LOAD_TIMEOUT||l.details===e.ErrorDetails.MANIFEST_PARSING_ERROR?o.loadSource(o.url):l.details===e.ErrorDetails.FRAG_LOAD_ERROR?++a<10&&(o.loadSource(o.url),o.media.currentTime=t.currentTime,o.media.play()):o.startLoad();break;case e.ErrorTypes.MEDIA_ERROR:o.recoverMediaError();break;default:s.show="视频播放异常,请刷新重试",o.destroy()}else switch(l.type){case e.ErrorTypes.NETWORK_ERROR:l.details===e.ErrorDetails.FRAG_LOAD_ERROR&&function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:6e3,o=t.match(/&x-oss-expires=(\d+)&/);return o?+"".concat(o[1],"000")-e3e5-e}(o.url)&&(a=0,i=Date.now(),o.stopLoad(),t.emit("resume",n.file))}}),{name:"hlsevents"}},()=>(function(t){const{i18n:e,option:o,notice:n,storage:s,controls:i,constructor:{utils:{isMobile:a,setStyle:r}}}=t;function l(t){return a?t.split(/\s/).shift():t}function c(){const a=o.quality,r=a.find(t=>t.default)||a[0];i.update({name:"quality",html:r?l(r.html):"",selector:a.map((t,e)=>({...t})),onSelect:o=>{if(o.url)return s.set("quality",l(o.html)),t.switchQuality(o.url),n.show=`${e.get("Switch Video")}: ${o.html}`,l(o.html);n.show="视频地址不可用"},mounted:()=>{const e=s.get("quality");if(e){const o=i.cache.get("quality").option.selector.find(t=>l(t.html)===e);o&&!o.default&&(t.switchQuality(o.url),i.check(o))}}})}function u(){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?u():t.once("ready",u),{name:"quality"}}),()=>(function(t){const{i18n:e,proxy:o,option:n,notice:s,storage:i,controls:a,constructor:{utils:{query:r,isMobile:l,debounce:c}}}=t,u={showtext:!l,icon:''};function p(){(n.filelist||[]).length>1&&(n.filelist,a.update({html:u.showtext?e.get("PlayList"):u.icon,name:"playlist",position:"right",tooltip:"",style:{marginLeft:"10px",marginRight:"10px"},selector:n.filelist.map((t,e)=>({...t,html:t.name,style:{textAlign:"left"}})),onSelect:o=>(n.file=o,n.id=o.file_id,t.emit("reload",o),s.show=`${e.get("Switch Video")}`,u.showtext?e.get("PlayList"):u.icon),mounted:()=>{const t=a.cache.get("playlist"),{$ref:e,option:{selector:n}}=t,s=r(".art-selector-list",e),i=r(".art-selector-value",e),l=s.offsetHeight,c=s.firstElementChild.offsetHeight;o(i,"click",t=>{const e=n.findIndex(t=>t.default);s.scrollTop=(e+1)*c-l/2})}}))}return e.update({"zh-cn":{PlayList:"播放列表"}}),t.isReady?p():t.once("ready",p),{name:"playlist"}}),()=>t=>{const{i18n:e,option:o,notice:n,setting:s,storage:i,plugins:a,subtitle:r,controls:l,template:c,contextmenu:u,constructor:{utils:{getExt:p,clamp:d,srtToVtt:h,assToVtt:m,vttToBlob:f,query:g,append:b,isMobile:w,debounce:y,throttle:x,loadScript:v,inverseClass:S}}}=t,k={showtext:!w,icon:'',tooltip:''};function _(s=[]){const i=s.find(t=>t.default)||Object.assign(s[0],{default:!0}),a=Object.assign({},{...o.subtitle},{style:o.subtitle.style},i);R({...a}).then(()=>{a.name&&(n.show=`加载字幕: ${a.name}`),c.$track.onerror=(e=>{n.show=`字幕加载失败: ${r.option.name}`,t.emit("subtitleError",r.cues,r.option)})}),l.update({html:k.showtext?"字幕列表":k.icon,name:"subtitle",position:"right",style:{paddingLeft:"10px",paddingRight:"10px"},selector:s.map((t,e)=>({...t})),onSelect:(s,i)=>{n.show=`${e.get("Switch Subtitle")}`;const a=Object.assign({},o.subtitle,{style:o.subtitle.style},s);return R({...a}).then(()=>{a.name&&(n.show=`${e.get("Switch Subtitle")}: ${a.name}`),c.$track.onerror=(e=>{n.show=`字幕加载失败: ${r.option.name}`,t.emit("subtitleError",r.cues,r.option)})}),k.showtext?"字幕列表":k.icon}})}function O(t=[]){t=Array.from(new Set(t)),l.hasOwnProperty("subtitle")?l.update({name:"subtitle",selector:t.map((t,e)=>({...t}))}):_(t)}function R(t){return t.text?Promise.resolve().then(()=>{const{type:e,text:o}=t;switch(e){case"srt":{const e=h(o),n=t.onVttLoad(e);return f(n)}case"ssa":case"ass":{const e=m(o),n=t.onVttLoad(e);return f(n)}case"webvtt":case"vtt":{const e=t.onVttLoad(o);return f(e)}default:return n.show=`无法识别的字幕格式: ${e}`,t.url}}).then(e=>(r.option=t,r.style(t.style),c.$subtitle.innerHTML="",r.url===e?e:(URL.revokeObjectURL(r.url),r.createTrack("metadata",e),e))).catch(t=>{throw c.$subtitle.innerHTML="",n.show=t,t}):t.url?r.init(t):(n.show=`不是正确的字幕文件: ${t.name}`,Promise.reject())}function D(t){return new Promise((e,o)=>{const n=new FileReader;n.readAsText(t,"UTF-8"),n.onload=(o=>{const 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=(t=>{o(t)})})}function T(){(o.sublist||[]).length&&_(o.sublist),t.once("user",({expire_time:e})=>{if(Math.max(Date.parse(e)-Date.now(),0)){for(let[t,e]of Object.entries({color:i.get("subtitle-color"),bottom:i.get("subtitle-bottom"),fontSize:i.get("subtitle-fontSize"),fontWeight:i.get("subtitle-fontWeight"),fontFamily:i.get("subtitle-fontFamily"),textShadow:i.get("subtitle-textShadow")}))e&&r.style(t,e);t.on("subtitle",t=>i.set("subtitle",t));const e=i.get("subtitle");"boolean"==typeof e&&(r.show=e),t.on("sublist",t=>{(t||[]).length&&(o.sublist=(o.sublist||[]).concat(t),O(o.sublist))})}}),o.subid=o.id,t.on("restart",()=>{if(o.subid===o.id){(l.cache.get("subtitle").option.selector||[]).length&&r.createTrack("metadata",r.url)}else{o.subid=o.id;const{$subtitle:t}=c;t.innerHTML="",o.subtitle.url="",r.createTrack("metadata",""),l.hasOwnProperty("subtitle")&&l.remove("subtitle"),(o.sublist||[]).length&&O(o.sublist)}})}return s.update({html:"字幕设置",name:"subtitle-setting",tooltip:"",icon:'',selector:[{html:"显示",name:"subtitle",tooltip:"显示",switch:!0,onSwitch:t=>(t.tooltip=t.switch?"隐藏":"显示",r.show=!t.switch,!t.switch),mounted:(e,o)=>{const n=r.show;o.switch=n,o.tooltip=n?"显示":"隐藏",t.on("subtitle",t=>{setTimeout(()=>{o.switch!==t&&(o.switch=t,o.tooltip=t?"显示":"隐藏")})})}},{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=>{setTimeout(()=>{o.$range.value=t,o.tooltip=t+"s"})})}},{html:"字幕位置",name:"subtitle-bottom",tooltip:"5%",range:[5,1,90,1],onChange(t){const e=t.range[0]+"%";return r.style({bottom:e}),i.set("subtitle-bottom",e),e},mounted:(t,e)=>{const o=i.get("subtitle-bottom");o&&(e.tooltip=o,e.$range.value=parseFloat(o))}},{html:"字体大小",name:"subtitle-fontSize",tooltip:"25px",range:[25,10,60,1],onChange(t){const e=t.range[0]+"px";return r.style({fontSize:e}),i.set("subtitle-fontSize",e),e},mounted:(t,e)=>{const o=i.get("subtitle-fontSize");o&&(e.tooltip=o,e.$range.value=parseFloat(o))}},{html:"字体粗细",name:"subtitle-fontWeight",tooltip:400,range:[4,1,9,1],onChange(t){const e=100*t.range[0];return i.set("subtitle-fontWeight",e),r.style({fontWeight:e}),e},mounted:(t,e)=>{const o=i.get("subtitle-fontWeight");o&&(e.tooltip=o,e.$range.value=o/100)}},{html:"字体颜色",name:"subtitle-color",tooltip:k.tooltip,selector:[{html:"预设",name:"color-presets",tooltip:''},{html:"默认颜色",name:"color-default",tooltip:k.tooltip},{html:"颜色选择器",name:"color-picker",tooltip:k.tooltip.replace("#FE9200","#000")}],onSelect:function(t,e,o){switch(t.name){case"color-presets":if("INPUT"===o.target.nodeName){const t=o.target.value;r.style({color:t}),i.set("subtitle-color",t)}break;case"color-default":r.style({color:"#FE9200"}),i.set("subtitle-color","#FE9200");break;case"color-picker":c.$colorPicker||(c.$colorPicker=b(c.$player,''),c.$colorPicker.oninput=(e=>{const o=e.target.value;r.style({color:o}),i.set("subtitle-color",o),t.tooltip=t.$parent.tooltip=k.tooltip.replace("#FE9200",o)})),c.$colorPicker.click()}return k.tooltip.replace("#FE9200",c.$subtitle.style.color)},mounted:(t,e)=>{const o=i.get("subtitle-color");o&&(e.tooltip=k.tooltip.replace("#FE9200",o))}},{html:"字体类型",name:"subtitle-fontFamily",tooltip:e.get("Default"),selector:[{html:"默认",value:""},{html:"等宽 衬线",value:'"Courier New", Courier, "Nimbus Mono L", "Cutive Mono", monospace'},{html:"比例 衬线",value:'"Times New Roman", Times, Georgia, Cambria, "PT Serif Caption", serif'},{html:"等宽 无衬线",value:'"Deja Vu Sans Mono", "Lucida Console", Monaco, Consolas, "PT Mono", monospace'},{html:"比例 无衬线",value:'Roboto, "Arial Unicode Ms", Arial, Helvetica, Verdana, "PT Sans Caption", sans-serif'},{html:"Casual",value:'"Comic Sans MS", Impact, Handlee, fantasy'},{html:"Cursive",value:'"Monotype Corsiva", "URW Chancery L", "Apple Chancery", "Dancing Script", cursive'},{html:"Small Capitals",value:'"Arial Unicode Ms", Arial, Helvetica, Verdana, "Marcellus SC", sans-serif'}],onSelect:function(t,e,o){return i.set("subtitle-fontFamily",t.html),r.style({fontFamily:t.value}),t.html},mounted:(t,e)=>{const o=i.get("subtitle-fontFamily");o&&(e.tooltip=o)}},{html:"描边样式",name:"subtitle-textShadow",tooltip:e.get("Default"),selector:[{html:"默认",value:"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:"重墨",value:"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:"描边",value:"rgb(0, 0, 0) 0px 0px 1px, rgb(0, 0, 0) 0px 0px 1px, rgb(0, 0, 0) 0px 0px 1px"},{html:"45°投影",value:"rgb(0, 0, 0) 1px 1px 2px, rgb(0, 0, 0) 0px 0px 1px"},{html:"阴影",value:"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:"凸起",value:"rgb(34, 34, 34) 1px 1px"},{html:"下沉",value:"rgb(204, 204, 204) 1px 1px, rgb(34, 34, 34) -1px -1px"},{html:"边框",value:"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 i.set("subtitle-textShadow",t.html),r.style({textShadow:t.value}),t.html},mounted:(t,e)=>{const o=i.get("subtitle-textShadow");o&&(e.tooltip=o)}},{name:"subtitle-load",html:"加载字幕",selector:[{html:"本地文件",name:"file",tooltip:"",node:b(c.$container,'')},{html:"本地文件夹",name:"files",tooltip:"",node:b(c.$container,'')}],onSelect:function(t,e,n){const{userJSON:s,show:i}=a.user;return s().then(({expire_time:e})=>{Math.max(Date.parse(e)-Date.now(),0)?function(t){return t.click(),new Promise((e,o)=>{t.onchange=(t=>{if(t.target.files.length){const o=[...t.target.files].map(t=>{const e=t.name.split(".").pop().toLowerCase();if(["webvtt","vtt","srt","ssa","ass","smi"].includes(e))return D(t).then(o=>({text:o,type:e,name:t.name,html:`本地字幕「${e}」`,source:"local"}))}).filter(Boolean);Promise.all(o).then(t=>{e(t)})}t.target.value=""})})}(t.node).then(t=>{o.sublist=(o.sublist||[]).concat([t]),O(o.sublist)}):i()}),""}}]}),u.update({name:"subtitle",index:31,html:`字幕显示: ${[1,0].map(t=>`${t?"显示":"隐藏"}`).join("")}`,click:(t,e)=>{S(e.target,"art-current");const{value:o}=e.target.dataset;r.show=Boolean(Number(o)),t.show=!1},mounted:e=>{const o=g(`[data-value='${Number(r.show)}']`,e);o&&S(o,"art-current"),t.on("subtitle",t=>{const o=g(`[data-value='${Number(t)}']`,e);o&&S(o,"art-current")})}}),t.isReady?T():t.once("ready",T),{name:"subtitle"}},()=>t=>{const{loadScript:e}=t.constructor.utils,{option:o,template:n,subtitle:s,storage:i,notice:a}=t;function r(){const{url:e,text:i,type:r}=s.option||o.subtitle||{};"ass"===r||"ssa"===r?function(){if(t.libass)return Promise.resolve(t.libass);const e={video:n.$video,subContent:"[Script Info]\nScriptType: v4.00+",subUrl:"",availableFonts:{"思源黑体 cn bold":"https://jsd.nn.ci/gh/tampermonkeyStorage/Self-use@master/Fonts/SourceHanSansCN-Bold.woff2"}};return function(t){if(unsafeWindow.queryLocalFonts){const e={};return t&&(e.postscriptNames=Array.isArray(t)?t:[t]),unsafeWindow.queryLocalFonts(e).then(t=>t&&t.length?t:Promise.reject())}return Promise.reject()}().then(t=>{const o=t.filter(t=>t.fullName.match(/[\u4e00-\u9fa5]/)),n=o.find(t=>["微软雅黑"].some(e=>t.fullName===e)).fullName||o.sort(()=>.5-Math.random())[0].fullName;return l({...e,fallbackFont:n,useLocalFonts:!0})}).catch(t=>l({...e,fallbackFont:Object.keys(e.availableFonts)[0]}))}().then(()=>{i?function(e){t.libass&&(t.libass.freeTrack(),t.libass.setTrack(e))}(i):e&&function(e){t.libass&&(t.libass.freeTrack(),t.libass.setTrackByUrl(e))}(e),u()}).catch(t=>{throw c(),p(),a.show=t,t}):(c(),p())}function l(o){let n="https://unpkg.com/jassub@1.7.18/dist/jassub.umd.js";return e(n).then(()=>(Object.assign(o,{workerUrl:new URL("jassub-worker.js",n).href,wasmUrl:new URL("jassub-worker.wasm",n).href,legacyWorkerUrl:new URL("jassub-worker.wasm.js",n).href,modernWasmUrl:new URL("jassub-worker-modern.wasm",n).href}),function({workerUrl:t}){return fetch(t).then(t=>t.text()).then(t=>{const e=new Blob([t],{type:"text/javascript"}),o=URL.createObjectURL(e);return setTimeout(()=>{URL.revokeObjectURL(o)}),o})}(o).then(e=>{o.workerUrl=e;const n=new unsafeWindow.JASSUB(o);return(n.canvasParent||n._canvasParent).style.cssText="position: absolute;top: 0;left: 0;width: 100%;height: 100%;user-select: none;pointer-events: none;z-index: 20;",t.libass=n,n})))}function c(){t.libass&&t.libass.freeTrack()}function u(){t.libass?(s.style({visibility:"hidden"}),(t.libass.canvasParent||t.libass._canvasParent).style.display="block",t.libass.resize()):s.style({visibility:"visible"})}function p(){s.style({visibility:"visible"}),t.libass&&((t.libass.canvasParent||t.libass._canvasParent).style.display="none")}function d(){t.libass&&(t.libass.destroy&&t.libass.destroy(),t.libass.dispose&&t.libass.dispose(),t.libass=null)}function h(){t.once("user",({expire_time:e})=>{Math.max(Date.parse(e)-Date.now(),0)&&(t.on("subtitleLoad",r),t.on("forceAss",r),t.on("subtitleOffset",e=>{!function(e){t.libass&&(t.libass.timeOffset=e)}(e)}),t.on("subtitle",t=>{t?u():p()}),t.on("restart",c),t.once("destroy",d))})}return t.isReady?h():t.once("ready",h),{name:"libass"}},()=>t=>{const{notice:e,storage:o,plugins:n,setting:s}=t;function i(){t.once("user",({expire_time:e})=>{Math.max(Date.parse(e)-Date.now(),0)&&function(){const e=window.Joysound||unsafeWindow.Joysound;e&&e.isSupport()&&(t.joySound=t.joySound||new e,t.joySound.hasSource()||t.joySound.init(t.template.$video),o.get("joysound")&&t.joySound.setEnabled(!0))}()})}return s.add({html:"声音设置",name:"joysound",tooltip:"",selector:[{html:"音质增强",name:"high",tooltip:"关闭",switch:!1,onSwitch:s=>{const i=s.switch;s.tooltip=i?"关闭":"开启";const{userJSON:a,show:r}=n.user;return a().then(({expire_time:n})=>{Math.max(Date.parse(n)-Date.now(),0)?(o.set("joysound",!i),t.joySound&&t.joySound.setEnabled(!i),e.show=`音质增强: ${i?"关闭":"开启"}`):r()}),!i},mounted:(t,e)=>{o.get("joysound")&&(e.tooltip="增强",e.switch=!0)}},{html:"音量增强",name:"volume",tooltip:"0x",range:[0,0,10,.1],onRange:o=>{const s=o.range[0]/10,{userJSON:i,show:a}=n.user;return i().then(({expire_time:o})=>{Math.max(Date.parse(o)-Date.now(),0)?(t.joySound&&t.joySound.setVolume(s),e.show=`音量增强: ${100+100*s}%`):a()}),`${Math.round(100*o.range[0])/100}x`}}]}),t.playing?i():t.once("video:playing",i),{name:"sound"}},()=>t=>{const{notice:e,storage:o,plugins:n,setting:s,template:{$video:{style:i}}}=t;function a(){t.once("user",({expire_time:t})=>{if(Math.max(Date.parse(t)-Date.now(),0)){const{saturate:t=1,brightness:e=1,contrast:n=1}=o.get("filter")||{};i.filter=`saturate(${t}) brightness(${e}) contrast(${n})`}})}return s.update({html:"色彩滤镜",name:"filter",tooltip:"",selector:[{html:"饱和度",name:"saturate",tooltip:100,range:[100,0,255,1],onRange:t=>{const s=t.range[0],{userJSON:a,show:r}=n.user;return a().then(({expire_time:t})=>{if(Math.max(Date.parse(t)-Date.now(),0)){e.show=`饱和度: ${s}`,o.set("filter",{...o.get("filter"),saturate:s/100});const{saturate:t=1,brightness:n=1,contrast:a=1}=o.get("filter")||{};i.filter=`saturate(${t}) brightness(${n}) contrast(${a})`}else r()}),s},mounted:(t,e)=>{const{saturate:n=1}=o.get("filter")||{};e.$range.value=100*n,e.tooltip=100*n}},{html:"亮度",name:"brightness",tooltip:100,range:[100,0,255,1],onRange:t=>{const s=t.range[0],{userJSON:a,show:r}=n.user;return a().then(({expire_time:t})=>{if(Math.max(Date.parse(t)-Date.now(),0)){e.show=`亮度: ${s}`,o.set("filter",{...o.get("filter"),brightness:s/100});const{saturate:t=1,brightness:n=1,contrast:a=1}=o.get("filter")||{};i.filter=`saturate(${t}) brightness(${n}) contrast(${a})`}else r()}),s},mounted:(t,e)=>{const{brightness:n=1}=o.get("filter")||{};e.$range.value=100*n,e.tooltip=100*n}},{html:"对比度",name:"contrast",tooltip:100,range:[100,0,255,1],onRange:t=>{const s=t.range[0],{userJSON:a,show:r}=n.user;return a().then(({expire_time:t})=>{if(Math.max(Date.parse(t)-Date.now(),0)){e.show=`对比度: ${s}`,o.set("filter",{...o.get("filter"),contrast:s/100});const{saturate:t=1,brightness:n=1,contrast:a=1}=o.get("filter")||{};i.filter=`saturate(${t}) brightness(${n}) contrast(${a})`}else r()}),s},mounted:(t,e)=>{const{contrast:n=1}=o.get("filter")||{};e.$range.value=100*n,e.tooltip=100*n}},{html:"预设「1」",name:"filter-presets",tooltip:""},{html:"默认",name:"filter-default",tooltip:""}],onSelect:(t,e,a)=>{const{userJSON:r,show:l}=n.user;return r().then(({expire_time:e})=>{if(Math.max(Date.parse(e)-Date.now(),0)){const e=s.find("saturate"),n=s.find("brightness"),a=s.find("contrast");"filter-presets"===t.name?(e.tooltip=110,e.$range.value=110,n.tooltip=105,n.$range.value=105,a.tooltip=101,a.$range.value=101,o.set("filter",{saturate:1.1,brightness:1.05,contrast:1.01}),i.filter="saturate(1.1) brightness(1.05) contrast(1.01)"):"filter-default"===t.name&&(e.tooltip=100,e.$range.value=100,n.tooltip=100,n.$range.value=100,a.tooltip=100,a.$range.value=100,o.set("filter",{saturate:1,brightness:1,contrast:1}),i.filter="")}else l()}),t.html}}),t.isReady?a():t.once("ready",a),{name:"imagefilter"}},()=>t=>{const{i18n:e,notice:o,storage:n,plugins:s,setting:i,controls:a,constructor:{utils:{throttle:r}}}=t;function l(){t.once("user",({expire_time:e})=>{Math.max(Date.parse(e)-Date.now(),0)&&(n.get("auto-fullscreen")&&(t.fullscreenWeb=!0),t.startTime=n.get("startTime"),t.endTime=n.get("endTime"),t.on("video:timeupdate",r(()=>{const{currentTime:e,duration:o,startTime:n,endTime:s}=t;if(n||s){const i=[[0,n||0],[s?o-s:0,s?o:0]];for(const[o,n]of i)if(e>=o&&e{if(n.get("auto-next")&&a.hasOwnProperty("playlist")){const t=a.cache.get("playlist").option.selector,e=t[t.findIndex(t=>t.default)+1];e?e.$control_item.click():o.show="没有下一集了"}}))})}return i.update({html:"播放设置",name:"play-setting",tooltip:"",selector:[{html:"自动下一集",name:"auto-next",icon:"",tooltip:"关闭",switch:!1,onSwitch:t=>{const e=t.switch;t.tooltip=e?"关闭":"开启";const{userJSON:i,show:a}=s.user;return i().then(({expire_time:t})=>{Math.max(Date.parse(t)-Date.now(),0)?(n.set("auto-next",!e),o.show=`自动下一集: ${e?"关闭":"开启"}`):a()}),!e},mounted:(t,e)=>{n.get("auto-next")&&(e.tooltip="开启",e.switch=!0)}},{html:"自动全屏",name:"auto-fullscreen",icon:"",tooltip:"关闭",switch:!1,onSwitch:e=>{const i=e.switch;e.tooltip=i?"关闭":"开启";const{userJSON:a,show:r}=s.user;return a().then(({expire_time:e})=>{Math.max(Date.parse(e)-Date.now(),0)?(t.fullscreenWeb=!i,n.set("auto-fullscreen",!i),o.show=`自动全屏: ${i?"关闭":"开启"}`):r()}),!i},mounted:(t,e)=>{n.get("auto-fullscreen")&&(e.tooltip="开启",e.switch=!0)}},{html:"跳过片头",tooltip:"0s",range:[0,0,120,1],onChange(e){const i=e.range[0],{userJSON:a,show:r}=s.user;return a().then(({expire_time:e})=>{Math.max(Date.parse(e)-Date.now(),0)?(t.startTime=i,n.set("startTime",i),o.show=`跳过片头: ${i} 秒`):r()}),i+"s"},mounted:(t,e)=>{const o=n.get("startTime");o&&(e.range=[o,0,120,1],e.tooltip=o+"s")}},{html:"跳过片尾",tooltip:"0s",range:[0,0,120,1],onChange(e){const i=e.range[0],{userJSON:a,show:r}=s.user;return a().then(({expire_time:e})=>{Math.max(Date.parse(e)-Date.now(),0)?(t.endTime=i,n.set("endTime",i),o.show=`跳过片尾: ${i} 秒`):r()}),i+"s"},mounted:(t,e)=>{const o=n.get("endTime");o&&(e.range=[o,0,120,1],e.tooltip=o+"s")}}]}),t.isReady?l():t.once("ready",l),{name:"play"}},()=>t=>{const{option:e,controls:o,template:{$video:n},constructor:{FAST_FORWARD_VALUE:s,utils:{isMobile:i}}}=t;let a=null,r=!1,l=1;const c=e=>{0===e.button&&(a=setTimeout(()=>{r=!0,o.show=!1,l=t.playbackRate,t.playbackRate*=s},1e3))},u=()=>{clearTimeout(a),setTimeout(()=>{r&&(r=!1,o.show=!1,t.playbackRate=l,t.play())})};function p(){t.once("user",({expire_time:o})=>{Math.max(Date.parse(o)-Date.now(),0)&&(i||(n.addEventListener("mousedown",c),document.addEventListener("mouseup",u)),e.hotkey&&!i&&(t.isFocus||(t.isFocus=!0)),t.on("blur",o=>{e.hotkey&&!i&&(t.isFocus=!0)}))})}return t.isReady?p():t.once("ready",p),{name:"hotkey"}}]);
2 |
--------------------------------------------------------------------------------
/alipanThirdParty.js:
--------------------------------------------------------------------------------
1 | window.alipanThirdParty = window.alipanThirdParty || (function () {
2 | (function(pushState) {
3 | history.pushState = function (state, unused, url) {
4 | if (url.indexOf("/membership") > 0) {
5 | location.href = location.protocol + "//" + location.host + "/cpx/member?userCode=MjAxOTcy&disableNav=YES&skuCode=thirdParty&customExtra=byScript001"
6 | }
7 | pushState.apply(this, arguments);
8 | };
9 | })(history.pushState);
10 |
11 | var domain_name = 'https://openapi.alipan.com';
12 | var client_id = '10bb67a9549846038fcbdc348477f59d';
13 | var code_challenge = function (arr) {
14 | var text = "";
15 | for (var i = 0; i < arr.length; i++) {
16 | text += arr[i].toString(32);
17 | }
18 | return text;
19 | }(window.crypto.getRandomValues(new Uint8Array(32)));
20 | var obj = {
21 | version: '1.0.2',
22 | vipInfo: {},
23 | };
24 |
25 | function ajax(url, options = {}) {
26 | Object.assign(options, {
27 | responseType: options.responseType || 'json',
28 | data: options.data instanceof Object ? Object.keys(options.data).map((k) => {
29 | return encodeURIComponent(k) + "=" + encodeURIComponent(options.data[k]).replace("%20", "+");
30 | }).join("&") : options.data
31 | });
32 | return new Promise(function (resolve, reject) {
33 | GM_xmlhttpRequest({
34 | url,
35 | ...options,
36 | onload: function (result) {
37 | if (parseInt(result.status / 100) === 2) {
38 | resolve(result.response);
39 | }
40 | else {
41 | reject(result.response);
42 | }
43 | },
44 | onerror: function (result) {
45 | reject(result.error);
46 | }
47 | });
48 | });
49 | }
50 |
51 | function getItem(n) {
52 | n = localStorage.getItem(n);
53 | if (!n) return null;
54 | try {
55 | return JSON.parse(n);
56 | } catch (e) {
57 | return n;
58 | }
59 | }
60 |
61 | function setItem(n, t) {
62 | n && t != undefined && localStorage.setItem(n, t instanceof Object ? JSON.stringify(t) : t);
63 | }
64 |
65 | function tokenExpires(token) {
66 | token = token || {};
67 | var t = token.expire_time, i = Number(token.expires_in), e = Date.parse(t) - Date.now();
68 | if (0 < e && e < 1e3 * i) return !0;
69 | return !1;
70 | }
71 |
72 | function authorize() {
73 | const { token_type, access_token } = getItem("token");
74 | return ajax("https://open.aliyundrive.com/oauth/users/authorize?client_id=" + client_id + "&redirect_uri=oob&scope=user:base,file:all:read,file:all:write&code_challenge=" + code_challenge + "&code_challenge_method=plain", {
75 | data: JSON.stringify({
76 | authorize: 1,
77 | drives: ["backup", "resource"],
78 | scope: "user:base,file:all:read,file:all:write"
79 | }),
80 | headers: {
81 | "authorization": "".concat(token_type || "", " ").concat(access_token || ""),
82 | "content-type": "application/json;charset=UTF-8"
83 | },
84 | method: "POST"
85 | }).then((response) => {
86 | if (response && response.redirectUri) {
87 | const code = response.redirectUri.split("=")[1];
88 | setItem("openToken", { code, code_verifier: code_challenge });
89 | return code;
90 | }
91 | return Promise.reject();
92 | });
93 | }
94 |
95 | function access_token() {
96 | const { code, code_verifier } = getItem("openToken") || {};
97 | return ajax(domain_name + "/oauth/access_token", {
98 | body: JSON.stringify({
99 | client_id: client_id,
100 | code: code,
101 | code_verifier: code_verifier,
102 | grant_type: "authorization_code"
103 | }),
104 | headers: {
105 | "content-type": "application/json;charset=UTF-8"
106 | },
107 | method: "POST"
108 | }).then((response) => {
109 | setItem("openToken", Object.assign(response, { expire_time: new Date(Date.now() + 1e3 * response.expires_in - 6e5).toISOString() }));
110 | return response;
111 | });
112 | }
113 |
114 | obj.init = function () {
115 | const openToken = getItem("openToken");
116 | if (tokenExpires(openToken)) {
117 | return Promise.resolve();
118 | }
119 | return authorize().then(() => {
120 | return access_token();
121 | });
122 | };
123 |
124 | obj.getUsersInfo = function () {
125 | return obj.init().then(() => {
126 | const { token_type, access_token } = getItem("openToken") || {};
127 | return ajax(domain_name + "/oauth/users/info", {
128 | data: null,
129 | headers: {
130 | "authorization": "".concat(token_type || "", " ").concat(access_token || ""),
131 | "content-type": "application/json;charset=UTF-8"
132 | },
133 | method: "GET"
134 | });
135 | });
136 | };
137 |
138 | obj.getDriveInfo = function () {
139 | return obj.init().then(() => {
140 | const { token_type, access_token } = getItem("openToken") || {};
141 | return ajax(domain_name + "/adrive/v1.0/user/getDriveInfo", {
142 | data: null,
143 | headers: {
144 | "authorization": "".concat(token_type || "", " ").concat(access_token || ""),
145 | "content-type": "application/json;charset=UTF-8"
146 | },
147 | method: "POST"
148 | });
149 | });
150 | };
151 |
152 | obj.getSpaceInfo = function () {
153 | return obj.init().then(() => {
154 | const { token_type, access_token } = getItem("openToken") || {};
155 | return ajax(domain_name + "/adrive/v1.0/user/getSpaceInfo", {
156 | data: null,
157 | headers: {
158 | "authorization": "".concat(token_type || "", " ").concat(access_token || ""),
159 | "content-type": "application/json;charset=UTF-8"
160 | },
161 | method: "POST"
162 | });
163 | });
164 | };
165 |
166 | obj.getVipInfo = function () {
167 | if (Object.keys(obj.vipInfo).length) {
168 | return Promise.resolve(obj.vipInfo);
169 | }
170 | return obj.init().then(() => {
171 | const { token_type, access_token } = getItem("openToken") || {};
172 | return ajax(domain_name + "/business/v1.0/user/getVipInfo", {
173 | data: null,
174 | headers: {
175 | "authorization": "".concat(token_type || "", " ").concat(access_token || ""),
176 | "content-type": "application/json;charset=UTF-8"
177 | },
178 | method: "POST"
179 | }).then((response) => {
180 | Object.assign(obj.vipInfo, response);
181 | return response;
182 | });
183 | });
184 | };
185 |
186 | obj.getUsersScopes = function () {
187 | return obj.init().then(() => {
188 | const { token_type, access_token } = getItem("openToken") || {};
189 | return ajax(domain_name + "/oauth/users/scopes", {
190 | data: null,
191 | headers: {
192 | "authorization": "".concat(token_type || "", " ").concat(access_token || ""),
193 | "content-type": "application/json;charset=UTF-8"
194 | },
195 | method: "GET"
196 | });
197 | });
198 | };
199 |
200 | obj.featureList = function () {
201 | return obj.init().then(() => {
202 | const { token_type, access_token } = getItem("openToken") || {};
203 | return ajax(domain_name + "/business/v1.0/vip/feature/list", {
204 | data: null,
205 | headers: {
206 | "authorization": "".concat(token_type || "", " ").concat(access_token || ""),
207 | "content-type": "application/json;charset=UTF-8"
208 | },
209 | method: "GET"
210 | });
211 | });
212 | };
213 |
214 | obj.featureTrial = function (featureCode) {
215 | return obj.init().then(() => {
216 | const { token_type, access_token } = getItem("openToken") || {};
217 | return ajax(domain_name + "/business/v1.0/vip/feature/trial", {
218 | data: JSON.stringify({
219 | featureCode: featureCode || "hd.1080p|hd.1080p.plus"
220 | }),
221 | headers: {
222 | "authorization": "".concat(token_type || "", " ").concat(access_token || ""),
223 | "content-type": "application/json;charset=UTF-8"
224 | },
225 | method: "POST"
226 | });
227 | });
228 | };
229 |
230 | obj.getVideoPreviewPlayInfo = function (drive_id, file_id) {
231 | return obj.init().then(() => {
232 | const { token_type, access_token } = getItem("openToken") || {};
233 | return ajax(domain_name + "/adrive/v1.0/openFile/getVideoPreviewPlayInfo", {
234 | data: JSON.stringify({
235 | drive_id: drive_id,
236 | file_id: file_id,
237 | category: "live_transcoding",
238 | template_id: "",
239 | get_subtitle_info: !0,
240 | url_expire_sec: 14400,
241 | with_play_cursor: !0
242 | }),
243 | headers: {
244 | "authorization": "".concat(token_type || "", " ").concat(access_token || ""),
245 | "content-type": "application/json;charset=UTF-8"
246 | },
247 | method: "POST"
248 | });
249 | });
250 | };
251 |
252 | obj.delete = function (drive_id, file_id) {
253 | return obj.init().then(() => {
254 | const { token_type, access_token } = getItem("openToken") || {};
255 | return ajax(domain_name + "/adrive/v1.0/openFile/delete", {
256 | data: JSON.stringify({
257 | drive_id: drive_id,
258 | file_id: file_id
259 | }),
260 | headers: {
261 | "authorization": "".concat(token_type || "", " ").concat(access_token || ""),
262 | "content-type": "application/json;charset=UTF-8"
263 | },
264 | method: "POST"
265 | });
266 | });
267 | };
268 |
269 | obj.delay = function (ms = 500) {
270 | return new Promise(resolve => setTimeout(resolve, ms));
271 | };
272 |
273 | return (obj.getVipInfo(), obj);
274 | })();
275 |
--------------------------------------------------------------------------------
/appreciation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tampermonkeyStorage/Self-use/21a11fdb1a9dbc59fd3017e0e5f733def2e16a9d/appreciation.png
--------------------------------------------------------------------------------
/天翼云盘-下载不求人.user.js:
--------------------------------------------------------------------------------
1 | // ==UserScript==
2 | // @name 天翼云盘-下载不求人
3 | // @namespace http://tampermonkey.net/
4 | // @version 0.8.1
5 | // @description 让下载成为一件愉快的事情
6 | // @author You
7 | // @match https://cloud.189.cn/web/*
8 | // @connect 189.cn
9 | // @icon https://cloud.189.cn/web/logo.ico
10 | // @require https://code.jquery.com/jquery-3.6.0.min.js
11 | // @require https://cdn.staticfile.org/blueimp-md5/2.19.0/js/md5.min.js
12 | // @grant GM_xmlhttpRequest
13 | // @grant GM_setClipboard
14 | // ==/UserScript==
15 |
16 | (function() {
17 | 'use strict';
18 | var $ = $ || window.$;
19 | var obj = {};
20 |
21 | obj.showTipSuccess = function (text, time) {
22 | obj.showNotify({
23 | type: "success",
24 | text: text
25 | });
26 | };
27 |
28 | obj.showTipError = function (text, time) {
29 | obj.showNotify({
30 | type: "error",
31 | text: text
32 | });
33 | };
34 |
35 | obj.showTipLoading = function (text, time) {
36 | obj.showNotify({
37 | type: "loading",
38 | text: text
39 | });
40 | };
41 |
42 | obj.showNotify = function (opts) {
43 | var $Vue = (document.querySelector(".content") || document.querySelector(".p-web")).__vue__;
44 | if (opts.type == "loading") {
45 | $Vue.$loading.show(opts);
46 | }
47 | else {
48 | $Vue.$toast.show(opts);
49 | }
50 | };
51 |
52 | obj.hideNotify = function() {
53 | var $Vue = (document.querySelector(".content") || document.querySelector(".p-web")).__vue__;
54 | $Vue.$toast.hide();
55 | $Vue.$loading.hide();
56 | };
57 |
58 | obj.getFinalUrl = function (url) {
59 | return new Promise(function (resolve) {
60 | const xhr = GM_xmlhttpRequest({
61 | url: url,
62 | method: "get",
63 | onreadystatechange: function(response) {
64 | if (response.readyState === 4 || response.finalUrl !== url) {
65 | xhr.abort();
66 | if (!xhr.mark) {
67 | xhr.mark = true;
68 | resolve(response.finalUrl);
69 | }
70 | }
71 | },
72 | onerror: function (error) {
73 | resolve("");
74 | }
75 | });
76 | });
77 | };
78 |
79 | obj.getAccessToken = function () {
80 | var accessToken = localStorage.getItem("accessToken");
81 | if (accessToken) return Promise.resolve(accessToken);
82 | return obj.getFinalUrl("https://api.cloud.189.cn/open/oauth2/ssoH5.action").then(function (location) {
83 | if (location) {
84 | var accessToken = (/accessToken=(.+)/.exec(location) || [])[1];
85 | accessToken && localStorage.setItem("accessToken", accessToken);
86 | return accessToken;
87 | }
88 | else {
89 | return "";
90 | }
91 | });
92 | };
93 |
94 | obj.getSignature = function (e) {
95 | for (var t = 1; t < arguments.length; t++) {
96 | var n = arguments[t];
97 | for (var r in n) {
98 | Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r])
99 | }
100 | }
101 | var i = []
102 | for (var s in e){
103 | i.push(s + "=" + e[s]);
104 | }
105 | i.sort(function(e, t) {
106 | return e > t ? 1 : e < t ? -1 : 0
107 | })
108 | e = i.join("&");
109 | return window.md5(e);
110 | };
111 |
112 | obj.getFileDownloadUrl = function (fileId, shareId) {
113 | var accessToken = localStorage.getItem("accessToken").replace(/[\"\\]/g, "")
114 | , timestamp = Date.now()
115 | , data = Object.assign({
116 | AccessToken: accessToken,
117 | Timestamp: timestamp,
118 | fileId: fileId
119 | }, shareId ? {dt: 1, shareId: shareId} : {})
120 | , signature = obj.getSignature(data);
121 |
122 | return new Promise(function (resolve) {
123 | $.ajax({
124 | url: "https://api.cloud.189.cn/open/file/getFileDownloadUrl.action?fileId=" + fileId + (shareId ? "&dt=1&shareId=" + shareId : ""),
125 | headers: {
126 | Accept: "application/json;charset=UTF-8",
127 | AccessToken: accessToken,
128 | Signature: signature,
129 | "Sign-Type": 1,
130 | Timestamp: timestamp
131 | },
132 | async: true,
133 | success: function (t) {
134 | if (0 === t.res_code) {
135 | resolve(t.fileDownloadUrl);
136 | }
137 | else if ("InfoSecurityErrorCode" === t.res_code) {
138 | obj.showTipError("文件内容违规,下载失败");
139 | resolve("");
140 | }
141 | else {
142 | obj.showTipError("下载失败,网络错误,刷新重试");
143 | resolve("");
144 | }
145 | },
146 | error: function () {
147 | obj.showTipError("网络错误,刷新重试");
148 | localStorage.removeItem("accessToken");
149 | resolve("");
150 | }
151 | });
152 | });
153 | };
154 |
155 | obj.getDownloadUrl = function (fileId, shareId) {
156 | if (localStorage.getItem("accessToken")) {
157 | return obj.getFileDownloadUrl(fileId, shareId);
158 | }
159 | else {
160 | return Promise.resolve("");
161 | }
162 | };
163 |
164 | obj.getSelectedFileList = function () {
165 | var $Vue;
166 | if (document.querySelector(".c-file-list")) {
167 | $Vue = document.querySelector(".c-file-list").__vue__;
168 | if ($Vue.selectLength > 0) {
169 | return $Vue.selectedList;
170 | }
171 | else {
172 | return $Vue.fileList;
173 | }
174 | }
175 | else if (document.querySelector(".info-detail")) {
176 | $Vue = document.querySelector(".info-detail").__vue__;
177 | if (Object.keys($Vue.fileDetail).length) {
178 | return [$Vue.fileDetail];
179 | }
180 | else {
181 | return [];
182 | }
183 | }
184 | else {
185 | return [];
186 | }
187 | };
188 |
189 | obj.showBox = function (body) {
190 | var html = '';
191 | $(".Directory_c-directory-list_wNNms").parent().append(html);
192 | $(".show-link-list").find(".close").on("click", function () {
193 | $(".show-link-list").remove();
194 | });
195 | $(".show-link-list .Directory_button-group_23dIK:eq(0) button:eq(0)").on("click", function () {
196 | window.open("https://pc-index-skin.cdn.bcebos.com/6cb0bccb31e49dc0dba6336167be0a18.png", "_blank");
197 | });
198 | $(".show-link-list .Directory_button-group_23dIK:eq(0) button:eq(1)").on("click", function () {
199 | var urls = [];
200 | $(".show-link-list a").each(function (index, value) {
201 | urls.push(this.href);
202 | });
203 | if (urls.length) {
204 | GM_setClipboard(urls.join("\r\n"));
205 | obj.showTipSuccess(urls.length + " 条链接已复制");
206 | }
207 | });
208 | };
209 |
210 | obj.showDownload = function () {
211 | var $Vue = document.querySelector(".main-box").__vue__;
212 | var accessToken = localStorage.getItem("accessToken");
213 | if (!$Vue.isLogin && !accessToken) {
214 | return obj.showTipError("无法显示链接,请登录后重试");
215 | }
216 |
217 | var fileList = obj.getSelectedFileList();
218 | if (fileList.length == 0) {
219 | return obj.showTipError("getSelectedFileList 获取选中文件出错");
220 | }
221 |
222 | obj.showTipLoading("正在获取链接...");
223 | var html = '';
224 | var rowStyle = "margin:10px 0px; overflow:hidden; white-space:nowrap; text-overflow:ellipsis;";
225 |
226 | var retCount = 0;
227 | fileList.forEach(function (item, index) {
228 | if (item.isFolder) {
229 | html += '
' + (++index) + ':' + (item.fileName ? item.fileName : item.fileId) + ' || 请进入文件夹下载
';
230 | html += '
';
231 | retCount++;
232 | }
233 | else {
234 | if (item.downloadUrl) {
235 | html += '
' + (++index) + ':' + (item.fileName ? item.fileName : item.fileId) + '
';
236 | html += '
' + item.downloadUrl + '
';
237 | retCount++;
238 | }
239 | else {
240 | obj.getDownloadUrl(item.fileId, item.shareId).then(function (downloadUrl) {
241 | item.downloadUrl = downloadUrl;
242 | html += '
' + (++index) + ':' + (item.fileName ? item.fileName : item.fileId) + '
';
243 | html += '
' + item.downloadUrl + '
';
244 | retCount++;
245 | });
246 | }
247 | }
248 | });
249 | var waitId = setInterval(function(){
250 | if (retCount == fileList.length){
251 | html += '
';
252 | obj.showBox(html);
253 | obj.hideNotify();
254 | clearInterval(waitId);
255 | }
256 | }, 200);
257 | };
258 |
259 | obj.initDownloadPage = function () {
260 | if ($(".btn-show-link").length) {
261 | return;
262 | }
263 | if ($(".file-operate").length) {
264 | var node = document.querySelector(".file-operate a"), attrName = node ? node.getAttributeNames()[0] : "";
265 | $(".file-operate").append('显示链接');
266 | $(".btn").css({"margin-left": "5px", "margin-right": "5px"});
267 | $(".tips-save-box").css("display", "none");
268 | $(".btn-show-link").on("click", obj.showDownload);
269 | }
270 | else if ($(".FileHead_file-head-left_3AuQ6").length) {
271 | $(".FileHead_file-head-left_3AuQ6").append('显示链接
');
272 | $(".btn-show-link").on("click", obj.showDownload);
273 | }
274 | };
275 |
276 | obj.initPageFileInfo = function () {
277 | var open = XMLHttpRequest.prototype.open;
278 | XMLHttpRequest.prototype.open = function() {
279 | this.addEventListener("load", function() {
280 | if (this.readyState == 4 && this.status == 200) {
281 | var responseURL = this.responseURL;
282 | if (responseURL.indexOf("/listShareDir.action") > 0 || responseURL.indexOf("/listFiles.action") > 0) {
283 | var response = this.response;
284 | try { response = JSON.parse(response) } catch (error) { };
285 | if (response && response.res_code == 0 && response.fileListAO) {
286 | obj.initDownloadPage();
287 | obj.showTipSuccess("文件加载完成 共:" + (response.fileListAO.count || (response.fileListAO.fileList || []).length) + "项");
288 | obj.getAccessToken().then(function (accessToken) {
289 | if (!accessToken && GM_info.scriptHandler === "Violentmonkey") obj.showTipError("无法适配暴力猴,请更换脚本管理器"); //v2.13.1
290 | });
291 | }
292 | }
293 | }
294 | }, false);
295 | open.apply(this, arguments);
296 | };
297 | }();
298 |
299 | console.info("=== 天翼云盘 好棒棒!===");
300 |
301 | // Your code here...
302 | })();
303 |
--------------------------------------------------------------------------------
/天翼云盘音乐播放器.user.js:
--------------------------------------------------------------------------------
1 | // ==UserScript==
2 | // @name 天翼云盘音乐播放器
3 | // @namespace https://bbs.tampermonkey.net.cn/
4 | // @version 0.1.0
5 | // @description 一曲肝肠断,天涯何处觅知音
6 | // @author You
7 | // @match https://cloud.189.cn/web/*
8 | // @connect kugou.com
9 | // @icon https://cloud.189.cn/web/logo.ico
10 | // @require https://scriptcat.org/lib/513/2.0.0/ElementGetter.js
11 | // @run-at document-body
12 | // @grant unsafeWindow
13 | // @grant GM_xmlhttpRequest
14 | // ==/UserScript==
15 |
16 | (function() {
17 | 'use strict';
18 |
19 | var obj = {
20 | audio_page: {
21 | fileList: [],
22 | fileIndex: -1,
23 | format: [
24 | ".mp3", ".wma", ".wav", ".midi", ".flac",
25 | ".ram", ".ra", ".mid", ".aac", ".m4a",
26 | /*".ape",*/ ".au", ".ogg", ".aif", ".aiff",
27 | ".snd", ".voc", ".mpa", ".lrc", ".cda",
28 | ".vqf", ".wvx", ".wmx", ".ttbl", ".ttpl", ".tta", ".tak", ".mpc"
29 | ]
30 | }
31 | };
32 |
33 | obj.playAudioSharePage = function () {
34 | obj.insertPrettyPlayerSharePage();
35 | obj.selectedFilePlayerSharePage();
36 | };
37 |
38 | obj.playAudioHomePage = function () {
39 | obj.insertPrettyPlayerHomePage();
40 | obj.replaceNativePlayerHomePage();
41 | };
42 |
43 | obj.insertPrettyPlayerSharePage = function () {
44 | obj.addedNodeReady(".file", function (elm) {
45 | Object.defineProperty(elm, "__vue__", {
46 | set(vue) {
47 | vue && Array.isArray(vue.fileList) && obj.togglePlayBtn(vue.fileList);
48 | }
49 | });
50 | });
51 | };
52 |
53 | obj.selectedFilePlayerSharePage = function () {
54 | obj.addedNodeReady(".file ul", function (elm) {
55 | elm.addEventListener("click", function (event) {
56 | if (event.target.className.includes("file-item-name-fileName-span")) {
57 | var fileItem = event.target.offsetParent?.__vue__?.fileItem || {};
58 | if (fileItem.mediaType == 2 && obj.audio_page.format.includes("." + fileItem.fileType)) {
59 | obj.audio_page.fileIndex = obj.audio_page.fileList.findIndex(function (item, index) {
60 | return item.fileId == fileItem.fileId;
61 | });
62 | if (window.player) {
63 | const { list, list: { audios, index } } = window.player;
64 | if (audios[index].fileId != fileItem.fileId) {
65 | list.switch(obj.audio_page.fileIndex);
66 | }
67 | }
68 | else {
69 | obj.useAPlayer();
70 | }
71 | }
72 | }
73 | }, true);
74 | });
75 | };
76 |
77 | obj.insertPrettyPlayerHomePage = function () {
78 | obj.addedNodeReady(".p-web section", function (elm) {
79 | Object.defineProperty(elm, "__vue__", {
80 | set(vue) {
81 | vue && Array.isArray(vue.fileList) && obj.togglePlayBtn(vue.fileList);
82 | }
83 | });
84 | });
85 | };
86 |
87 | obj.replaceNativePlayerHomePage = function () {
88 | obj.addedNodeReady(".p-web-audioplayer", function (elm) {
89 | Object.defineProperty(elm, "__vue__", {
90 | set(vue) {
91 | if (vue && vue.isShowPlayer) {
92 | const { closeAudio, currentPlayItem, player: { node } } = vue;
93 | node.setSrc("");
94 | closeAudio();
95 | obj.audio_page.fileIndex = (obj.audio_page.fileList || []).findIndex(function (item, index) {
96 | return item.fileId == currentPlayItem.fileId;
97 | });
98 | obj.useAPlayer();
99 | }
100 | }
101 | });
102 | });
103 | };
104 |
105 | obj.togglePlayBtn = function (fileList) {
106 | var playbtn = obj.query(".advertising .audio-play-btn");
107 | (obj.audio_page.fileList = fileList.filter(function (item, index) {
108 | return item.mediaType == 2 && obj.audio_page.format.includes("." + item.fileType);
109 | })).length ? playbtn || (obj.append(obj.query(".advertising"), ' 音乐播放 ').onclick = obj.useAPlayer) : playbtn && obj.remove(playbtn);
110 | };
111 |
112 | obj.useAPlayer = function () {
113 | obj.aplayerSupport(function (result) {
114 | result && obj.aplayerStart();
115 | });
116 | };
117 |
118 | obj.aplayerSupport = function (callback) {
119 | (function laodcdn(urlArr, index = 0) {
120 | var arr = urlArr[index];
121 | if (arr) {
122 | var promises = [];
123 | arr.forEach(function (url, index) {
124 | var ext = url.split(".").pop();
125 | if (ext === "js") {
126 | promises.push(obj.loadScript(url));
127 | }
128 | else if (ext === "css") {
129 | promises.push(obj.loadStyle(url));
130 | }
131 | });
132 | Promise.all(promises).then(function (results) {
133 | setTimeout(function () {
134 | callback && callback(unsafeWindow.APlayer);
135 | });
136 | }).catch(function (error) {
137 | laodcdn(urlArr, ++index);
138 | });
139 | }
140 | else {
141 | callback && callback(unsafeWindow.APlayer);
142 | }
143 | })([
144 | [
145 | "https://cdnjs.cloudflare.com/ajax/libs/aplayer/1.10.1/APlayer.min.js",
146 | "https://cdnjs.cloudflare.com/ajax/libs/aplayer/1.10.1/APlayer.min.css"
147 | ],
148 | [
149 | "https://unpkg.com/aplayer/dist/APlayer.min.js",
150 | "https://unpkg.com/aplayer/dist/APlayer.min.css"
151 | ],
152 | [
153 | "https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js",
154 | "https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css"
155 | ]
156 | ]);
157 | };
158 |
159 | obj.aplayerStart = function () {
160 | var aplayerNode, audio = obj.audio_page.fileList;
161 | audio.forEach(function (item) {
162 | Object.assign(item, {
163 | name: item.fileName,
164 | url: item.downloadUrl || item.url,
165 | cover: item.icon.smallUrl,
166 | theme: obj.getRandomColor(),
167 | type: "custom"
168 | });
169 | });
170 | if (audio.length) {
171 | aplayerNode = document.getElementById("aplayer");
172 | if (aplayerNode) {
173 | window.player && window.player.destroy();
174 | }
175 | else {
176 | aplayerNode = document.createElement("div");
177 | aplayerNode.setAttribute("id", "aplayer");
178 | aplayerNode.setAttribute("style", "background-color: #fafdff;position: fixed;z-index: 9999;width: 440px;bottom: 0;left: 0px;box-shadow: 0 0 10px #ccc;border-top-left-radius: 4px;border-top-right-radius: 4px;border: 1px solid #dedede;");
179 | document.body.appendChild(aplayerNode);
180 | }
181 | }
182 | else {
183 | return ;
184 | }
185 | try{
186 | var player = window.player = new unsafeWindow.APlayer({
187 | container: aplayerNode,
188 | audio: audio,
189 | customAudioType: {
190 | custom: function (audioElement, audio, player) {
191 | if (audioElement instanceof Element) {
192 | if (audio.url) {
193 | audioElement.src = audio.url;
194 | }
195 | else {
196 | obj.getMusicUrl(audio.fileId, audio.shareId).then(function (url) {
197 | try{
198 | audioElement.src = audio.url = url;
199 | } catch (error) { }
200 | });
201 | }
202 | audioElement.oncanplay = function () {
203 | player.play();
204 | };
205 | audioElement.onerror = function () {
206 | if (player.prevErrorAudio && player.prevErrorAudio.fileId == audio.fileId) {
207 | player.notice(audio.fileName + " == 无法播放");
208 | const { list } = player;
209 | list.remove(list.index);
210 | obj.audio_page.fileList.splice(list.index, 1);
211 | }
212 | else {
213 | obj.getMusicUrl(audio.fileId, audio.shareId).then(function (url) {
214 | audioElement.src = audio.url = url;
215 | const { list } = player;
216 | list.switch(list.index);
217 | player.prevErrorAudio = audio;
218 | });
219 | }
220 | };
221 | }
222 | }
223 | },
224 | autoplay: true,
225 | order: "random",
226 | lrcType: 1,
227 | mutex: true
228 | });
229 | let image = [
230 | "https://wimg.588ku.com/gif620/21/08/19/98bc65b53f8b7f91e3fb091bd413ee87.gif",
231 | "https://wimg.588ku.com/gif620/19/08/22/e385a29ad529368de8cf650a18a195c6.gif",
232 | "https://wimg.588ku.com/gif620/21/03/05/d97bb525bf33390227171ad8fa374002.gif",
233 | "https://wimg.588ku.com/gif620/21/08/19/c42708c1bd3f26ddb7466dddf9492f77.gif",
234 | "https://wimg.588ku.com/gif620/20/07/22/a6b3fb60fff01b6fe3d6dd44aba08765.gif"
235 | ];
236 | player.on("listswitch", function ({ index }) {
237 | if (player.audio.oncanplay) {
238 | obj.querySongInfo(player, index);
239 | player.template.list.style.cssText += "background: url(" + image[Math.floor(Math.random() * image.length)] + ") center center / contain no-repeat;";
240 | }
241 | });
242 | player.on("destroy", function () {
243 | player.audio.oncanplay = null;
244 | player.audio.onerror = null;
245 | window.player.list.clear();
246 | window.player = null;
247 | });
248 | const { list, template: { time, body } } = player;
249 | const fileIndex = obj.audio_page.fileIndex;
250 | if (fileIndex > -1 && list.audios.length > 1 && list.index !== fileIndex) {
251 | setTimeout(() => { list.switch(fileIndex); }, 500);
252 | }
253 | else {
254 | obj.querySongInfo(player);
255 | player.template.list.style.cssText += "background: url(" + image[Math.floor(Math.random() * image.length)] + ") center center / contain no-repeat;";
256 | }
257 | [...time.children].forEach(element => {
258 | element.style.cssText += "display: inline-block;";
259 | });
260 | obj.append(body, '').onclick = () => player.destroy();
261 | obj.append(body, '
');
262 | } catch (error) {
263 | console.error("播放器创建失败", error);
264 | }
265 | };
266 |
267 | obj.getMusicUrl = function (fileId, shareId) {
268 | return obj.getFileDownloadUrl(fileId, shareId).then(function (fileDownloadUrl) {
269 | return fileDownloadUrl;
270 | }, function () {
271 | return obj.getNewMusicUrl(fileId, shareId);
272 | });
273 | };
274 |
275 | obj.getFileDownloadUrl = function (fileId, shareId) {
276 | return unsafeWindow.axios({
277 | url: "https://cloud.189.cn/api/open/file/getFileDownloadUrl.action?fileId=" + fileId + (shareId ? "&dt=1&shareId=" + shareId : ""),
278 | headers: {
279 | Accept: "application/json;charset=UTF-8"
280 | }
281 | }).then(function ({ data }) {
282 | return data.fileDownloadUrl;
283 | });
284 | };
285 |
286 | obj.getNewMusicUrl = function (fileId) {
287 | return unsafeWindow.axios({
288 | url: "https://cloud.189.cn/api/open/file/getNewMusicUrl.action?noCache=" + Math.random() + "&fileId=" + fileId + "&short=true&forcedGet=0",
289 | headers: {
290 | Accept: "application/json;charset=UTF-8"
291 | }
292 | }).then(function ({ data }) {
293 | return data.fileDownloadUrl;
294 | });
295 | };
296 |
297 | obj.querySongInfo = function (player, index) {
298 | const { list, lrc, template: { pic, author } } = player;
299 | index || index === 0 || (index = list.index);
300 | if (lrc.parsed[index] && lrc.parsed[index].length > 1) return;
301 | const { fileName, md5, size } = list.audios[index] || {};
302 | obj.songinfoKugou(fileName, md5, size).then(function (result) { // 酷狗好棒棒,听歌来帮忙
303 | const { candidates, info, author_name, img } = result;
304 | const candidate = Array.isArray(candidates) ? candidates.find(function (item) {
305 | return item.lyrics;
306 | }) : Array.isArray(info) ? info.find(function (item) {
307 | return item.lyrics;
308 | }) : "";
309 | if (candidate && candidate.lyrics) {
310 | lrc.parsed[index] = lrc.current = lrc.parse(candidate.lyrics);
311 | lrc.container.innerHTML = lrc.parsed[index].map((item) => `${item[1]}
`).join("\n");
312 | lrc.container.getElementsByTagName("p").length && lrc.container.getElementsByTagName("p")[0].classList.add("aplayer-lrc-current");
313 | }
314 | obj.getdataKugou(candidate.hash || md5).then(function (data) {
315 | const { author_name, img } = data;
316 | if (author_name) {
317 | author.innerText = "- " + (list.audios[index].artist = author_name);
318 | }
319 | if (img) {
320 | pic.style.cssText += "background-image: url(" + (list.audios[index].cover = img) + ")";
321 | }
322 | }).catch(function () { });
323 | }).catch(function (error) { });
324 | };
325 |
326 | obj.songinfoKugou = function (name, hash, size) {
327 | return obj.songinfohashKugou(name, hash, size).then(function (result) {
328 | return result;
329 | }, function () {
330 | return obj.songinfonameKugou(name, hash, size);
331 | });
332 | };
333 |
334 | obj.songinfohashKugou = function (name, hash, size) {
335 | return obj.searchhashKugou(name, hash, size).then(function (result) {
336 | var promises = [];
337 | result.candidates.slice(0, 3).forEach(function (item, index) {
338 | promises.push(obj.downloadhashKugou(item.id, item.accesskey));
339 | });
340 | return Promise.allSettled(promises).then(function (results) {
341 | results.forEach(function (item, index) {
342 | if (item.status == "fulfilled") {
343 | var words = window.CryptoJS.enc.Base64.parse(item.value.content);
344 | result.candidates[index].lyrics = window.CryptoJS.enc.Utf8.stringify(words);
345 | }
346 | });
347 | return result;
348 | });
349 | });
350 | };
351 |
352 | obj.searchhashKugou = function (name, hash, size) {
353 | return new Promise(function (resolve, reject) {
354 | obj.ajax({
355 | url: "https://lyrics.kugou.com/search?ver=1&man=yes&client=pc&keyword=&duration=&hash=" + hash,
356 | headers: {
357 | origin: "https://www.kugou.com",
358 | referer: "https://www.kugou.com/"
359 | },
360 | success: function (result) {
361 | if (result && result.status == 200 && result.proposal !== "0") {
362 | resolve(result);
363 | }
364 | else {
365 | reject(result);
366 | }
367 | },
368 | error: function (error) {
369 | reject(error);
370 | }
371 | });
372 | });
373 | };
374 |
375 | obj.downloadhashKugou = function (id, accesskey) {
376 | return new Promise(function (resolve, reject) {
377 | obj.ajax({
378 | url: "https://lyrics.kugou.com/download?ver=1&client=pc&id=" + id + "&accesskey=" + accesskey + "&fmt=lrc&charset=utf8",
379 | headers: {
380 | origin: "https://www.kugou.com",
381 | referer: "https://www.kugou.com/"
382 | },
383 | success: function (result) {
384 | resolve(result);
385 | },
386 | error: function (error) {
387 | reject(error);
388 | }
389 | });
390 | });
391 | };
392 |
393 | obj.songinfonameKugou = function (name, hash, size) {
394 | return obj.searchnameKugou(name, hash, size).then(function (result) {
395 | var promises = [];
396 | result.info.slice(0, 3).forEach(function (item, index) {
397 | promises.push(obj.krcKugou(item.hash));
398 | });
399 | return Promise.allSettled(promises).then(function (results) {
400 | results.forEach(function (item, index) {
401 | if (item.status == "fulfilled") {
402 | result.info[index].lyrics = item.value;
403 | }
404 | });
405 | return result;
406 | });
407 | });
408 | };
409 |
410 | obj.searchnameKugou = function (name, hash, size) {
411 | return new Promise(function (resolve, reject) {
412 | obj.ajax({
413 | url: "https://mobilecdn.kugou.com/api/v3/search/song?pagesize=20&keyword=" + name,
414 | headers: {
415 | origin: "https://www.kugou.com",
416 | referer: "https://www.kugou.com/"
417 | },
418 | success: function (result) {
419 | if (result && result.status == 1 && result.data.total) {
420 | resolve(result.data);
421 | }
422 | else {
423 | reject(result);
424 | }
425 | },
426 | error: function (error) {
427 | reject(error);
428 | }
429 | });
430 | });
431 | };
432 |
433 | obj.krcKugou = function (hash) {
434 | return obj.surlRequest("https://m.kugou.com/app/i/krc.php?cmd=100&timelength=999999&hash=" + hash);
435 | };
436 |
437 | obj.getdataKugou = function (hash) {
438 | return new Promise(function (resolve, reject) {
439 | obj.ajax({
440 | url: "https://www.kugou.com/yy/index.php?r=play/getdata&hash=" + hash,
441 | headers: {
442 | origin: "https://www.kugou.com",
443 | referer: "https://www.kugou.com/"
444 | },
445 | success: function (result) {
446 | if (result && result.status == 1) {
447 | resolve(result.data);
448 | }
449 | else {
450 | reject(result);
451 | }
452 | },
453 | error: function (error) {
454 | reject(error);
455 | }
456 | });
457 | });
458 | };
459 |
460 | obj.surlRequest = function (url) {
461 | return new Promise(function (resolve, reject) {
462 | obj.ajax({
463 | url : url,
464 | dataType: "blob",
465 | success: function (blob) {
466 | var reader = new FileReader();
467 | reader.readAsText(blob, "UTF-8");
468 | reader.onload = function (e) {
469 | resolve(reader.result);
470 | };
471 | reader.onerror = function (e) {
472 | reject(e);
473 | };
474 | },
475 | error: function (error) {
476 | reject(error);
477 | }
478 | });
479 | });
480 | };
481 |
482 | obj.ajax = function (option) {
483 | var details = {
484 | method: option.type || "get",
485 | url: option.url,
486 | responseType: option.dataType || "json",
487 | onload: function (result) {
488 | var response = result.response || result.responseText;
489 | if (parseInt(result.status / 100) == 2) {
490 | option.success && option.success(response);
491 | }
492 | else {
493 | option.error && option.error(response);
494 | }
495 | },
496 | onerror: function (result) {
497 | option.error && option.error(result.error);
498 | }
499 | };
500 | if (option.data) {
501 | if (option.data instanceof Object) {
502 | details.data = Object.keys(option.data).map(function (k) {
503 | return encodeURIComponent(k) + "=" + encodeURIComponent(option.data[k]).replace("%20", "+");
504 | }).join("&");
505 | }
506 | else {
507 | details.data = option.data;
508 | }
509 | if (option.type.toUpperCase() == "GET") {
510 | details.url = option.url + (option.url.includes("?") ? "&" : "?") + details.data;
511 | delete details.data;
512 | }
513 | }
514 | if (option.headers) {
515 | details.headers = option.headers;
516 | }
517 | GM_xmlhttpRequest(details);
518 | };
519 |
520 | obj.loadScript = function (src) {
521 | if (!window.instances) {
522 | window.instances = {};
523 | }
524 | if (!window.instances[src]) {
525 | window.instances[src] = new Promise((resolve, reject) => {
526 | const script = document.createElement("script")
527 | script.src = src;
528 | script.type = "text/javascript";
529 | script.onload = resolve;
530 | script.onerror = reject;
531 | Node.prototype.appendChild.call(document.head, script);
532 | });
533 | }
534 | return window.instances[src];
535 | };
536 |
537 | obj.loadStyle = function (href) {
538 | if (!window.instances) {
539 | window.instances = {};
540 | }
541 | if (!window.instances[href]) {
542 | window.instances[href] = new Promise((resolve, reject) => {
543 | const style = document.createElement("link");
544 | style.type = "text/css";
545 | style.rel = "stylesheet";
546 | style.href = href;
547 | style.onload = resolve;
548 | style.onerror = reject;
549 | Node.prototype.appendChild.call(document.head, style);
550 | });
551 | }
552 | return window.instances[href];
553 | };
554 |
555 | obj.getRandomColor = function () {
556 | return "#" + ("00000" + (Math.random() * 0x1000000 << 0).toString(16)).substr(-6);
557 | };
558 |
559 | obj.addedNodeReady = function (selector, callback) {
560 | const element = obj.query(selector);
561 | if (element) {
562 | callback && callback(element);
563 | }
564 | else {
565 | const observer = new MutationObserver(function (mutationsList, observer) {
566 | for (const mutation of mutationsList) {
567 | if (mutation.addedNodes.length) {
568 | for (const node of mutation.addedNodes) {
569 | if (node instanceof Element) {
570 | const targetNode = obj.query(selector, node.parentElement || node.parentNode || document);
571 | if (targetNode) {
572 | observer.disconnect();
573 | callback(targetNode);
574 | break;
575 | }
576 | continue;
577 | }
578 | }
579 | }
580 | else {
581 | continue;
582 | }
583 | }
584 | });
585 | observer.observe(document, { childList: true, subtree: true });
586 | }
587 | };
588 |
589 | obj.query = function (selector, parent = document) {
590 | return parent.querySelector(selector);
591 | };
592 |
593 | obj.append = function (parent, child) {
594 | if (child instanceof Element) {
595 | Node.prototype.appendChild.call(parent, child);
596 | }
597 | else {
598 | parent.insertAdjacentHTML("beforeend", String(child));
599 | }
600 | return parent.lastElementChild || parent.lastChild;
601 | };
602 |
603 | obj.prepend = function (parent, child) {
604 | if (child instanceof Element) {
605 | Node.prototype.appendChild.call(parent, child);
606 | }
607 | else {
608 | parent.insertAdjacentHTML("afterbegin", String(child));
609 | }
610 | return parent.firstElementChild || parent.firstChild;
611 | };
612 |
613 | obj.remove = function (child) {
614 | return Node.prototype.removeChild.call(child?.parentNode || document, child);
615 | };
616 |
617 | obj.run = function () {
618 | var url = location.href;
619 | if (url.indexOf("cloud.189.cn/web/share") > 0) {
620 | obj.playAudioSharePage();
621 | }
622 | else if (url.indexOf("cloud.189.cn/web/main/file") > 0) {
623 | obj.playAudioHomePage();
624 | }
625 | }();
626 |
627 | console.log("=== 天翼云盘 好棒棒 ===");
628 |
629 | // Your code here...
630 | })();
631 |
--------------------------------------------------------------------------------
/夸克网盘.user.js:
--------------------------------------------------------------------------------
1 | // ==UserScript==
2 | // @name 夸克网盘
3 | // @namespace https://bbs.tampermonkey.net.cn/
4 | // @version 0.1.6
5 | // @description 你手捏一片金黄,像一个归来的王
6 | // @author You
7 | // @match https://pan.quark.cn/s/*
8 | // @match https://pan.quark.cn/list*
9 | // @connect quark.cn
10 | // @icon https://pan.quark.cn/favicon.ico
11 | // @require https://code.jquery.com/jquery-3.6.0.min.js
12 | // @run-at document-body
13 | // @grant GM_xmlhttpRequest
14 | // ==/UserScript==
15 |
16 | (function () {
17 | 'use strict';
18 | var $ = $ || window.$;
19 | var obj = {
20 | file_page: {
21 | share_list: [],
22 | home_list: [],
23 | }
24 | };
25 |
26 | obj.httpListener = function () {
27 | (function(send) {
28 | XMLHttpRequest.prototype.send = function (sendParams) {
29 | this.addEventListener("load", function(event) {
30 | if (this.readyState == 4 && this.status == 200) {
31 | var response = this.response || this.responseText, responseURL = this.responseURL;
32 | if (responseURL.indexOf("/clouddrive/share/sharepage/detail") > 0) {
33 | obj.initFileList(response);
34 | }
35 | else if (responseURL.indexOf("/clouddrive/file/sort") > 0) {
36 | if ($(".ant-modal-mask").length && !$(".ant-modal-mask").hasClass("ant-modal-mask-hidden")) return;
37 | obj.initFileList(response);
38 | }
39 | }
40 | }, false);
41 | send.apply(this, arguments);
42 | };
43 | })(XMLHttpRequest.prototype.send);
44 | };
45 |
46 | obj.initFileList = function (response) {
47 | try { response = JSON.parse(response) } catch (error) { };
48 | var list = response?.data?.list;
49 | if ((list || []).length) {
50 | var index = parseInt(list.length / 3);
51 | if (list[index].fid === obj.file_page.share_list[index]?.fid || list[index].fid === obj.file_page.home_list[index]?.fid) {
52 | return;
53 | }
54 | if (obj.getShareId()) {
55 | obj.file_page.share_list = list;
56 | obj.showTipSuccess("share文件加载完成 共:" + list.length + "项");
57 | }
58 | else {
59 | obj.file_page.home_list = response.data.list;
60 | obj.showTipSuccess("home文件加载完成 共:" + list.length + "项");
61 | }
62 | obj.initDownloadPage();
63 | }
64 | };
65 |
66 | obj.initSharePage = function () {
67 | obj.httpListener();
68 | obj.openVideoSharePage();
69 | };
70 |
71 | obj.initHomePage = function () {
72 | obj.httpListener();
73 | if (obj.file_page.home_list.length == 0) {
74 | obj.getFileListHomePage().then(function (response) {
75 | obj.initFileList(response);
76 | });
77 | }
78 | };
79 |
80 | obj.initVideoPage = function () {
81 | obj.autoDelFileVideoPage();
82 | };
83 |
84 | obj.getFileListHomePage = function () {
85 | var pdir_fid = ((location.hash.match(/.+\/([a-z\d]{32})/) || []) [1]) || 0;
86 | return fetch("https://drive.quark.cn/1/clouddrive/file/sort?pr=ucpro&fr=pc&pdir_fid=" + pdir_fid + "&_page=1&_size=50&_fetch_total=1&_fetch_sub_dirs=0&_sort=file_type:asc,updated_at:desc", {
87 | body: null,
88 | method: "GET",
89 | credentials: "include"
90 | }).then(function (result) {
91 | return result.ok ? result.json() : Promise.reject();
92 | }).then(function (result) {
93 | return result.code == 0 ? result : Promise.reject(result);
94 | });
95 | };
96 |
97 | obj.openVideoSharePage = function () {
98 | $(document).on("click", ".file-click-wrap", function (event) {
99 | var filelist = obj.getSelectedFileList();
100 | if (filelist.length == 1 && filelist[0].obj_category == "video") {
101 | obj.dir().then(function (data) {
102 | var pdir_fid = data.pdir_fid;
103 | return obj.save(filelist, pdir_fid).then(function (data) {
104 | var task_id = data.task_id;
105 | return obj.waitTask(task_id).then(function (data) {
106 | var fids = data.save_as && data.save_as.save_as_top_fids;
107 | var fidsStorage = JSON.parse(sessionStorage.getItem("delete_fids") || "[]");
108 | sessionStorage.setItem("delete_fids", JSON.stringify(fidsStorage.concat(fids)));
109 | $(".pc-cannot-preview-cancel").click();
110 | window.open("https://pan.quark.cn/list#/video/" + fids[0], "_blank");
111 | window.onmessage = function (event) {
112 | var fids = JSON.parse(sessionStorage.getItem("delete_fids") || "[]");
113 | if (event.origin == "https://pan.quark.cn" && event.data && fids.includes(event.data)) {
114 | obj.delete([ event.data ]).then(function (data) {
115 | obj.task(data.task_id).then(function (data) {
116 | fids.splice(fids.indexOf(event.data), 1);
117 | sessionStorage.setItem("delete_fids", JSON.stringify(fids));
118 | });
119 | });
120 | }
121 | }
122 | window.onbeforeunload = function () {
123 | var fids = JSON.parse(sessionStorage.getItem("delete_fids") || "[]");
124 | obj.delete(fids).then(function (data) {
125 | obj.task(data.task_id).then(function (result) {
126 | sessionStorage.removeItem("delete_fids");
127 | });
128 | });
129 | };
130 | });
131 | });
132 | });
133 | };
134 | });
135 | };
136 |
137 | obj.autoDelFileVideoPage = function () {
138 | var fid = ((location.hash.match(/video\/(\w+)/) || []) [1]) || "";
139 | window.onbeforeunload = function () {
140 | window.opener.postMessage(fid, "/");
141 | };
142 | };
143 |
144 | obj.initDownloadPage = function () {
145 | if ($(".btn-show-link").length) {
146 | return;
147 | }
148 | if ($(".share-btns").length) {
149 | $(".share-btns").prepend('');
150 | $(".btn-show-link").on("click", obj.showDownloadSharePage);
151 | }
152 | else if ($(".btn-main").length) {
153 | $(".btn-main").append('');
154 | $(".btn-show-link").on("click", obj.showDownloadHomePage);
155 | }
156 | else {
157 | setTimeout(obj.initDownloadPage, 500);
158 | }
159 | };
160 |
161 | obj.showDownloadSharePage = function () {
162 | var filelist = obj.getSelectedFileList();
163 | if ((filelist = filelist.filter(function (item) {
164 | return item.category; // 0: 文件夹
165 | })).length === 0) return obj.showTipError("未获取到可下载文件");
166 | obj.downloadUrlSharePage(filelist).then(function (data) {
167 | obj.showBox(data);
168 | });
169 | };
170 |
171 | obj.showDownloadHomePage = function () {
172 | var filelist = obj.getSelectedFileList();
173 | if ((filelist = filelist.filter(function (item) {
174 | return item.category; // 0: 文件夹
175 | })).length === 0) return obj.showTipError("未获取到可下载文件");
176 | obj.downloadUrlHomePage(filelist).then(function (data) {
177 | obj.showBox(data);
178 | });
179 | };
180 |
181 | obj.showBox = function (filelist) {
182 | if (!(filelist && filelist.length)) return;
183 | var html = '';
184 | $("body").append(html);
185 | filelist.forEach(function (item, index) {
186 | var bc = `bc://http/${btoa(unescape(encodeURIComponent(`AA/${encodeURIComponent(item.file_name)}/?url=${encodeURIComponent(item.download_url)}&cookie=${encodeURIComponent(document.cookie)}ZZ`)))}`;
187 | $(".show-link-list").find(".ant-tree.ant-tree-directory").append('' + item.file_name + '比特彗星下载');
188 | });
189 | $(".show-link-list").find(".ant-modal-close").on("click", function () {
190 | $(".show-link-list").remove();
191 | });
192 | $(".show-link-list .buttons-wrap").prepend('');
193 | $(".show-link-list .buttons-wrap").prepend('');
194 | $(".show-link-list .buttons-wrap").prepend('');
195 | $(".show-link-list .buttons-wrap button:eq(-1)").on("click", function () {
196 | window.open("https://ifdian.net/a/vpannice", "_blank");
197 | });
198 | $(".show-link-list .buttons-wrap button:eq(-2)").on("click", function () {
199 | window.open("https://gcore.jsdelivr.net/gh/tampermonkeyStorage/Self-use@main/appreciation.png", "_blank");
200 | });
201 | $(".show-link-list .buttons-wrap button:eq(-3)").on("click", function () {
202 | var $this = $(this), $text = $this.text();
203 | $this.text("正在推送");
204 | var downData = [];
205 | filelist.forEach(function (item, index) {
206 | downData.push({
207 | id: "",
208 | jsonrpc: "2.0",
209 | method: "aria2.addUri",
210 | params:[
211 | //"token:你的RPC密钥", // 替换你的RPC密钥
212 | [ item.download_url ],
213 | {
214 | out: item.file_name,
215 | dir: "D:\/quarkDownloads", // 下载路径
216 | referer: "https://pan.quark.cn/",
217 | "user-agent": navigator.userAgent,
218 | header: [`cookie: ${document.cookie}`]
219 | }
220 | ]
221 | });
222 | });
223 | obj.aria2RPC(downData, function (result) {
224 | if (result) {
225 | obj.showTipSuccess("Aria2 推送完成,请查收");
226 | }
227 | else {
228 | obj.showTipError("Aria2 推送失败 可能 Aria2 未启动或配置错误");
229 | }
230 | $this.text($text);
231 | });
232 | });
233 | };
234 |
235 | obj.aria2RPC = function (downData, callback) {
236 | var urls = ["http://127.0.0.1:6800/jsonrpc", "http://localhost:16800/jsonrpc"];
237 | var url = sessionStorage.getItem("aria-url");
238 | $.ajax({
239 | type: "POST",
240 | url: url || urls[0],
241 | data: JSON.stringify(downData),
242 | crossDomain: true,
243 | processData: false,
244 | contentType: "application/json",
245 | success: function(result){
246 | url || sessionStorage.setItem("aria-url", this.url);
247 | callback && callback(result);
248 | },
249 | error: function (error) {
250 | var index = urls.indexOf(this.url);
251 | if (index >= 0) {
252 | if (index < urls.length - 1) {
253 | sessionStorage.setItem("aria-url", urls[index + 1]);
254 | setTimeout(function() { obj.aria2RPC(downData, callback) }, 500);
255 | }
256 | else {
257 | sessionStorage.removeItem("aria-url");
258 | callback && callback("");
259 | }
260 | }
261 | else {
262 | sessionStorage.setItem("aria-url", urls[index + 1]);
263 | setTimeout(function() { obj.aria2RPC(downData, callback) }, 500);
264 | }
265 | }
266 | });
267 | };
268 |
269 | obj.getSelectedFileList = function () {
270 | var list = obj.getShareId() ? obj.file_page.share_list : obj.file_page.home_list, fids = [];
271 | $(".ant-table-body tbody tr").each(function () {
272 | var $this = $(this);
273 | if ($this.find("input").get(0)?.checked) {
274 | fids.push($this.attr("data-row-key"));
275 | }
276 | });
277 | if (fids.length) {
278 | return list.filter(function (item) {
279 | return fids.includes(item.fid);
280 | });
281 | }
282 | else {
283 | return list;
284 | }
285 | };
286 |
287 | obj.downloadUrlSharePage = function (filelist) {
288 | return obj.dir().then(function (data) {
289 | var pdir_fid = data.pdir_fid;
290 | return obj.save(filelist, pdir_fid).then(function (data) {
291 | var task_id = data.task_id;
292 | return obj.waitTask(task_id).then(function (data) {
293 | var fids = data.save_as && data.save_as.save_as_top_fids;
294 | return obj.download(fids).finally(function () {
295 | obj.delete(fids).then(function (data) {
296 | var task_id = data.task_id;
297 | obj.task(task_id).catch(function (error) {
298 | obj.showTipError(error.message);
299 | });
300 | });
301 | });
302 | });
303 | }).catch(function (error) {
304 | obj.showTipError('文件缓存失败,可能网盘空间不足或一次缓存文件过多');
305 | });
306 | });
307 | };
308 |
309 | obj.downloadUrlHomePage = function (filelist) {
310 | return obj.download(filelist);
311 | };
312 |
313 | obj.dir = function () {
314 | return fetch("https://drive-pc.quark.cn/1/clouddrive/share/sharepage/dir?pr=ucpro&fr=pc", {
315 | body: null,
316 | method: "GET",
317 | credentials: "include"
318 | }).then(function (result) {
319 | return result.ok ? result.json() : Promise.reject();
320 | }).then(function (result) {
321 | return result.code == 0 ? result.data : Promise.reject(result);
322 | });
323 | };
324 |
325 | obj.save = function (filelist, to_pdir_fid) {
326 | var fid_list = [], fid_token_list = [];
327 | (Array.isArray(filelist) ? filelist : [ filelist ]).filter(Boolean).forEach(function (item) {
328 | fid_list.push(item.fid);
329 | fid_token_list.push(item.share_fid_token);
330 | });
331 | var _share_args = sessionStorage.getItem("_share_args")
332 | , value = JSON.parse(_share_args).value
333 | , pwd_id = value.pwd_id
334 | , stoken = value.stoken;
335 | return fetch("https://drive-pc.quark.cn/1/clouddrive/share/sharepage/save?pr=ucpro&fr=pc", {
336 | body: JSON.stringify({
337 | fid_list: fid_list,
338 | fid_token_list: fid_token_list,
339 | pdir_fid: "0",
340 | pwd_id: pwd_id,
341 | scene: "link",
342 | stoken: stoken,
343 | to_pdir_fid: to_pdir_fid || "0",
344 | }),
345 | method: "POST",
346 | credentials: "include"
347 | }).then(function (result) {
348 | return result.ok ? result.json() : Promise.reject();
349 | }).then(function (result) {
350 | return result.code == 0 ? result.data : Promise.reject(result);
351 | });
352 | };
353 |
354 | obj.waitTask = function (task_id, retry_index = 0) {
355 | return obj.task(task_id, retry_index).then(function (data) {
356 | if (data.status) {
357 | return data;
358 | }
359 | else {
360 | if (retry_index < 10) {
361 | return obj.delay().then(function () {
362 | return obj.waitTask(task_id, ++retry_index);
363 | });
364 | }
365 | else {
366 | return Promise.reject(data);
367 | }
368 | }
369 | });
370 | };
371 |
372 | obj.task = function (task_id, retry_index = 0) {
373 | return fetch("https://drive-pc.quark.cn/1/clouddrive/task?pr=ucpro&fr=pc&task_id=" + task_id + "&retry_index=" + retry_index, {
374 | body: null,
375 | method: "GET",
376 | credentials: "include"
377 | }).then(function (result) {
378 | return result.ok ? result.json() : Promise.reject();
379 | }).then(function (result) {
380 | return result.code == 0 ? result.data : Promise.reject(result);
381 | });
382 | };
383 |
384 | obj.download = function (filelist) {
385 | var fids = filelist.map(function (item) {
386 | return item.fid || item;
387 | });
388 | return fetch("https://drive-pc.quark.cn/1/clouddrive/file/download?pr=ucpro&fr=pc", {
389 | headers: {
390 | "accept": "application/json, text/plain, */*",
391 | "content-type": "application/json;charset=UTF-8"
392 | },
393 | body: JSON.stringify({
394 | fids: fids
395 | }),
396 | method: "POST",
397 | credentials: "include"
398 | }).then(function (result) {
399 | return result.ok ? result.json() : Promise.reject(result);
400 | }).then(function (result) {
401 | return result.code == 0 ? result.data : Promise.reject(result);
402 | }).catch(function (erroe) {
403 | return obj.fetch("https://drive-pc.quark.cn/1/clouddrive/file/download?pr=ucpro&fr=pc", {
404 | headers: {
405 | "accept": "application/json, text/plain, */*",
406 | "content-type": "application/json;charset=UTF-8"
407 | },
408 | body: JSON.stringify({
409 | fids: fids
410 | }),
411 | method: "POST",
412 | }).then(function (result) {
413 | return result.code == 0 ? result.data : Promise.reject(result);
414 | });
415 | });
416 | };
417 |
418 | obj.delete = function (filelist) {
419 | (Array.isArray(filelist) ? filelist : [ filelist ]).map(function(n) {
420 | return n?.fid || n;
421 | }).filter(Boolean);
422 | return fetch("https://drive-pc.quark.cn/1/clouddrive/file/delete?pr=ucpro&fr=pc", {
423 | headers: {
424 | "accept": "application/json, text/plain, */*",
425 | "content-type": "application/json;charset=UTF-8"
426 | },
427 | body: JSON.stringify({
428 | action_type: 2,
429 | exclude_fids: [],
430 | filelist: filelist
431 | }),
432 | method: "POST",
433 | credentials: "include"
434 | }).then(function (result) {
435 | return result.ok ? result.json() : Promise.reject();
436 | }).then(function (result) {
437 | return result.code == 0 ? result.data : Promise.reject(result);
438 | });
439 | };
440 |
441 | obj.fetch = function (url, option) {
442 | return new Promise(function (resolve, reject) {
443 | GM_xmlhttpRequest({
444 | method: option.method || "POST",
445 | url: url,
446 | data: option.body,
447 | headers: Object.assign({
448 | "accept": "application/json, text/plain, */*",
449 | "content-type": "application/json;charset=UTF-8",
450 | "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) quark-cloud-drive/3.0.2 Chrome/100.0.4896.160 Electron/18.3.5.12-a038f7b798 Safari/537.36 Channel/pckk_clouddrive_share_ch"
451 | }, option.headers),
452 | responseType: "json",
453 | onload: function (result) {
454 | var response = result.response || result.responseText;
455 | if (parseInt(result.status / 100) == 2) {
456 | resolve(response);
457 | }
458 | else {
459 | reject(response);
460 | }
461 | },
462 | onerror: function (result) {
463 | reject(result.error);
464 | }
465 | });
466 | });
467 | };
468 |
469 | obj.delay = function (ms = 500) {
470 | return new Promise(resolve => setTimeout(resolve, ms));
471 | };
472 |
473 | obj.getShareId = function () {
474 | return (window.location.pathname || "").split("/").slice(2)[0] || "";
475 | };
476 |
477 | obj.showTipSuccess = function (message, timeout) {
478 | if ($(".ant-message").length == 0) {
479 | $("body").append('
');
480 | }
481 | $(".ant-message span").append('');
482 | setTimeout(function () {
483 | $(".ant-message span").empty();
484 | }, timeout || 3e3)
485 | };
486 |
487 | obj.showTipError = function (message, timeout) {
488 | if ($(".ant-message").length == 0) {
489 | $("body").append('
');
490 | }
491 | $(".ant-message span").append('');
492 | setTimeout(function () {
493 | $(".ant-message span").empty();
494 | }, timeout || 3e3)
495 | };
496 |
497 | obj.run = function () {
498 | var url = location.href;
499 | if (url.indexOf(".quark.cn/s/") > 0) {
500 | obj.initSharePage();
501 | }
502 | else if (url.indexOf(".quark.cn/list") > 0) {
503 | if (url.indexOf(".quark.cn/list#/video/") > 0) {
504 | obj.initVideoPage();
505 | }
506 | else {
507 | obj.initHomePage();
508 | }
509 | }
510 | }();
511 |
512 | console.log("=== 夸克网盘 好棒棒!===");
513 |
514 | // Your code here...
515 | })();
516 |
--------------------------------------------------------------------------------
/百度网盘视频播放器.user.js:
--------------------------------------------------------------------------------
1 | // ==UserScript==
2 | // @name 百度网盘视频播放器
3 | // @namespace https://scriptcat.org/zh-CN/users/13895
4 | // @version 0.9.3
5 | // @description 功能更全,播放更流畅,界面更好看!特色功能主要有: 倍速任意调整,分辨率任意切换,自动加载播放列表,自动加载字幕,可加载本地字幕,可精细设置字幕样式,声音音质增强音量增大,画面比例调整,色彩调整,......,对常用设置自动记忆,支持移动端网页播放(网盘主页),想你所想,极致播放体验 ...
6 | // @author You
7 | // @match http*://yun.baidu.com/s/*
8 | // @match https://pan.baidu.com/s/*
9 | // @match https://pan.baidu.com/wap/home*
10 | // @match https://pan.baidu.com/play/video*
11 | // @match https://pan.baidu.com/pfile/video*
12 | // @match https://pan.baidu.com/pfile/mboxvideo*
13 | // @match https://pan.baidu.com/mbox/streampage*
14 | // @require https://scriptcat.org/lib/950/^1.0.1/Joysound.js
15 | // @require https://scriptcat.org/lib/1348/^1.1.3/artPlugins.js
16 | // @require https://unpkg.com/hls.js@1.4.14/dist/hls.min.js
17 | // @require https://unpkg.com/artplayer@5.2.2/dist/artplayer.js
18 | // @require https://unpkg.com/leancloud-storage@4.15.2/dist/av-min.js
19 | // @icon https://nd-static.bdstatic.com/business-static/pan-center/images/vipIcon/user-level2-middle_4fd9480.png
20 | // @run-at document-start
21 | // @antifeature ads
22 | // @antifeature membership
23 | // @antifeature payment
24 | // @antifeature referral-link
25 | // @antifeature tracking
26 | // @grant unsafeWindow
27 | // @grant GM_xmlhttpRequest
28 | // @grant GM_getValue
29 | // @grant GM_setValue
30 | // ==/UserScript==
31 |
32 | (function() {
33 | 'use strict';
34 |
35 | var obj = {
36 | video_page: {
37 | flag: "",
38 | file: {},
39 | filelist: [],
40 | quality: [],
41 | adToken: "",
42 | }
43 | };
44 |
45 | obj.currentList = function () {
46 | try {
47 | var currentList = unsafeWindow.require('system-core:context/context.js').instanceForSystem.list.getCurrentList();
48 | if (currentList.length) {
49 | sessionStorage.setItem("currentList", JSON.stringify(currentList));
50 | }
51 | else {
52 | setTimeout(obj.currentList, 500);
53 | }
54 | } catch (e) { }
55 |
56 | window.onhashchange = function (e) {
57 | setTimeout(obj.currentList, 500);
58 | };
59 | document.querySelector(".fufHyA") && [ ...document.querySelectorAll(".fufHyA") ].forEach(function (element) {
60 | element.onclick = function () {
61 | setTimeout(obj.currentList, 500);
62 | };
63 | });
64 | };
65 |
66 | obj.forcePreview = function () {
67 | unsafeWindow.jQuery(document).on("click", "#shareqr dd", function () {
68 | try {
69 | var selectedFile = unsafeWindow.require('system-core:context/context.js').instanceForSystem.list.getSelected()
70 | , file = selectedFile[0];
71 | if (file.category == 1) {
72 | var ext = file.server_filename.split(".").pop().toLowerCase();
73 | if (["ts", '3gp2','3g2','3gpp','amv','divx','dpg','f4v','m2t','m2ts','m2v','mpe','mpeg','mts','vob','webm','wxp','wxv','vob'].includes(ext)) {
74 | window.open("https://pan.baidu.com" + location.pathname + "?fid=" + file.fs_id, "_blank");
75 | }
76 | }
77 | } catch (error) { }
78 | });
79 | };
80 |
81 | obj.sharevideo = function () {
82 | if (unsafeWindow.require) {
83 | unsafeWindow.locals.get("file_list", "share_uk", "shareid", "sign", "timestamp", function (file_list, share_uk, shareid, sign, timestamp) {
84 | if (file_list.length == 1 && file_list[0].category == 1) {
85 | obj.startObj().then(function (obj) {
86 | obj.video_page.flag = "sharevideo";
87 | const { fs_id } = obj.video_page.file = file_list[0]
88 | , vip = obj.getVip();
89 | obj.video_page.getUrl = function (type) {
90 | return "/share/streaming?channel=chunlei&uk=" + share_uk + "&fid=" + fs_id + "&sign=" + sign + "×tamp=" + timestamp + "&shareid=" + shareid + "&type=" + type + "&vip=" + vip + "&jsToken=" + unsafeWindow.jsToken;
91 | }
92 | obj.getAdToken().then(function () {
93 | obj.addQuality();
94 | obj.addFilelist();
95 | obj.initVideoPlayer();
96 | });
97 | });
98 | }
99 | else {
100 | obj.currentList();
101 | obj.forcePreview();
102 | }
103 | });
104 | }
105 | else {
106 | }
107 | };
108 |
109 | obj.playvideo = function () {
110 | unsafeWindow.jQuery(document).ajaxComplete(function (event, xhr, options) {
111 | var response, requestUrl = options.url;
112 | if (requestUrl.indexOf("/api/categorylist") >= 0) {
113 | response = xhr.responseJSON;
114 | obj.video_page.filelist = response.info || [];
115 | }
116 | else if (requestUrl.indexOf("/api/filemetas") >= 0) {
117 | response = xhr.responseJSON;
118 | if (response && response.info) {
119 | obj.startObj().then(function (obj) {
120 | obj.video_page.flag = "playvideo";
121 | const { path } = obj.video_page.file = response.info[0]
122 | , vip = obj.getVip();
123 | obj.video_page.getUrl = function (type) {
124 | if (type.includes(1080)) vip > 1 || (type = type.replace(1080, 720));
125 | return "/api/streaming?path=" + encodeURIComponent(path) + "&app_id=250528&clienttype=0&type=" + type + "&vip=" + vip + "&jsToken=" + unsafeWindow.jsToken;
126 | }
127 | obj.getAdToken().then(function () {
128 | obj.addQuality();
129 | obj.addFilelist();
130 | obj.initVideoPlayer();
131 | });
132 | });
133 | }
134 | }
135 | });
136 | };
137 |
138 | obj.video = function () {
139 | const { $pinia, $router } = document.querySelector("#app")?.__vue_app__?.config?.globalProperties || {};
140 | if ($pinia && $router && Object.keys($pinia.state._rawValue.videoinfo?.videoinfo || {}).length) {
141 | obj.startObj().then(function (obj) {
142 | obj.video_page.flag = "video";
143 | const { recommendListInfo, videoinfo: { videoinfo } } = $pinia.state._rawValue;
144 | const { selectionVideoList } = recommendListInfo;
145 | if (Array.isArray(selectionVideoList) && selectionVideoList.length) {
146 | obj.video_page.filelist = selectionVideoList;
147 | }
148 | else {
149 | Object.defineProperty(recommendListInfo, "selectionVideoList", {
150 | enumerable: true,
151 | set(selectionVideoList) {
152 | obj.video_page.filelist = selectionVideoList;
153 | }
154 | });
155 | }
156 | const { path } = obj.video_page.file = videoinfo
157 | , vip = obj.getVip();
158 | obj.video_page.getUrl = function (type) {
159 | if (type.includes(1080)) vip > 1 || (type = type.replace(1080, 720));
160 | return "/api/streaming?path=" + encodeURIComponent(path) + "&app_id=250528&clienttype=0&type=" + type + "&vip=" + vip + "&jsToken=" + unsafeWindow.jsToken
161 | }
162 | obj.getAdToken().then(function () {
163 | obj.addQuality();
164 | obj.addFilelist();
165 | obj.initVideoPlayer();
166 | });
167 | });
168 | $router.isReady().then(function () {
169 | $router.afterEach(function (to, from) {
170 | from.fullPath === "/" || from.fullPath === to.fullPath || location.reload();
171 | });
172 | });
173 | }
174 | else {
175 | obj.delay().then(obj.video);
176 | }
177 | };
178 |
179 | obj.mboxvideo = function () {
180 | const { $pinia, $router } = document.querySelector("#app")?.__vue_app__?.config?.globalProperties || {};
181 | if ($pinia && $router && Object.keys($pinia.state._rawValue.videoinfo?.videoinfo || {}).length) {
182 | obj.startObj().then(function (obj) {
183 | obj.video_page.flag = "mboxvideo";
184 | const { to, from_uk, msg_id, fs_id, type, trans, ltime, adToken } = obj.video_page.file = $pinia.state._rawValue.videoinfo.videoinfo;
185 | obj.video_page.getUrl = function (stream_type) {
186 | 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;
187 | }
188 | obj.video_page.adToken = adToken || "";
189 | obj.getAdToken().then(function () {
190 | obj.addQuality();
191 | obj.addFilelist();
192 | obj.initVideoPlayer();
193 | });
194 | });
195 |
196 | $router.isReady().then(function () {
197 | $router.afterEach(function (to, from) {
198 | from.fullPath === "/" || from.fullPath === to.fullPath || location.reload();
199 | });
200 | });
201 | }
202 | else {
203 | obj.delay().then(obj.mboxvideo);
204 | }
205 | };
206 |
207 | obj.videoView = function () {
208 | const { videoFile } = document.querySelector(".preview-video")?.__vue__ || {};
209 | if (videoFile) {
210 | obj.startObj().then(function (obj) {
211 | obj.video_page.flag = "videoView";
212 | const { path } = obj.video_page.file = videoFile;
213 | obj.video_page.getUrl = function (type) {
214 | if (type.includes(1080)) +unsafeWindow.locals?.isVip > 1 || (type = type.replace(1080, 720));
215 | return "/rest/2.0/xpan/file?method=streaming&path=" + encodeURIComponent(path) + "&type=" + type;
216 | }
217 | obj.getAdToken().then(function () {
218 | obj.addQuality();
219 | obj.addFilelist();
220 | obj.initVideoPlayer();
221 | });
222 | });
223 | }
224 | else {
225 | obj.delay().then(obj.videoView);
226 | }
227 | };
228 |
229 | obj.initVideoPlayer = function () {
230 | obj.replaceVideoPlayer().then(function () {
231 | const { file, filelist, quality, getUrl, adToken } = obj.video_page;
232 | const { url, type } = quality.find((item) => item.default) || quality[0];
233 | const options = {
234 | adToken,
235 | file,
236 | filelist,
237 | quality,
238 | getUrl,
239 | url,
240 | type,
241 | id: "" + file.fs_id,
242 | poster: (Object.values(file.thumbs || []).slice(-1)[0] || "").replace(/size=c\d+_u\d+/, "size=c850_u580")
243 | };
244 | obj.artPlugins().init(options).then(() => {
245 | obj.showTip("视频播放器已就绪 ...", "success");
246 | obj.destroyPlayer();
247 | });
248 | });
249 | };
250 |
251 | obj.replaceVideoPlayer = function () {
252 | const { flag } = obj.video_page;
253 | var container, videoNode = document.querySelector("#video-wrap, .vp-video__player, #app .video-content");
254 | if (videoNode) {
255 | while (videoNode.nextSibling) {
256 | videoNode.parentNode.removeChild(videoNode.nextSibling);
257 | }
258 | container = document.getElementById("artplayer");
259 | if (!container) {
260 | container = document.createElement("div");
261 | container.setAttribute("id", "artplayer");
262 | if ([ "videoView" ].includes(flag)) {
263 | container.setAttribute("style", "width: 100%; height: 3.75rem;");
264 | }
265 | else {
266 | container.setAttribute("style", "width: 100%; height: 100%;");
267 | }
268 | obj.videoNode = videoNode.parentNode.replaceChild(container, videoNode);
269 | container.parentNode.style.cssText += 'z-index: auto;'
270 | return Promise.resolve();
271 | }
272 | }
273 | else {
274 | return obj.delay().then(function () {
275 | return obj.replaceVideoPlayer();
276 | });
277 | }
278 | };
279 |
280 | obj.artPlugins = function () {
281 | return window.artPlugins||function(t){var e={version:"1.1.3",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.2/artplayer.min.js")},readySupported:()=>Promise.resolve(GM_info).then(t=>{if(t){const{scriptHandler:e,scriptMetaStr:o=""}=t;if(["monkey","cript"].includes(e)&&Math.min(o.indexOf(1348),0))return Promise.reject()}}),initArtplayer:e=>{const o=window.Artplayer||unsafeWindow.Artplayer,{isMobile:n}=o.utils;return Object.assign(o,{ASPECT_RATIO:["default","自动","4:3","16:9"],AUTO_PLAYBACK_TIMEOUT:1e4,NOTICE_TIME:5e3}),new o(e=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 a=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 a,s=(decodeURIComponent(e||"").match(/backhost=(\[.*\])/)||[])[1];if(s){try{a=JSON.parse(s)}catch(t){}if(a&&a.length){const t=(a=[].concat(a,[n])).findIndex(t=>t===o.realHost);o.realHost=a[t+1>=a.length?0:t+1]}}}o.realHost&&(e=e.replace(n,o.realHost),t.open("GET",e,!0))}}});a.loadSource(e),a.attachMedia(t),a.on(n.Events.ERROR,(t,e)=>{if(e.fatal)switch(e.type){case n.ErrorTypes.NETWORK_ERROR:e.details===n.ErrorDetails.MANIFEST_LOAD_ERROR?setTimeout(()=>{a.loadSource(a.url)},1e3):e.details===n.ErrorDetails.MANIFEST_LOAD_TIMEOUT||e.details===n.ErrorDetails.MANIFEST_PARSING_ERROR?a.loadSource(a.url):e.details===n.ErrorDetails.FRAG_LOAD_ERROR?(a.fragLoadError=(a.fragLoadError||0)+1)<5?(a.loadSource(a.url),a.media.currentTime=o.currentTime,a.media.play()):(a.destroy(),o.notice.show="视频播放错误次数过多,请刷新重试"):a.startLoad();break;case n.ErrorTypes.MEDIA_ERROR:a.recoverMediaError();break;default:a.destroy(),o.notice.show="视频播放异常,请刷新重试"}}),o.hls=a,o.on("destroy",()=>a.destroy())}else t.canPlayType("application/vnd.apple.mpegurl")?t.src=e:(alert("不支持的播放格式:m3u8"),o.notice.show="Unsupported playback format: m3u8")}},flip:!1,icons:{loading:'
',state:'
',indicator:'
'},id:"",pip:!n,poster:"",playbackRate:!1,screenshot:!0,setting:!0,subtitle:{url:"",type:"auto",style:{color:"#fe9200",bottom:"5%",fontSize:"25px",fontWeight:400,fontFamily:"",textShadow:""},encoding:"utf-8",escape:!1},subtitleOffset:!1,hotkey:!0,fullscreen:!0,fullscreenWeb:!n},e),e=>{t.forEach(t=>{e.plugins.add(t())})})},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 e}([()=>t=>{const e=window.Hls||unsafeWindow.Hls,{hls:o,layers:n,notice:a,storage:s,constructor:{CONTEXTMENU:r,utils:{query:i,append:l,setStyle:c,clamp:p,debounce:u,throttle:d}}}=t,h={show:!1};function m(){return b().then(t=>{const e=t.User.current();if(e){const{ON:o,authData:n,check:a,expire_time:r,updatedAt:i}=e.toJSON();if(3===[Math.max(Date.parse(i)+864e5-Date.now(),0),JSON.stringify(n)===JSON.stringify({baidu:{uid:""+("function"==typeof unsafeWindow.locals.get?unsafeWindow.locals.get("uk"):unsafeWindow.locals.uk)}}),s.get(t._getAVPath(t.User._CURRENT_USER_KEY))===btoa(encodeURIComponent(JSON.stringify(r)))].filter(Boolean).length)return o?Math.max(a,0)?Math.max(Date.parse(i)+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:r,check:a-1}),t._handleSaveResult(!0).then(()=>t))):g():e}return g()})}function g(){return b().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",s.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:a}=e.toJSON();return s.set(t._getAVPath(t.User._CURRENT_USER_KEY),btoa(encodeURIComponent(JSON.stringify(a)))),e})}))}function b(){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(){h.show||n.update({name:"sponsor",html:'\n \n \n \n \n \n
\n \n \n \n \n
\n ',tooltip:"感谢支持,赞助后不再提示",style:{position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)",background:"rgba(0, 0, 0, 0.7)",border:"1px solid #c6c6c6",borderRadius:"8px",textAlign:"center"},click:(e,o)=>{o.isTrusted||t.destroy(),t.mask.show=!1,t.loading.show=!1},mounted:e=>{t.pause(),o.stopLoad(),h.show=!0,setTimeout(()=>{t.mask.show=!1,t.loading.show=!1,t.controls.show=!1,t.setting.show=!1,t.constructor.CONTEXTMENU=!1},500);const n=i("#open-afdian",e),r=i("#copy-order",e),l=i("#update-script",e);t.proxy(n,"click",()=>{window.open("https://afdian.com/order/create?plan_id=dc4bcdfa5c0a11ed8ee452540025c377","_blank")}),t.proxy(r,"click",()=>{window.open("https://afdian.com/dashboard/order","_blank")}),t.proxy(l,"click",()=>{window.open("https://scriptcat.org/scripts/code/340/BD%E7%BD%91%E7%9B%98%E8%A7%86%E9%A2%91%E6%92%AD%E6%94%BE%E5%99%A8.user.js","_blank")});const c=i("#order-input",e),p=i("#cancel-order",e),u=i("#submit-order",e);t.proxy(p,"click",()=>{x()}),t.proxy(u,"click",()=>{if(c.value){const t=c.value.trim();if(t.match(/^202[\d]{22,25}$/)){if(t.match(/(\d)\1{7,}/g))return;!function(t){const e=s.get(t)||0;s.set(t,e+1),b().then(e=>m().then(o=>{const{authData:n,expire_time:a,shortId:r,username:i}=o.toJSON(),l=new(e.Object.extend("baidu"));l.set("ON",t),l.set("pnum",s.get(t));for(let[t,e]of Object.entries({authData:n,expire_time:a,shortId:r,username:i}))l.set(t,e);return l.save().then(n=>{Object.assign(o.attributes,{ON:t,check:3,expire_time:new Date(Date.now()+864e3).toISOString()});const{expire_time:a}=o.toJSON();return s.set(e._getAVPath(e.User._CURRENT_USER_KEY),btoa(encodeURIComponent(JSON.stringify(a)))),o._handleSaveResult(!0)})}))}(t),x()}else a.show="此订单号不合规范,请重试"}else a.show="请输入订单号"})}})}function x(){n.hasOwnProperty("sponsor")&&(o.startLoad(),h.show=!1,n.remove("sponsor"),t.constructor.CONTEXTMENU=r)}function y(){t.contextmenu.update({index:51,html:"更多功能",click:()=>{f(),t.contextmenu.show=!1}}),t.contextmenu.update({index:52,html:"鼓励一下",click:()=>{window.open("https://pc-index-skin.cdn.bcebos.com/6cb0bccb31e49dc0dba6336167be0a18.png","_blank"),t.contextmenu.show=!1}}),t.setting.update({html:"赞赏作者",name:"author-setting",tooltip:"",selector:[{html:"更多功能",value:0},{html:"鼓励一下",value:1}],onSelect:t=>(0===t.value?f():1===t.value&&window.open("https://pc-index-skin.cdn.bcebos.com/6cb0bccb31e49dc0dba6336167be0a18.png","_blank"),"")});let n=Number(s.get("pnum")||0);s.set("pnum",++n),t.on("video:ended",()=>{m().then(e=>{const{expire_time:o}=e.toJSON();Math.max(Date.parse(o)-Date.now(),0)||t.layers.update({name:"potser",html:'
',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)=>{m().then(e=>{t.emit("user",e.toJSON()),t.once("user",({expire_time:t})=>{Math.max(Date.parse(t)-Date.now(),0)?x():f()})})},1e3*p(420,t.duration/100,t.duration/3)))}return t.isReady?y():t.once("ready",y),{name:"user",userJSON:function(){return m().then(t=>t.toJSON())},show:f}},()=>t=>{const{i18n:e,option:o,notice:n,storage:a,controls:s,constructor:{utils:{isMobile:r,setStyle:i}}}=t;function l(t){return r?t.split(/\s/).shift():t}function c(){const a=o.quality,r=a.find(t=>t.default)||a[0];s.update({name:"quality",html:r?l(r.html):"",selector:a.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&&i(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:a}}}=t,s={showtext:!a,icon:''};function r(){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:s.showtext?e.get("PlayList"):s.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(),s.showtext?e.get("PlayList"):s.icon)})}(o.filelist)})}return e.update({"zh-cn":{PlayList:"播放列表"}}),t.isReady?r():t.once("ready",r),{name:"playlist"}},()=>t=>{const{i18n:e,icons:o,option:n,layers:a,storage:s,plugins:r,setting:i,contextmenu:l,constructor:{PLAYBACK_RATE:c,SETTING_ITEM_WIDTH:p,utils:{query:u,append:d,setStyle:h,inverseClass:m}}}=t;function g(){return a["auto-playbackrate"]||a.update({name:"auto-playbackrate",html:`播放速度
`,tooltip:"",style:{"border-radius":"var(--art-border-radius)",left:"var(--art-padding)",bottom:"calc(var(--art-control-height) + var(--art-bottom-gap) + 10px)","background-color":"var(--art-widget-background)","align-items":"center",gap:"10px",padding:"10px","line-height":1,display:"none",position:"absolute"},mounted:e=>{const o=u("input",e),n=u(".art-auto-playback-close",e);t.proxy(o,"change",()=>{const e=o.value;t.playbackRate=e}),t.proxy(n,"click",()=>{h(e,"display","none")})}})}function b(t){return 1===t?e.get("Normal"):t?t.toFixed(2):e.get("Custom")}function f(){return c.includes(t.playbackRate)?t.playbackRate:0}function x(){const t=i.find(`playback-rate-${f()}`);t&&i.check(t)}function y(){t.once("user",({expire_time:e})=>{if(Math.max(Date.parse(e)-Date.now(),0)){t.on("video:ratechange",()=>s.set("playbackRate",t.playbackRate));const e=s.get("playbackRate");e&&(t.playbackRate=Number(e))}else t.on("video:ratechange",()=>{f()||(t.playbackRate=1)})})}return e.update({"zh-cn":{Custom:"自定义"}}),c.unshift(0),i.update({width:p,name:"playback-rate",html:e.get("Play Speed"),tooltip:b(t.playbackRate),icon:o.playbackRate,selector:c.map(t=>({value:t,name:`playback-rate-${t}`,default:t===f(),html:b(t)})),onSelect(e){if(e.value)t.playbackRate=e.value,h(g(),"display","none");else{const{userJSON:e,show:o}=r.user;e().then(({expire_time:e})=>{if(Math.max(Date.parse(e)-Date.now(),0)){u("input",g()).value=t.playbackRate,h(g(),"display","flex")}else o()})}return e.html},mounted:()=>{x(),t.on("video:ratechange",()=>x())}}),l.update({index:10,name:"playbackRate",html:`${e.get("Play Speed")}: ${c.map(t=>`${b(t)}`).join("")}`,click:(e,o)=>{e.show=!1;const{value:n}=o.target.dataset;if(Number(n))t.playbackRate=Number(n),h(g(),"display","none");else{const{userJSON:e,show:o}=r.user;e().then(({expire_time:e})=>{if(Math.max(Date.parse(e)-Date.now(),0)){u("input",g()).value=t.playbackRate,h(g(),"display","flex")}else o()})}},mounted:e=>{const o=u(`[data-value='${f()}']`,e);o&&m(o,"art-current"),t.on("video:ratechange",()=>{const t=u(`[data-value='${f()}']`,e);t&&m(t,"art-current")})}}),t.isReady?y():t.once("ready",y),{name:"playbackRate"}},()=>t=>{const{i18n:e,option:o,notice:n,storage:a,plugins:s,setting:r,controls:i,template:l,subtitle:c,contextmenu:p,constructor:{utils:{isMobile:u,append:d,query:h,inverseClass:m}}}=t,g={showtext:!u,icon:'',tooltip:''};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 a=n.result;return a.indexOf("�")>-1&&!n.markGBK?(n.markGBK=!0,n.readAsText(t,"GBK")):a.indexOf("")>-1&&!n.markBIG5?(n.markBIG5=!0,n.readAsText(t,"BIG5")):void e(a)},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 f(t=[]){if(t.length<1)return;const e=t.find(t=>t.default)||t[0],a=Object.assign({},o.subtitle,{style:o.subtitle.style},e),{url:s,type:r}=a;Object.assign(o.subtitle,{url:s,type:r,escape:!1}),c.init({...a}).then(()=>{a.name&&(n.show=`加载字幕: ${a.name}`)}),i.update({html:g.showtext?"字幕列表":g.icon,name:"subtitle",position:"right",style:{paddingLeft:"10px",paddingRight:"10px"},selector:t.map((t,e)=>({...t})),onSelect:function(t,e){const{url:s,type:r}=t;return Object.assign(o.subtitle,{url:s,type:r}),c.switch(s,a).then(()=>{n.show=`切换字幕: ${t.name}`}),t.html}})}function x(){t.once("user",({expire_time:e})=>{if(Math.max(Date.parse(e)-Date.now(),0)){Object.assign(o.subtitle.style,{color:a.get("subtitle-color"),bottom:a.get("subtitle-bottom"),fontSize:a.get("subtitle-fontSize"),fontWeight:a.get("subtitle-fontWeight"),fontFamily:a.get("subtitle-fontFamily"),textShadow:a.get("subtitle-textShadow")}),t.on("subtitle",t=>a.set("subtitle",t));const e=a.get("subtitle");"boolean"==typeof e&&(c.show=e),(o.sublist||[]).length&&f(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{o.sublist=(o.sublist||[]).concat(t),f(o.sublist)}),o.subid=o.id,t.on("restart",()=>{if(o.subid===o.id){const t=i.cache.get("subtitle").option.selector;(t||[]).length&&f(t)}else if(o.subid=o.id,(o.sublist||[]).length)f(o.sublist);else{const{$subtitle:t}=l;t.innerHTML="",o.subtitle.url="",c.createTrack("metadata",""),i.hasOwnProperty("subtitle")&&i.remove("subtitle")}})}})}return r.add({html:"字幕设置",name:"subtitle-setting",tooltip:"",icon:'',selector:[{html:"显示",name:"subtitle",tooltip:"显示",switch:!0,onSwitch:t=>(t.tooltip=t.switch?"隐藏":"显示",c.show=!t.switch,!t.switch),mounted:(e,o)=>{const n=c.show;o.switch=n,o.tooltip=n?"显示":"隐藏",t.on("subtitle",t=>{setTimeout(()=>{o.switch!==t&&(o.switch=t,o.tooltip=t?"显示":"隐藏")})})}},{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=>{setTimeout(()=>{o.$range.value=t,o.tooltip=t+"s"})})}},{html:"字幕位置",name:"subtitle-bottom",tooltip:"5%",range:[5,1,90,1],onChange(t){const e=t.range[0]+"%";return c.style({bottom:e}),a.set("subtitle-bottom",e),e},mounted:(t,e)=>{const o=a.get("subtitle-bottom");o&&(e.tooltip=o,e.$range.value=parseFloat(o))}},{html:"字体大小",name:"subtitle-fontSize",tooltip:"25px",range:[25,10,60,1],onChange(t){const e=t.range[0]+"px";return c.style({fontSize:e}),a.set("subtitle-fontSize",e),e},mounted:(t,e)=>{const o=a.get("subtitle-fontSize");o&&(e.tooltip=o,e.$range.value=parseFloat(o))}},{html:"字体粗细",name:"subtitle-fontWeight",tooltip:400,range:[400,100,900,100],onChange(t){const e=t.range[0];return a.set("subtitle-fontWeight",e),c.style({fontWeight:e}),e},mounted:(t,e)=>{const o=a.get("subtitle-fontWeight");o&&(e.tooltip=o,e.$range.value=o)}},{html:"字体颜色",name:"subtitle-color",tooltip:g.tooltip,selector:[{html:"预设",name:"color-presets",tooltip:''},{html:"默认颜色",name:"color-default",tooltip:g.tooltip},{html:"颜色选择器",name:"color-picker",tooltip:g.tooltip.replace("#FE9200","#000")}],onSelect:function(t,e,o){switch(t.name){case"color-presets":if("INPUT"===o.target.nodeName){const t=o.target.value;c.style({color:t}),a.set("subtitle-color",t)}break;case"color-default":c.style({color:"#FE9200"}),a.set("subtitle-color","#FE9200");break;case"color-picker":l.$colorPicker||(l.$colorPicker=d(l.$player,''),l.$colorPicker.oninput=(e=>{const o=e.target.value;c.style({color:o}),a.set("subtitle-color",o),t.tooltip=t.$parent.tooltip=g.tooltip.replace("#FE9200",o)})),l.$colorPicker.click()}return g.tooltip.replace("#FE9200",l.$subtitle.style.color)},mounted:(t,e)=>{const o=a.get("subtitle-color");o&&(e.tooltip=g.tooltip.replace("#FE9200",o))}},{html:"字体类型",name:"subtitle-fontFamily",tooltip:e.get("Default"),selector:[{html:"默认",text:""},{html:"等宽 衬线",value:'"Courier New", Courier, "Nimbus Mono L", "Cutive Mono", monospace'},{html:"比例 衬线",value:'"Times New Roman", Times, Georgia, Cambria, "PT Serif Caption", serif'},{html:"等宽 无衬线",value:'"Deja Vu Sans Mono", "Lucida Console", Monaco, Consolas, "PT Mono", monospace'},{html:"比例 无衬线",value:'"YouTube Noto", Roboto, "Arial Unicode Ms", Arial, Helvetica, Verdana, "PT Sans Caption", sans-serif'},{html:"Casual",value:'"Comic Sans MS", Impact, Handlee, fantasy'},{html:"Cursive",value:'"Monotype Corsiva", "URW Chancery L", "Apple Chancery", "Dancing Script", cursive'},{html:"Small Capitals",value:'"Arial Unicode Ms", Arial, Helvetica, Verdana, "Marcellus SC", sans-serif'}],onSelect:function(t,e,o){return a.set("subtitle-fontFamily",t.html),c.style({fontFamily:t.value}),t.html},mounted:(t,e)=>{const o=a.get("subtitle-fontFamily");o&&(e.tooltip=o)}},{html:"描边样式",name:"subtitle-textShadow",tooltip:e.get("Default"),selector:[{html:"默认",value:"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:"重墨",value:"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:"描边",value:"rgb(0, 0, 0) 0px 0px 1px, rgb(0, 0, 0) 0px 0px 1px, rgb(0, 0, 0) 0px 0px 1px"},{html:"45°投影",value:"rgb(0, 0, 0) 1px 1px 2px, rgb(0, 0, 0) 0px 0px 1px"},{html:"阴影",value:"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:"凸起",value:"rgb(34, 34, 34) 1px 1px"},{html:"下沉",value:"rgb(204, 204, 204) 1px 1px, rgb(34, 34, 34) -1px -1px"},{html:"边框",value:"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),c.style({textShadow:t.value}),t.html},mounted:(t,e)=>{const o=a.get("subtitle-textShadow");o&&(e.tooltip=o)}},{name:"subtitle-load",html:"加载字幕",selector:[{html:"本地文件",name:"file"}],onSelect:function(t,e,n){const{userJSON:a,show:r}=s.user;return a().then(({expire_time:e})=>{Math.max(Date.parse(e)-Date.now(),0)?"file"===t.name&&(l.$subtitleLocalFile||(l.$subtitleLocalFile=d(l.$container,'')),function(t){return t.click(),new Promise(function(e,o){t.onchange=(t=>{if(t.target.files.length){const o=t.target.files[0],n=o.name.split(".").pop().toLowerCase();b(o).then(t=>{const a={url:t,type:n,name:o.name,html:`本地字幕「${n}」`};e(a)})}t.target.value=""})})}(l.$subtitleLocalFile).then(t=>{o.sublist=(o.sublist||[]).concat([t]),f(o.sublist)})):r()}),""}}]}),p.update({name:"subtitle",index:31,html:`字幕显示: ${[1,0].map(t=>`${t?"显示":"隐藏"}`).join("")}`,click:(t,e)=>{m(e.target,"art-current");const{value:o}=e.target.dataset;c.show=Boolean(Number(o)),t.show=!1},mounted:e=>{const o=h(`[data-value='${Number(c.show)}']`,e);o&&m(o,"art-current"),t.on("subtitle",t=>{const o=h(`[data-value='${Number(t)}']`,e);o&&m(o,"art-current")})}}),t.isReady?x():t.once("ready",x),{name:"subtitle"}},()=>t=>{const{notice:e,storage:o,plugins:n,setting:a}=t;function s(){t.once("user",({expire_time:e})=>{Math.max(Date.parse(e)-Date.now(),0)&&function(){const e=window.Joysound||unsafeWindow.Joysound;e&&e.isSupport()&&(t.joySound=t.joySound||new e,t.joySound.hasSource()||t.joySound.init(t.template.$video),o.get("joysound")&&t.joySound.setEnabled(!0))}()})}return a.add({html:"声音设置",name:"joysound",tooltip:"",selector:[{html:"音质增强",name:"high",tooltip:"关闭",switch:!1,onSwitch:a=>{const s=a.switch;a.tooltip=s?"关闭":"开启";const{userJSON:r,show:i}=n.user;return r().then(({expire_time:n})=>{Math.max(Date.parse(n)-Date.now(),0)?(o.set("joysound",!s),t.joySound&&t.joySound.setEnabled(!s),e.show=`音质增强: ${s?"关闭":"开启"}`):i()}),!s},mounted:(t,e)=>{o.get("joysound")&&(e.tooltip="增强",e.switch=!0)}},{html:"音量增强",name:"volume",tooltip:"0x",range:[0,0,10,.1],onRange:o=>{const a=o.range[0]/10,{userJSON:s,show:r}=n.user;return s().then(({expire_time:o})=>{Math.max(Date.parse(o)-Date.now(),0)?(t.joySound&&t.joySound.setVolume(a),e.show=`音量增强: ${100+100*a}%`):r()}),`${Math.round(100*o.range[0])/100}x`}}]}),t.playing?s():t.once("video:playing",s),{name:"sound"}},()=>t=>{const{notice:e,storage:o,plugins:n,setting:a,template:{$video:{style:s}}}=t;function r(){t.once("user",({expire_time:t})=>{if(Math.max(Date.parse(t)-Date.now(),0)){const{saturate:t=1,brightness:e=1,contrast:n=1}=o.get("filter")||{};s.filter=`saturate(${t}) brightness(${e}) contrast(${n})`}})}return a.update({html:"色彩滤镜",name:"filter",tooltip:"",selector:[{html:"饱和度",name:"saturate",tooltip:100,range:[100,0,255,1],onRange:t=>{const a=t.range[0],{userJSON:r,show:i}=n.user;return r().then(({expire_time:t})=>{if(Math.max(Date.parse(t)-Date.now(),0)){e.show=`饱和度: ${a}`,o.set("filter",{...o.get("filter"),saturate:a/100});const{saturate:t=1,brightness:n=1,contrast:r=1}=o.get("filter")||{};s.filter=`saturate(${t}) brightness(${n}) contrast(${r})`}else i()}),a},mounted:(t,e)=>{const{saturate:n=1}=o.get("filter")||{};e.$range.value=100*n,e.tooltip=100*n}},{html:"亮度",name:"brightness",tooltip:100,range:[100,0,255,1],onRange:t=>{const a=t.range[0],{userJSON:r,show:i}=n.user;return r().then(({expire_time:t})=>{if(Math.max(Date.parse(t)-Date.now(),0)){e.show=`亮度: ${a}`,o.set("filter",{...o.get("filter"),brightness:a/100});const{saturate:t=1,brightness:n=1,contrast:r=1}=o.get("filter")||{};s.filter=`saturate(${t}) brightness(${n}) contrast(${r})`}else i()}),a},mounted:(t,e)=>{const{brightness:n=1}=o.get("filter")||{};e.$range.value=100*n,e.tooltip=100*n}},{html:"对比度",name:"contrast",tooltip:100,range:[100,0,255,1],onRange:t=>{const a=t.range[0],{userJSON:r,show:i}=n.user;return r().then(({expire_time:t})=>{if(Math.max(Date.parse(t)-Date.now(),0)){e.show=`对比度: ${a}`,o.set("filter",{...o.get("filter"),contrast:a/100});const{saturate:t=1,brightness:n=1,contrast:r=1}=o.get("filter")||{};s.filter=`saturate(${t}) brightness(${n}) contrast(${r})`}else i()}),a},mounted:(t,e)=>{const{contrast:n=1}=o.get("filter")||{};e.$range.value=100*n,e.tooltip=100*n}},{html:"预设「1」",name:"filter-presets",tooltip:""},{html:"默认",name:"filter-default",tooltip:""}],onSelect:(t,e,r)=>{const{userJSON:i,show:l}=n.user;return i().then(({expire_time:e})=>{if(Math.max(Date.parse(e)-Date.now(),0)){const e=a.find("saturate"),n=a.find("brightness"),r=a.find("contrast");"filter-presets"===t.name?(e.tooltip=110,e.$range.value=110,n.tooltip=105,n.$range.value=105,r.tooltip=101,r.$range.value=101,o.set("filter",{saturate:1.1,brightness:1.05,contrast:1.01}),s.filter="saturate(1.1) brightness(1.05) contrast(1.01)"):"filter-default"===t.name&&(e.tooltip=100,e.$range.value=100,n.tooltip=100,n.$range.value=100,r.tooltip=100,r.$range.value=100,o.set("filter",{saturate:1,brightness:1,contrast:1}),s.filter="")}else l()}),t.html}}),t.isReady?r():t.once("ready",r),{name:"imagefilter"}},()=>t=>{const{i18n:e,notice:o,storage:n,plugins:a,setting:s,controls:r,constructor:{utils:{throttle:i}}}=t;function l(){t.once("user",({expire_time:e})=>{Math.max(Date.parse(e)-Date.now(),0)&&(n.get("auto-fullscreen")&&(t.fullscreenWeb=!0),t.startTime=n.get("startTime"),t.endTime=n.get("endTime"),t.on("video:timeupdate",i(()=>{const{currentTime:e,duration:o,startTime:n,endTime:a}=t;if(n||a){const s=[[0,n||0],[a?o-a:0,a?o:0]];for(const[o,n]of s)if(e>=o&&e{if(n.get("auto-next")&&r.hasOwnProperty("playlist")){const t=r.cache.get("playlist").option.selector,e=t[t.findIndex(t=>t.default)+1];e?e.$control_item.click():o.show="没有下一集了"}}))})}return s.update({html:"播放设置",name:"play-setting",tooltip:"",selector:[{html:"自动下一集",name:"auto-next",icon:"",tooltip:"关闭",switch:!1,onSwitch:t=>{const e=t.switch;t.tooltip=e?"关闭":"开启";const{userJSON:s,show:r}=a.user;return s().then(({expire_time:t})=>{Math.max(Date.parse(t)-Date.now(),0)?(n.set("auto-next",!e),o.show=`自动下一集: ${e?"关闭":"开启"}`):r()}),!e},mounted:(t,e)=>{n.get("auto-next")&&(e.tooltip="开启",e.switch=!0)}},{html:"自动全屏",name:"auto-fullscreen",icon:"",tooltip:"关闭",switch:!1,onSwitch:e=>{const s=e.switch;e.tooltip=s?"关闭":"开启";const{userJSON:r,show:i}=a.user;return r().then(({expire_time:e})=>{Math.max(Date.parse(e)-Date.now(),0)?(t.fullscreenWeb=!s,n.set("auto-fullscreen",!s),o.show=`自动全屏: ${s?"关闭":"开启"}`):i()}),!s},mounted:(t,e)=>{n.get("auto-fullscreen")&&(e.tooltip="开启",e.switch=!0)}},{html:"跳过片头",tooltip:"0s",range:[0,0,120,1],onChange(e){const s=e.range[0],{userJSON:r,show:i}=a.user;return r().then(({expire_time:e})=>{Math.max(Date.parse(e)-Date.now(),0)?(t.startTime=s,n.set("startTime",s),o.show=`跳过片头: ${s} 秒`):i()}),s+"s"},mounted:(t,e)=>{const o=n.get("startTime");o&&(e.range=[o,0,120,1],e.tooltip=o+"s")}},{html:"跳过片尾",tooltip:"0s",range:[0,0,120,1],onChange(e){const s=e.range[0],{userJSON:r,show:i}=a.user;return r().then(({expire_time:e})=>{Math.max(Date.parse(e)-Date.now(),0)?(t.endTime=s,n.set("endTime",s),o.show=`跳过片尾: ${s} 秒`):i()}),s+"s"},mounted:(t,e)=>{const o=n.get("endTime");o&&(e.range=[o,0,120,1],e.tooltip=o+"s")}}]}),t.isReady?l():t.once("ready",l),{name:"play"}},()=>t=>{const{proxy:e,option:o,contextmenu:n,template:a,constructor:{utils:{query:s,append:r,isMobile:i}}}=t;function l(){t.once("user",({expire_time:e})=>{Math.max(Date.parse(e)-Date.now(),0)&&(o.hotkey&&!i&&(t.isFocus||(t.isFocus=!0)),t.on("blur",e=>{o.hotkey&&!i&&(t.isFocus=!0)}))})}return t.isReady?l():t.once("ready",l),{name:"hotkey"}}]);
282 | };
283 |
284 | obj.destroyPlayer = function () {
285 | var count, id;
286 | const { flag } = obj.video_page;
287 | if ([ "sharevideo", "playvideo" ].includes(flag)) {
288 | unsafeWindow.require.async("file-widget-1:videoPlay/context.js", function (context) {
289 | id = count = setInterval(function () {
290 | var playerInstance = context && context.getContext()?.playerInstance;
291 | if (playerInstance && playerInstance.player) {
292 | clearInterval(id);
293 | playerInstance.player.dispose();
294 | playerInstance.player = !1;
295 | }
296 | else if (++count - id > 60) {
297 | clearInterval(id);
298 | }
299 | }, 500);
300 | });
301 | }
302 | else if ([ "video", "mboxvideo" ].includes(flag)) {
303 | id = count = setInterval(function() {
304 | var playerInstance = obj.videoNode?.firstChild;
305 | if (playerInstance && playerInstance.player) {
306 | clearInterval(id);
307 | playerInstance.player.dispose();
308 | playerInstance.player = !1;
309 | obj.videoNode = null;
310 | }
311 | else if (++count - id > 60) {
312 | clearInterval(id);
313 | obj.videoNode = null;
314 | }
315 | }, 500);
316 | }
317 | else {
318 | obj.videoNode = null;
319 | }
320 | };
321 |
322 | obj.getVip = function () {
323 | if (unsafeWindow.yunData && !unsafeWindow.yunData.neglect) {
324 | return 1 === unsafeWindow.yunData.ISSVIP ? 2 : 1 === unsafeWindow.yunData.ISVIP ? 1 : 0;
325 | }
326 | if (unsafeWindow.locals) {
327 | var is_svip = false, is_vip = false;
328 | if (unsafeWindow.locals.get) {
329 | is_svip = 1 === +unsafeWindow.locals.get("is_svip");
330 | is_vip = 1 === +unsafeWindow.locals.get("is_vip");
331 | return is_svip ? 2 : is_vip ? 1 : 0;
332 | }
333 | is_svip = 1 === +unsafeWindow.locals.is_svip;
334 | is_vip = 1 === +unsafeWindow.locals.is_vip;
335 | return is_svip ? 2 : is_vip ? 1 : 0;
336 | }
337 | return 0;
338 | };
339 |
340 | obj.getAdToken = function () {
341 | if (obj.video_page.adToken || obj.getVip() > 1) {
342 | return Promise.resolve(obj.video_page.adToken);
343 | }
344 | const { getUrl } = obj.video_page;
345 | const url = getUrl(obj.getBPSType());
346 | return fetch(url).then(function (response) {
347 | return response.text();
348 | }).then(function (response) {
349 | try { response = JSON.parse(response) } catch (e) { }
350 | if (response && 133 === response.errno && 0 !== response.adTime) {
351 | obj.video_page.adToken = response.adToken;
352 | }
353 | return obj.video_page.adToken;
354 | });
355 | };
356 |
357 | obj.addQuality = function () {
358 | const { file: { resolution }, getUrl, adToken } = obj.video_page;
359 | const templates = {
360 | 1080: "超清 1080P",
361 | 720: "高清 720P",
362 | 480: "流畅 480P",
363 | 360: "省流 360P"
364 | };
365 | const freeList = obj.freeList(resolution);
366 | obj.video_page.quality = freeList.map(function (template, index) {
367 | return {
368 | html: templates[template],
369 | url: getUrl(obj.getBPSType(template)) + "&adToken=" + encodeURIComponent(adToken),
370 | default: index === 0,
371 | type: "hls"
372 | };
373 | });
374 | return obj.video_page.quality;
375 | };
376 |
377 | obj.freeList = function (e) {
378 | e = e || "";
379 | var t = [480, 360]
380 | , a = e.match(/width:(\d+),height:(\d+)/) || ["", "", ""]
381 | , i = +a[1] * +a[2];
382 | return i ? (i > 409920 && t.unshift(720), i > 921600 && t.unshift(1080), t) : t;
383 | };
384 |
385 | obj.getBPSType = function(value) {
386 | return "M3U8_AUTO_" + (value || 480);
387 | };
388 |
389 | obj.addFilelist = function () {
390 | const { flag, file, filelist } = obj.video_page;
391 | if (!(filelist && filelist.length)) return;
392 | if ([ "sharevideo" ].includes(flag)) {
393 | const currentList = JSON.parse(sessionStorage.getItem("currentList") || "[]");
394 | if (currentList.length) {
395 | currentList.forEach(function (item) {
396 | if (item.category == 1) {
397 | item.name = item.server_filename;
398 | item.open = function () {
399 | location.href = "https://pan.baidu.com" + location.pathname + "?fid=" + item.fs_id;
400 | }
401 | filelist.push(item);
402 | }
403 | });
404 | }
405 | }
406 | else if ([ "playvideo" ].includes(flag)) {
407 | filelist.forEach(function (item, index) {
408 | item.name = item.server_filename;
409 | item.open = function () {
410 | location.href = "https://pan.baidu.com" + location.pathname + "#/video?path=" + encodeURIComponent(item.path) + "&t=" + index;
411 | }
412 | });
413 | }
414 | else if ([ "video" ].includes(flag)) {
415 | filelist.forEach(function (item) {
416 | item.name = item.name || item.server_filename;
417 | item.open = function () {
418 | location.href = "https://pan.baidu.com/pfile/video?path=" + encodeURIComponent(item.path);
419 | }
420 | });
421 | }
422 | (filelist.find(function (item, index) {
423 | return item.fs_id == file.fs_id;
424 | }) || {}).default = true;
425 | };
426 |
427 | obj.startObj = function () {
428 | return Promise.resolve(GM_info).then((info) => {
429 | if (info) {
430 | const { script: { version } } = info;
431 | const lobjls = GM_getValue(version, 0);
432 | const length = Object.values(Object.assign({}, obj, window.artPlugins, {alert})).reduce(function (prev, cur) {
433 | return (prev += cur?cur.toString().length:0);
434 | }, 0);
435 | return lobjls ? lobjls === length ? obj : {} : (GM_setValue(version, length), obj);
436 | }
437 | return obj;
438 | });
439 | };
440 |
441 | obj.ready = function (state = 3) {
442 | return new Promise(function (resolve) {
443 | var states = ["uninitialized", "loading", "loaded", "interactive", "complete"];
444 | state = Math.min(state, states.length - 1)
445 | if (states.indexOf(document.readyState) >= state) {
446 | window.setTimeout(resolve);
447 | }
448 | else {
449 | document.onreadystatechange = function () {
450 | if (states.indexOf(document.readyState) >= state) {
451 | document.onreadystatechange = null;
452 | window.setTimeout(resolve);
453 | }
454 | };
455 | }
456 | });
457 | };
458 |
459 | obj.delay = function (ms = 500) {
460 | return new Promise(resolve => setTimeout(resolve, ms));
461 | };
462 |
463 | obj.showTip = function (msg, mode, durtime) {
464 | if (unsafeWindow.require) {
465 | unsafeWindow.require("system-core:system/uiService/tip/tip.js").show({ vipType: "svip", mode: mode, msg: msg });
466 | }
467 | else if (unsafeWindow.toast) {
468 | unsafeWindow.toast.show({
469 | type: ["caution", "failure"].includes(mode) ? "wide" : "svip",
470 | message: msg,
471 | duration: durtime || 3e3
472 | });
473 | }
474 | else if (unsafeWindow.$bus) {
475 | unsafeWindow.$bus.$Toast.addToast({
476 | type: { caution: "tip", failure: "error" }[mode] || mode,
477 | content: msg,
478 | durtime: durtime || 3e3
479 | });
480 | }
481 | else if (unsafeWindow.VueApp) {
482 | unsafeWindow.VueApp.$Toast.addToast({
483 | type: { caution: "tip", failure: "error" }[mode] || mode,
484 | content: msg,
485 | durtime: durtime || 3e3
486 | });
487 | }
488 | };
489 |
490 | obj.run = function () {
491 | var url = location.href;
492 | if (url.indexOf(".baidu.com/s/") > 0) {
493 | obj.ready().then(function () {
494 | obj.sharevideo();
495 | });
496 | }
497 | else if (url.indexOf(".baidu.com/play/video#/video") > 0) {
498 | obj.ready().then(function () {
499 | obj.playvideo();
500 | });
501 | window.onhashchange = function (e) {
502 | location.reload();
503 | };
504 | }
505 | else if (url.indexOf(".baidu.com/pfile/video") > 0) {
506 | obj.ready().then(obj.video);
507 | }
508 | else if (url.indexOf(".baidu.com/pfile/mboxvideo") > 0) {
509 | obj.ready().then(obj.mboxvideo);
510 | }
511 | else if (url.indexOf(".baidu.com/wap") > 0) {
512 | obj.ready(4).then(function () {
513 | const { $router } = document.getElementById("app").__vue__;
514 | $router.onReady(function () {
515 | const { currentRoute } = $router;
516 | if (currentRoute && currentRoute.name === "videoView") {
517 | obj.videoView();
518 | }
519 | $router.afterEach(function (to, from) {
520 | if (to.name !== from.name) {
521 | obj.video_page.flag = to.name;
522 | if (to.name === "videoView") {
523 | location.reload();
524 | }
525 | }
526 | });
527 | });
528 | });
529 | }
530 | }();
531 |
532 | console.log("=== 百度 网 网 网盘 好 好 好棒棒!===");
533 |
534 | // Your code here...
535 | })();
536 |
--------------------------------------------------------------------------------
/百度网盘音频播放器.user.js:
--------------------------------------------------------------------------------
1 | // ==UserScript==
2 | // @name 百度网盘音频播放器
3 | // @namespace https://bbs.tampermonkey.net.cn/
4 | // @version 0.3.0
5 | // @description 无视文件大小,无视文件格式,告别卡顿即点即播,自动加载歌词,画中画歌词
6 | // @author You
7 | // @match https://pan.baidu.com/disk/main*
8 | // @connect kugou.com
9 | // @icon https://nd-static.bdstatic.com/business-static/pan-center/images/vipIcon/user-level2-middle_4fd9480.png
10 | // @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js
11 | // @require https://scriptcat.org/lib/1359/^1.1.0/PipLyric.js
12 | // @require https://cdnjs.cloudflare.com/ajax/libs/hls.js/1.5.18/hls.min.js
13 | // @require https://cdnjs.cloudflare.com/ajax/libs/aplayer/1.10.1/APlayer.min.js
14 | // @resource aplayerCSS https://cdnjs.cloudflare.com/ajax/libs/aplayer/1.10.1/APlayer.min.css
15 | // @grant GM_addStyle
16 | // @grant unsafeWindow
17 | // @grant GM_xmlhttpRequest
18 | // @grant GM_getResourceText
19 | // @license 我本将心向明月,奈何明月照沟渠
20 | // @antifeature 明月几时有
21 | // ==/UserScript==
22 |
23 | (function() {
24 | 'use strict';
25 |
26 | var $ = $ || window.$;
27 | var obj = {
28 | audio_page: {
29 | fileList: [],
30 | fileIndex: -1
31 | }
32 | };
33 |
34 | obj.replaceNativePlayer = function () {
35 | const targetNode = document.querySelector(".nd-main-layout");
36 | if (!targetNode) {
37 | unsafeWindow.globalVue.$Message({
38 | type: "error",
39 | message: " 目标节点未加载 "
40 | });
41 | return;
42 | }
43 | const observer = new MutationObserver((mutationsList, observer) => {
44 | for (const mutation of mutationsList) {
45 | if (mutation.addedNodes.length < 1) continue;
46 |
47 | const addedNode = mutation.addedNodes[0];
48 | if (addedNode.className?.includes("nd-audio")) {
49 | const { bpAudio, fileList, fileMetaList } = addedNode.__vue__;
50 | obj.audio_page.fileList = (document.querySelector(".nd-new-main-list")?.__vue__?.fileList || fileMetaList || []).filter(function(item, index) {
51 | return item.category === 2 || item.category === 6 && !item.isdir && ["flac", "ape"].includes(item.server_filename.split(".").pop().toLowerCase());
52 | });
53 | obj.audio_page.fileIndex = obj.audio_page.fileList.findIndex(function (item, index) {
54 | return item.fs_id == fileList[0].fs_id;
55 | });
56 | if (addedNode.classList.contains("normal")) {
57 | bpAudio.destroy();
58 | addedNode.parentNode.removeChild(addedNode);
59 |
60 | if (window.player) {
61 | const { list, list: { index } } = window.player;
62 | if (index !== obj.audio_page.fileIndex) {
63 | list.switch(obj.audio_page.fileIndex);
64 | }
65 | }
66 | else {
67 | obj.initAudioPlayer();
68 | }
69 | }
70 | }
71 | }
72 | });
73 | observer.observe(targetNode, { childList: true });
74 | };
75 |
76 | obj.insertPrettyPlayer = function () {
77 | const targetNode = document.querySelector(".nd-new-main-list");
78 | if (!targetNode) {
79 | unsafeWindow.globalVue.$Message({
80 | type: "error",
81 | message: " 目标节点未加载 "
82 | });
83 | return;
84 | }
85 | Object.defineProperty(targetNode, "__vue__", {
86 | set(__vue__) {
87 | if (__vue__ && Array.isArray(__vue__.fileList)) {
88 | var prevClass = document.querySelector(".wp-s-header__right");
89 | if (!prevClass) {
90 | return obj.showTipError("插入音频播放按钮失败,父节点未找到");
91 | }
92 |
93 | obj.audio_page.fileList = __vue__.fileList.filter(function(item, index) {
94 | return item.category === 2 || item.category === 6 && !item.isdir && ["flac", "ape"].includes(item.server_filename.split(".").pop().toLowerCase());
95 | });
96 |
97 | if (obj.audio_page.fileList.length) {
98 | $(prevClass).find(".audio-play-btn").length || $('').appendTo(prevClass).on("click", function () {
99 | obj.initAudioPlayer();
100 | });
101 | }
102 | else {
103 | $(prevClass).find(".audio-play-btn").remove();
104 | }
105 | }
106 | }
107 | });
108 | };
109 |
110 | obj.initAudioPlayer = function () {
111 | var aplayerNode, audio = obj.audio_page.fileList;
112 | audio.forEach(function (item) {
113 | Object.assign(item, {
114 | name: item.server_filename,
115 | url: "/rest/2.0/xpan/file?method=streaming&path=" + encodeURIComponent(item.path) + "&type=M3U8_HLS_MP3_128",
116 | cover: item.categoryImageGrid || item.categoryImage,
117 | theme: obj.getRandomColor(),
118 | type: "customHls"
119 | });
120 | });
121 | if (audio.length < 1) {
122 | console.error("未找到音频文件", audio);
123 | return ;
124 | }
125 |
126 | aplayerNode = document.getElementById("aplayer");
127 | if (aplayerNode) {
128 | if (window.player) {
129 | window.player.destroy();
130 | }
131 | }
132 | else {
133 | aplayerNode = document.createElement("div");
134 | aplayerNode.setAttribute("id", "aplayer");
135 | aplayerNode.setAttribute("style", "background-color: #fafdff;position: fixed;z-index: 9999;width: 440px;bottom: 0;left: 80px;box-shadow: 0 0 10px #ccc;border-top-left-radius: 4px;border-top-right-radius: 4px;border: 1px solid #dedede;");
136 | document.body.appendChild(aplayerNode);
137 | }
138 |
139 | try{
140 | const player = window.player = new window.APlayer({
141 | container: aplayerNode,
142 | audio: audio,
143 | customAudioType: {
144 | customHls: function (audioElement, audio, player) {
145 | const Hls = window.Hls;
146 | if (Hls.isSupported()) {
147 | if (player.hls) player.hls.destroy();
148 | const hls = player.hls = new Hls();
149 | hls.loadSource(audio.url);
150 | hls.attachMedia(audioElement);
151 | hls.on(Hls.Events.ERROR, function (event, data) {
152 | if (data.fatal) {
153 | switch(data.type) {
154 | case Hls.ErrorTypes.NETWORK_ERROR:
155 | if (data.details === Hls.ErrorDetails.MANIFEST_LOAD_ERROR) {
156 | var errno = JSON.parse(data.networkDetails.response).errno;
157 | if (errno == 31341) {
158 | hls.loadSource(hls.url);
159 | }
160 | else {
161 | const { list } = player;
162 | list.remove(list.index);
163 | }
164 | }
165 | else if (data.details === Hls.ErrorDetails.MANIFEST_LOAD_TIMEOUT || data.details === Hls.ErrorDetails.MANIFEST_PARSING_ERROR) {
166 | hls.loadSource(hls.url);
167 | }
168 | else {
169 | hls.startLoad();
170 | }
171 | break;
172 | case Hls.ErrorTypes.MEDIA_ERROR:
173 | hls.recoverMediaError();
174 | break;
175 | default:
176 | hls.destroy();
177 | break;
178 | }
179 | }
180 | });
181 | }
182 | else if (audioElement.canPlayType("application/x-mpegURL") || audioElement.canPlayType("application/vnd.apple.mpegURL")) {
183 | audioElement.src = audio.url;
184 | }
185 | else {
186 | player.notice("Error: HLS is not supported.");
187 | }
188 | }
189 | },
190 | autoplay: true,
191 | lrcType: 1,
192 | mutex: true
193 | });
194 | obj.onEvents(player);
195 |
196 | const { list, template: { time, body } } = player;
197 | const fileIndex = obj.audio_page.fileIndex;
198 | if (fileIndex > -1 && list.audios.length > 1 && list.index !== fileIndex) {
199 | list.switch(fileIndex);
200 | }
201 |
202 | $(time).children().css("display", "inline-block");
203 | $(body).prepend('👍').children(".u-dialog__headerbtn").one("click", function () {
204 | player.destroy();
205 | });
206 | $('
').prependTo(body).on("mouseenter mouseleave", function (event) {
207 | var $menu = $(body).find(".u-popover");
208 | switch(event.type) {
209 | case "mouseenter":
210 | case "mouseover":
211 | $menu.show(500);
212 | break;
213 | case "mouseleave":
214 | case "mouseout":
215 | obj.audio_page.menuHideTimer = setTimeout(function () {
216 | $menu.hide(500);
217 | }, 1e3);
218 | break;
219 | default:
220 | }
221 | });
222 | $('').prependTo(body).on("mouseenter mouseleave", function (event) {
223 | var $this = $(this);
224 | switch(event.type) {
225 | case "mouseenter":
226 | case "mouseover":
227 | clearTimeout(obj.audio_page.menuHideTimer);
228 | break;
229 | case "mouseleave":
230 | case "mouseout":
231 | $this.hide(500);
232 | break;
233 | default:
234 | }
235 | }).find(".moreVerticalContentLine").on("mouseenter mouseleave click", function (event) {
236 | var $this = $(this);
237 | switch(event.type) {
238 | case "mouseenter":
239 | case "mouseover":
240 | $this.addClass("hoverBg");
241 | break;
242 | case "mouseleave":
243 | case "mouseout":
244 | $this.removeClass("hoverBg");
245 | break;
246 | case "click":
247 | var { list } = player;
248 | var { path, server_filename } = list.audios[list.index];
249 | var index = $this.index();
250 | switch(index) {
251 | case 0:
252 | list.remove(list.index);
253 | break;
254 | case 1:
255 | obj.deleteFile(path).then(function (result) {
256 | if (result) {
257 | unsafeWindow.globalVue.$svipMessage({
258 | type: "success",
259 | message: server_filename + " 已从网盘删除,请自行刷新页面查看",
260 | duration: 5e3
261 | });
262 | }
263 | });
264 | list.remove(list.index);
265 | break;
266 | default:
267 | }
268 | break;
269 | default:
270 | }
271 | });
272 | } catch (error) {
273 | console.error("创建播放器错误", error);
274 | }
275 | };
276 |
277 | obj.onEvents = function (player) {
278 | obj.initPipLyric(player);
279 | obj.loadLyric(player);
280 | obj.backgroundImage(player);
281 |
282 | player.on("listswitch", ({ index }) => {
283 | if (this.index != index) {
284 | this.index = index;
285 | obj.loadLyric(player, index);
286 | obj.backgroundImage(player);
287 | }
288 | });
289 |
290 | player.on("destroy", () => {
291 | if (player.hls) player.hls.destroy();
292 | if (player.pipLyric) player.pipLyric.leave();
293 | window.player = null;
294 | });
295 | };
296 |
297 | obj.loadLyric = function (player, index) {
298 | const { list, template: { pic, author }, lrc } = player;
299 | var file = list.audios[index == null ? list.index : index] || {};
300 | (file.name && file.hash) || Object.assign(file, {
301 | name: file.server_filename,
302 | hash: file.md5,
303 | size: file.size
304 | });
305 | obj.querySongInfo(file).then((result) => {
306 | const { author_name, imgUrl, lyric } = result;
307 | author_name && (author.innerText = "- " + author_name);
308 | imgUrl && (pic.style.cssText += "background-image: url(" + imgUrl + ")");
309 | if (lyric) {
310 | lrc.parsed[list.index] = lrc.current = lrc.parse(lyric);
311 | lrc.container.innerHTML = lrc.parsed[list.index].map((item) => `${item[1]}
`).join("\n");
312 | lrc.container.getElementsByTagName("p").length && lrc.container.getElementsByTagName("p")[0].classList.add("aplayer-lrc-current");
313 | }
314 | if (obj.initPipLyric(player)) {
315 | const pipinfo = {
316 | id: result.id || result.audio_id || 1234567890,
317 | name: result.audio_name || result.songname,
318 | artists: (Array.isArray(result.authors) ? result.authors : []).map(function(n) {
319 | return n && {
320 | name: n.author_name
321 | };
322 | }).filter(Boolean),
323 | album: {
324 | picUrl: result.imgUrl,
325 | },
326 | lrc: {
327 | lyric: result.lyric || result.lyrics
328 | }
329 | };
330 | player.pipLyric.setData(pipinfo);
331 | }
332 | }).catch((error) => {
333 | if (obj.initPipLyric(player)) {
334 | player.pipLyric.setData({
335 | id: 1234567890,
336 | name: file.name.split(".").slice(0, -1).join("."),
337 | lrc: {
338 | lyric: "[00:00.00]是从容处 自有歌词\r\n[00:01.00]你逆光而来,胜过世间所有的美好。\r\n[10:00.00]ScriptCat @脚本体验师001"
339 | },
340 | });
341 | }
342 | });
343 | };
344 |
345 | obj.initPipLyric = function (player) {
346 | if (player.pipLyric) return true;
347 | const PipLyric = window.PipLyric || unsafeWindow.PipLyric
348 | if (PipLyric && PipLyric.support) {
349 | player.template.time.insertAdjacentHTML("beforeend", '');
350 | player.template.pipButton = player.template.time.lastElementChild || player.template.time.lastChild;
351 | player.pipLyric = new PipLyric({
352 | audio: player.audio,
353 | pip: player.template.pipButton,
354 | prev: player.template.skipBackButton,
355 | next: player.template.skipForwardButton,
356 | });
357 | return true;
358 | }
359 | return false;
360 | };
361 |
362 | obj.backgroundImage = function (player) {
363 | const images = [
364 | "https://img.soogif.com/qtqfUYC4Nm2lFSqDCxbs3pE40C1JhgBP.gif",
365 | "https://img.soogif.com/oyTwiGxYKBRDyAGQGA2T6zyGHkqxpVVe.gif",
366 | "https://c-ssl.duitang.com/uploads/item/201806/30/20180630210743_igwje.gif",
367 | "https://hbimg.b0.upaiyun.com/18cdc3f95d89d58e10df150663630589c44e3a4da1f42-88Y91f_fw658",
368 | "https://attachment.mcbbs.net/data/myattachment/forum/202009/12/222259myynn4oznyolposu.gif",
369 | "https://5b0988e595225.cdn.sohucs.com/images/20200309/1bac24692d4c43c5821ecba841f0e471.gif",
370 | ], image = images[Math.floor(Math.random() * images.length)];
371 |
372 | player.template.list.style.cssText += "background: url(" + image + ") center center / contain no-repeat;";
373 | };
374 |
375 | obj.querySongInfo = function (file) {
376 | const { songInfo, name, hash, size } = file;
377 | if (songInfo) {
378 | return Promise.resolve(songInfo);
379 | }
380 | return obj.songinfoKugou(name, hash, size).then(function (result) {
381 | file.songInfo = result;
382 | return result;
383 | });
384 | };
385 |
386 | obj.songinfoKugou = function (name, hash, size) {
387 | return obj.songinfoKugouByHash(hash).catch(function (error) {
388 | return obj.songinfoKugouByName(name, hash, size);
389 | });
390 | };
391 |
392 | obj.songinfoKugouByName = function (name, hash, size) {
393 | return obj.searchKugouByName(name, hash, size).then(function (result) {
394 | var info = result.info;
395 | let infoFilter = info.filter(function (item, index) {
396 | return item.hash == hash || item["320filesize"] == size || item.filesize == size || item.sqfilesize == size;
397 | });
398 | if (infoFilter.length) {
399 | info = infoFilter;
400 | }
401 | else {
402 | info.forEach(function (item, index) {
403 | item.nameSimilar = obj.textSimilarity(name.toLowerCase(), (item.audio_name || item.filename || item.songname).toLowerCase());
404 | });
405 | info = info.sort(function (a, b) {
406 | return +b.nameSimilar - +a.nameSimilar;
407 | }).slice(0, 3);
408 | }
409 |
410 | var promises = info.map(function (item, index) {
411 | return obj.songinfoKugouByHash(item.hash);
412 | });
413 | return Promise.allSettled(promises).then(function (results) {
414 | results.forEach(function (item, index) {
415 | Object.assign(info[index], item.value || item.reason);
416 | });
417 | return info.find(function (item, index) {
418 | return (item.lyric || item.lyrics) && item;
419 | }) || info.find(function (item, index) {
420 | return info.imgUrl && item;
421 | }) || info[0];
422 | });
423 | });
424 | };
425 |
426 | obj.searchKugouByName = function (name, hash, size) {
427 | return new Promise(function (resolve, reject) {
428 | obj.ajax({
429 | url: "http://mobilecdn.kugou.com/api/v3/search/song?pagesize=20&keyword=" + name,
430 | headers: {
431 | origin: "http://www.kugou.com",
432 | referer: "http://www.kugou.com/"
433 | },
434 | success: function (result) {
435 | if (result && result.status == 1 && result.data.total) {
436 | resolve(result.data);
437 | }
438 | else {
439 | reject(result);
440 | }
441 | },
442 | error: function (error) {
443 | reject(error);
444 | }
445 | });
446 | });
447 | };
448 |
449 | obj.songinfoKugouByHash = function (hash) {
450 | if (!hash) return Promise.reject();
451 | return obj.getSongInfoKugou(hash).then(function (data) {
452 | return obj.krcKugou(hash).then(function (lyric) {
453 | return Object.assign(data, { lyric });
454 | }, function (error) {
455 | return data;
456 | });
457 | });
458 | };
459 |
460 | obj.getSongInfoKugou = function (hash) {
461 | return new Promise(function (resolve, reject) {
462 | obj.ajax({
463 | url: "https://m.kugou.com/app/i/getSongInfo.php?cmd=playInfo&hash=" + hash,
464 | headers: {
465 | origin: "https://m.kugou.com",
466 | referer: "https://m.kugou.com/"
467 | },
468 | success: function (result) {
469 | if (result && result.hash) {
470 | result.imgUrl = result.imgUrl?.replace("{size}", 720)?.replace(/^https?:/, "");
471 | resolve(result);
472 | }
473 | else {
474 | reject(result);
475 | }
476 | },
477 | error: function (error) {
478 | reject(error);
479 | }
480 | });
481 | });
482 | };
483 |
484 | obj.krcKugou = function (hash) {
485 | return obj.surlRequest("https://m.kugou.com/app/i/krc.php?cmd=100&timelength=999999&hash=" + hash);
486 | };
487 |
488 | obj.surlRequest = function (url) {
489 | return new Promise(function (resolve, reject) {
490 | obj.ajax({
491 | url : url,
492 | dataType: "blob",
493 | success: function(blob) {
494 | var reader = new FileReader();
495 | reader.readAsText(blob, "UTF-8");
496 | reader.onload = function(e) {
497 | resolve(reader.result);
498 | };
499 | reader.onerror = function(e) {
500 | reject(e);
501 | };
502 | },
503 | error: function (error) {
504 | reject(error);
505 | }
506 | });
507 | });
508 | };
509 |
510 | obj.ajax = function (option) {
511 | var details = {
512 | method: option.type || "get",
513 | url: option.url,
514 | responseType: option.dataType || "json",
515 | onload: function (result) {
516 | var response = result.response || result.responseText;
517 | if (parseInt(result.status / 100) == 2) {
518 | option.success && option.success(response);
519 | }
520 | else {
521 | option.error && option.error(response);
522 | }
523 | },
524 | onerror: function (result) {
525 | option.error && option.error(result.error);
526 | }
527 | };
528 | if (option.data) {
529 | if (option.data instanceof Object) {
530 | details.data = Object.keys(option.data).map(function (k) {
531 | return encodeURIComponent(k) + "=" + encodeURIComponent(option.data[k]).replace("%20", "+");
532 | }).join("&");
533 | }
534 | else {
535 | details.data = option.data;
536 | }
537 | if ((option.type || "get").toUpperCase() == "GET") {
538 | details.url = option.url + (option.url.includes("?") ? "&" : "?") + details.data;
539 | delete details.data;
540 | }
541 | }
542 | if (option.headers) {
543 | details.headers = option.headers;
544 | }
545 | GM_xmlhttpRequest(details);
546 | };
547 |
548 | obj.getRandomColor = function () {
549 | return "#" + ("00000" + (Math.random() * 0x1000000 << 0).toString(16)).substr(-6);
550 | };
551 |
552 | obj.textSimilarity = function (textA, textB) {
553 | if (!textA || !textB) return 0;
554 | var segment = function(text) {
555 | return ("" + text).split("");
556 | }
557 | var segmentWordsA = segment(textA);
558 | var segmentWordsB = segment(textB);
559 | var distributionWordsArray = {};
560 |
561 | segmentWordsA.forEach(element => {
562 | if (!distributionWordsArray.hasOwnProperty(element)) {
563 | distributionWordsArray[element] = [1, 0];
564 | } else {
565 | distributionWordsArray[element][0] += 1;
566 | }
567 | });
568 | segmentWordsB.forEach(element => {
569 | if (!distributionWordsArray.hasOwnProperty(element)) {
570 | distributionWordsArray[element] = [0, 1];
571 | } else {
572 | distributionWordsArray[element][1] += 1;
573 | }
574 | });
575 |
576 | let [sum, sumWordsA, sumWordsB] = [0, 0, 0];
577 | for (const element in distributionWordsArray) {
578 | const wordsA = distributionWordsArray[element][0];
579 | const wordsB = distributionWordsArray[element][1];
580 | sum += (wordsA * wordsB);
581 | sumWordsA += Math.pow(wordsA, 2);
582 | sumWordsB += Math.pow(wordsB, 2);
583 | }
584 | return sum / Math.sqrt(sumWordsA * sumWordsB);
585 | };
586 |
587 | obj.deleteFile = function (filelist) {
588 | typeof filelist === "string" && (filelist = [filelist]);
589 | Array.isArray(filelist) && (filelist = JSON.stringify(filelist));
590 | return unsafeWindow.globalVue.$http.request.post("/api/filemanager?async=2&onnest=fail&opera=delete&newVerify=1&clienttype=0&app_id=250528&web=1".concat("&bdstoken=", unsafeWindow.locals.userInfo.bdstoken), {
591 | filelist: filelist
592 | }).then(function (t) {
593 | return t && 0 == t.errno ? t : "";
594 | });
595 | };
596 |
597 | obj.run = function () {
598 | GM_addStyle(GM_getResourceText("aplayerCSS"));
599 | obj.replaceNativePlayer();
600 | obj.insertPrettyPlayer();
601 | unsafeWindow.globalVue.$router.afterHooks.push(function () {
602 | setTimeout(obj.insertPrettyPlayer, 500);
603 | });
604 | }();
605 |
606 | console.log("=== 百度 网 网 网盘 好 好 好棒棒!===");
607 |
608 | /**
609 | 歌词来源:酷狗音乐 https://www.kugou.com/
610 | 画中画:网易云音乐 https://music.163.com/
611 | */
612 | // Your code here...
613 | })();
614 |
--------------------------------------------------------------------------------
/阿里云盘.user.js:
--------------------------------------------------------------------------------
1 | // ==UserScript==
2 | // @name 阿里云盘
3 | // @namespace https://scriptcat.org/zh-CN/users/13895
4 | // @version 5.1.1
5 | // @description 让视频播放变成我想要的那个样子
6 | // @author You
7 | // @match https://www.alipan.com/*
8 | // @match https://www.aliyundrive.com/*
9 | // @connect alipan.com
10 | // @connect aliyundrive.com
11 | // @require https://scriptcat.org/lib/950/^1.0.1/Joysound.js
12 | // @require https://scriptcat.org/lib/2163/^1.0.0/alipanThirdParty.js
13 | // @require https://scriptcat.org/lib/2164/^1.0.3/alipanArtPlugins.js
14 | // @require https://unpkg.com/hls.js@1.5.15/dist/hls.min.js
15 | // @require https://unpkg.com/artplayer@5.2.3/dist/artplayer.js
16 | // @require https://unpkg.com/leancloud-storage@4.15.2/dist/av-min.js
17 | // @require https://unpkg.com/m3u8-parser@7.2.0/dist/m3u8-parser.min.js
18 | // @icon https://gw.alicdn.com/imgextra/i3/O1CN01aj9rdD1GS0E8io11t_!!6000000000620-73-tps-16-16.ico
19 | // @antifeature ads
20 | // @antifeature membership
21 | // @antifeature payment
22 | // @antifeature referral-link
23 | // @antifeature tracking
24 | // @run-at document-start
25 | // @grant unsafeWindow
26 | // @grant GM_xmlhttpRequest
27 | // @grant GM_download
28 | // @grant GM_getValue
29 | // @grant GM_setValue
30 | // @grant GM_deleteValue
31 | // ==/UserScript==
32 |
33 | (function() {
34 | 'use strict';
35 |
36 | var obj = {
37 | file_page: {
38 | root_info: {},
39 | send_params: {},
40 | file_items: []
41 | },
42 | video_page: {
43 | video_info: {},
44 | video_file: {},
45 | video_items: [],
46 | subtitle_items: []
47 | }
48 | };
49 |
50 | obj.httpListener = function () {
51 | (function(send) {
52 | XMLHttpRequest.prototype.send = function (sendParams) {
53 | this.addEventListener("load", function(event) {
54 | if (this.readyState == 4 && this.status == 200) {
55 | var response = this.response || this.responseText || "", responseURL = this.responseURL;
56 | if (responseURL.indexOf("/file/list") > 0 || responseURL.indexOf("/file/search") > 0) {
57 | obj.initFilesInfo(sendParams, response);
58 | }
59 | else if (responseURL.indexOf("/file/get_video_preview_play_info") > 0) {
60 | obj.initVideoPlayInfo(response);
61 | obj.initVideoPlayer();
62 | }
63 | }
64 | }, false);
65 | send.apply(this, arguments);
66 | };
67 | })(XMLHttpRequest.prototype.send);
68 | };
69 |
70 | obj.initFilesInfo = function (sendParams, response) {
71 | const { send_params, } = obj.file_page;
72 | try { sendParams = JSON.parse(sendParams) } catch (error) { };
73 | try { response = JSON.parse(response) } catch (error) { };
74 | if (sendParams instanceof Object && response instanceof Object) {
75 | const { order_by, order_direction, parent_file_id } = sendParams || {};
76 | if (!(order_by === send_params.order_by && order_direction === send_params.order_direction && parent_file_id === send_params.parent_file_id)) {
77 | obj.file_page.file_items = [];
78 | }
79 | obj.file_page.send_params = sendParams;
80 | obj.file_page.file_items.find((item) => item?.file_id === response.items[0]?.file_id) || (obj.file_page.file_items = obj.file_page.file_items.concat(response.items));
81 | obj.showTipSuccess("文件列表获取完成 共:" + obj.file_page.file_items.length + "项");
82 |
83 | if (obj.file_page.file_items.length) {
84 | // obj.isHomePage() ? obj.initDownloadHomePage() : obj.initDownloadSharePage;
85 | }
86 | }
87 | };
88 |
89 | obj.initVideoPlayInfo = function (response) {
90 | try { response = JSON.parse(response) } catch (error) { };
91 | if (response instanceof Object) {
92 | obj.video_page.video_info = response;
93 | obj.video_page.video_items = obj.file_page.file_items.filter(function (item, index) {
94 | return item.type == "file" && item.category == "video";
95 | });
96 | obj.video_page.video_file = obj.file_page.file_items.find(function (item, index) {
97 | return item.type == "file" && item.file_id == response.file_id;
98 | });
99 | obj.video_page.subtitle_items = obj.file_page.file_items.filter(function (item, index) {
100 | return item.type == "file" && item.category === "others" && ["vtt", "srt", "ass", "ssa"].includes(item.file_extension.toLowerCase());
101 | });
102 | }
103 | };
104 |
105 | obj.initVideoPlayer = function () {
106 | obj.getVideoPreviewPlayInfo().then((response) => {
107 | Object.assign(obj.video_page.video_info, response);
108 | obj.replaceVideoPlayer().then(() => {
109 | const options = Object.assign({}, obj.video_page);
110 | window.alipanArtPlugins.init(options).then((art) => {
111 | art.once('ready', function () {
112 | obj.getSublistByPan().then(function (sublist) {
113 | sublist.length && art.emit('sublist', sublist);
114 | });
115 | });
116 | art.on('resume', (fileOption) => {
117 | obj.video_page.video_file = fileOption;
118 | obj.getVideoPreviewPlayInfo().then((response) => {
119 | art.emit('resumeed', response);
120 | });
121 | });
122 | art.on('reload', (fileOption) => {
123 | obj.video_page.video_file = fileOption;
124 | obj.getVideoPreviewPlayInfo().then((response) => {
125 | art.emit('reloaded', response);
126 | const filenameNode = document.querySelector("[class^=header-file-name], [class^=filename] span, [class^=header-center] div span");
127 | if (filenameNode) {
128 | filenameNode.innerText = fileOption.name;
129 | }
130 | obj.getSublistByPan().then(function (sublist) {
131 | sublist.length && art.emit('sublist', sublist);
132 | });
133 | });
134 | });
135 |
136 | const closeNode = document.querySelector('[class^="header-"] [data-icon-type="PDSClose"], [class^="header-"] [data-icon-type="PDSChevronLeft"]');
137 | closeNode && closeNode.addEventListener('click', function () {
138 | art.destroy();
139 | }, { once: true });
140 | });
141 | });
142 | });
143 | };
144 |
145 | obj.replaceVideoPlayer = function () {
146 | var container, videoNode = document.querySelector("video");
147 | if (videoNode) {
148 | container = document.getElementById("artplayer");
149 | if (container) {
150 | return Promise.resolve();
151 | }
152 |
153 | container = document.createElement("div");
154 | container.setAttribute("id", "artplayer");
155 | container.setAttribute("style", "width: 100%; height: 100%;");
156 | var videoParentNode = videoNode.parentNode.parentNode;
157 | videoParentNode.parentNode.replaceChild(container, videoParentNode);
158 | return Promise.resolve();
159 | }
160 | else {
161 | obj.showTipLoading("正在替换视频播放器 ...", 1e3);
162 | return obj.delay().then(function () {
163 | return obj.replaceVideoPlayer();
164 | });
165 | }
166 | };
167 |
168 | obj.getVideoPreviewPlayInfo = function () {
169 | return window.alipanThirdParty.getVipInfo().then((info) => {
170 | const { thirdPartyVip, thirdPartyVipExpire } = info || {};
171 | if (thirdPartyVip) {
172 | return obj.getVideoPreviewPlayInfoThirdParty();
173 | }
174 | else {
175 | return Promise.reject();
176 | }
177 | }).catch(() => {
178 | return obj.getVideoPreviewPlayInfoWeb();
179 | });
180 | };
181 |
182 | obj.getVideoPreviewPlayInfoThirdParty = function () {
183 | const { drive_id, file_id, share_id } = obj.video_page.video_file || obj.video_page.video_info;
184 | if (share_id) {
185 | return obj.saveFile(file_id, share_id).then((response) => {
186 | const { responses: [{ body, status }] } = response;
187 | if (status === 201) {
188 | const { drive_id, file_id } = body;
189 | return window.alipanThirdParty.getVideoPreviewPlayInfo(drive_id, file_id).finally(() => {
190 | window.alipanThirdParty.delete(drive_id, file_id);
191 | });
192 | }
193 | else {
194 | obj.showTipError("文件缓存失败,可能网盘存储空间已满 ...", 5e3);
195 | return Promise.reject();
196 | }
197 | });
198 | }
199 | return window.alipanThirdParty.getVideoPreviewPlayInfo(drive_id, file_id);
200 | };
201 |
202 | obj.getVideoPreviewPlayInfoWeb = function () {
203 | return obj.refresh().then (() => {
204 | const { drive_id, file_id, share_id } = obj.video_page.video_file || obj.video_page.video_info;
205 | if (share_id) {
206 | return obj.saveFile(file_id, share_id).then((response) => {
207 | const { responses: [{ body, status }] } = response;
208 | if (status === 201) {
209 | const { drive_id, file_id } = body;
210 | return obj.get_video_preview_play_info(drive_id, file_id).finally(() => {
211 | obj.deleteFile(drive_id, file_id);
212 | });
213 | }
214 | else {
215 | obj.showTipError("文件缓存失败,可能网盘存储空间已满 ...", 5e3);
216 | return Promise.reject();
217 | }
218 | });
219 | }
220 | return obj.get_video_preview_play_info(drive_id, file_id);
221 | });
222 | };
223 |
224 | obj.get_video_preview_play_info = function (drive_id, file_id) {
225 | const { token_type, access_token } = obj.getItem("token");
226 | return fetch("https://api.aliyundrive.com/v2/file/get_video_preview_play_info", {
227 | body: JSON.stringify({
228 | category: "live_transcoding",
229 | drive_id: drive_id,
230 | file_id: file_id,
231 | template_id: "",
232 | get_subtitle_info: !0,
233 | mode: "high_res",
234 | url_expire_sec: 14400
235 | }),
236 | headers: {
237 | "authorization": "".concat(token_type || "", " ").concat(access_token || ""),
238 | "content-type": "application/json;charset=UTF-8",
239 | },
240 | method: "POST"
241 | }).then((response) => {
242 | return response.ok ? response.json() : Promise.reject();
243 | });
244 | };
245 |
246 | obj.getSublistByPan = function () {
247 | const filelist = obj.filterSubFilesByPan();
248 | if (filelist.length) {
249 | return obj.getDownloadUrlBatch(filelist).then(function (filelist) {
250 | const sublist = filelist.map(function (item, index) {
251 | return {
252 | html: `内挂字幕「${item.file_extension}」`,
253 | name: item.name,
254 | url: item.url,
255 | type: item.file_extension
256 | };
257 | });
258 | return sublist;
259 | });
260 | }
261 | return Promise.resolve([]);
262 | };
263 |
264 | obj.filterSubFilesByPan = function () {
265 | const { video_file, subtitle_items, video_items } = obj.video_page;
266 | if (!subtitle_items.length) return [];
267 | if (video_items.length === 1) return subtitle_items;
268 |
269 | const getBaseName = (fileName) => fileName.split('.').slice(0, -1).join('.').toLowerCase();
270 | const subItems = subtitle_items.map(item => ({
271 | item,
272 | base: getBaseName(item.name)
273 | }));
274 | const videoBase = getBaseName(video_file.name);
275 | const videoVariants = [];
276 | let currentVariant = videoBase;
277 | while (currentVariant) {
278 | videoVariants.push(currentVariant);
279 | currentVariant = currentVariant.split('.').slice(0, -1).join('.');
280 | }
281 | for (const variant of videoVariants) {
282 | const matched = subItems.filter(({ base }) => base.includes(variant) || variant.includes(base));
283 | if (matched.length) return matched.map(({ item }) => item);
284 | }
285 | return [];
286 | };
287 |
288 | obj.getDownloadUrlBatch = function (fileList) {
289 | if (!Array.isArray(fileList)) {
290 | fileList = [fileList];
291 | }
292 | var promises = fileList.map(function (item) {
293 | return item.type == "file" && obj.getDownloadUrl(item).then((response) => {
294 | item.url = response.url;
295 | return item;
296 | });
297 | }).filter(Boolean);
298 | return Promise.allSettled(promises).then((results) => {
299 | return fileList;
300 | });
301 | };
302 |
303 | obj.getDownloadUrl = function (file) {
304 | return obj.refresh().then (() => {
305 | const { drive_id, file_id, share_id } = file;
306 | if (share_id) {
307 | return obj.saveFile(file_id, share_id).then((response) => {
308 | const { responses: [{ body, status }] } = response;
309 | if (status === 201) {
310 | const { drive_id, file_id } = body;
311 | return obj.get_download_url(drive_id, file_id).finally(() => {
312 | obj.deleteFile(drive_id, file_id);
313 | });
314 | }
315 | else {
316 | obj.showTipError("文件缓存失败,请自行清理网盘文件后重试。。。", 10e3);
317 | return Promise.reject();
318 | }
319 | });
320 | }
321 |
322 | return obj.get_download_url(drive_id, file_id);
323 | });
324 | };
325 |
326 | obj.get_download_url = function (drive_id, file_id) {
327 | const { token_type, access_token } = obj.getItem("token");
328 | return fetch("https://api.aliyundrive.com/v2/file/get_download_url", {
329 | body: JSON.stringify({
330 | expire_sec: 14400,
331 | drive_id: drive_id,
332 | file_id: file_id
333 | }),
334 | headers: {
335 | "authorization": "".concat(token_type || "", " ").concat(access_token || ""),
336 | "content-type": "application/json;charset=UTF-8",
337 | "x-canary": "client=windows,app=adrive,version=v6.0.0",
338 | },
339 | method: "POST"
340 | }).then((response) => {
341 | return response.ok ? response.json() : Promise.reject();
342 | });
343 | };
344 |
345 | obj.saveFile = function (file_id, share_id) {
346 | const { token_type, access_token, default_drive_id } = obj.getItem("token");
347 | const { share_token } = obj.getItem("shareToken");
348 | return fetch("https://api.aliyundrive.com/adrive/v4/batch", {
349 | body: JSON.stringify({
350 | requests: [
351 | {
352 | body: {
353 | auto_rename: true,
354 | file_id: file_id,
355 | share_id: share_id,
356 | to_parent_file_id: "root",
357 | to_drive_id: default_drive_id
358 | },
359 | headers: {
360 | "Content-Type": "application/json"
361 | },
362 | id: "0",
363 | method: "POST",
364 | url: "/file/copy"
365 | }
366 | ],
367 | resource: "file"
368 | }),
369 | headers: {
370 | "authorization": "".concat(token_type || "", " ").concat(access_token || ""),
371 | "content-type": "application/json;charset=UTF-8",
372 | "x-share-token": share_token
373 | },
374 | method: "POST"
375 | }).then((response) => {
376 | return response.ok ? response.json() : Promise.reject();
377 | });
378 | };
379 |
380 | obj.deleteFile = function (drive_id, file_id) {
381 | const { token_type, access_token } = obj.getItem("token");
382 | return fetch("https://api.aliyundrive.com/v3/file/delete", {
383 | body: JSON.stringify({
384 | drive_id: drive_id,
385 | file_id: file_id
386 | }),
387 | headers: {
388 | "authorization": "".concat(token_type || "", " ").concat(access_token || ""),
389 | "content-type": "application/json;charset=UTF-8",
390 | },
391 | method: "POST"
392 | });
393 | };
394 |
395 | obj.refresh = function () {
396 | const token = obj.getItem("token") || {};
397 | if (obj.tokenExpires(token)) {
398 | return Promise.resolve();
399 | }
400 | return fetch("https://api.aliyundrive.com/token/refresh", {
401 | body: JSON.stringify({
402 | refresh_token: token.refresh_token
403 | }),
404 | headers: {
405 | "accept": "application/json, text/plain, */*",
406 | "content-type": "application/json",
407 | },
408 | method: "POST"
409 | }).then((response) => {
410 | return response.ok ? response.json() : Promise.reject();
411 | }).then((response) => {
412 | obj.setItem("token", response);
413 | return response;
414 | });
415 | };
416 |
417 | obj.tokenExpires = function (file) {
418 | var t = file.expire_time, i = Number(file.expires_in), e = Date.parse(t) - Date.now();
419 | if (0 < e && e < 1e3 * i) return !0;
420 | return !1;
421 | };
422 |
423 | obj.getItem = function (n) {
424 | n = localStorage.getItem(n);
425 | if (!n) return null;
426 | try {
427 | return JSON.parse(n);
428 | } catch (e) {
429 | return n;
430 | }
431 | };
432 |
433 | obj.setItem = function (n, t) {
434 | n && t != undefined && localStorage.setItem(n, t instanceof Object ? JSON.stringify(t) : t);
435 | };
436 |
437 | obj.removeItem = function (n) {
438 | n != undefined && localStorage.removeItem(n);
439 | };
440 |
441 | obj.isSharePage = function () {
442 | return location.href.indexOf("aliyundrive.com/s/") > 0 || location.href.indexOf("alipan.com/s/") > 0;
443 | };
444 |
445 | obj.delay = function (ms = 500) {
446 | return new Promise(resolve => setTimeout(resolve, ms));
447 | };
448 |
449 | obj.showTipSuccess = function (message, time) {
450 | obj.showNotify({
451 | type: "success",
452 | message: message,
453 | time: time
454 | });
455 | };
456 |
457 | obj.showTipError = function (message, time) {
458 | obj.showNotify({
459 | type: "fail",
460 | message: message,
461 | time: time
462 | });
463 | };
464 |
465 | obj.showTipLoading = function (message, time) {
466 | obj.showNotify({
467 | type: "loading",
468 | message: message,
469 | time: time
470 | });
471 | };
472 |
473 | obj.showNotify = function (opts) {
474 | if (unsafeWindow.application) {
475 | unsafeWindow.application.showNotify(opts);
476 | }
477 | else {
478 | var css = [
479 | ".notify{display:none;position:absolute;top:0;left:25%;width:50%;text-align:center;overflow:hidden;z-index:1010}",
480 | ".notify .alert{display:inline-block;*display:inline;*zoom:1;min-width:110px;white-space:nowrap}",
481 | ".alert-success,.alert-fail,.alert-loading{padding:0 20px;line-height:34px;font-size:14px;color:#ffffff}",
482 | ".alert-success,.alert-loading{background:#36be63}",
483 | ".alert-fail{background:#ff794a}",
484 | ".fade{opacity:0;-webkit-transition:opacity .15s linear;-o-transition:opacity .15s linear;transition:opacity .15s linear}",
485 | ".fade.in{opacity:1}"
486 | ];
487 |
488 | var style = document.createElement('style');
489 | style.textContent = css.join(" ");
490 | (document.head || document.documentElement).appendChild(style);
491 |
492 | var notifyDiv = document.createElement('div');
493 | notifyDiv.id = 'J_Notify';
494 | notifyDiv.className = 'notify';
495 | notifyDiv.style.cssText = 'width: 650px; margin: 10px auto; display: none;';
496 | document.body.appendChild(notifyDiv);
497 |
498 | unsafeWindow.application = {
499 | notifySets: {
500 | type_class_obj: {success: "alert-success", fail: "alert-fail", loading: "alert-loading"},
501 | count: 0,
502 | delay: 3e3
503 | },
504 | showNotify: function(opts) {
505 | var that = this,
506 | class_obj = that.notifySets.type_class_obj,
507 | count = that.notifySets.count,
508 | notifyEl = document.getElementById('J_Notify'),
509 | alertEl;
510 |
511 | if (opts.type == "loading") {
512 | that.notifySets.delay *= 5;
513 | }
514 |
515 | if (!notifyEl.querySelector('.alert')) {
516 | notifyEl.innerHTML = '';
517 | notifyEl.style.display = 'block';
518 | } else {
519 | Object.keys(class_obj).forEach(function(key) {
520 | notifyEl.classList.remove(class_obj[key]);
521 | });
522 | }
523 |
524 | alertEl = notifyEl.querySelector('.alert');
525 | alertEl.textContent = opts.message;
526 | alertEl.classList.add(class_obj[opts.type]);
527 | that.notifySets.count += 1;
528 |
529 | var delay = opts.time || that.notifySets.delay;
530 | setTimeout(function() {
531 | if (++count == that.notifySets.count) {
532 | that.hideNotify();
533 | }
534 | }, delay);
535 | },
536 | hideNotify: function() {
537 | var notifyEl = document.getElementById('J_Notify');
538 | notifyEl.innerHTML = '';
539 | notifyEl.style.display = 'none';
540 | }
541 | };
542 | obj.showNotify(opts);
543 | }
544 | };
545 |
546 | obj.hideNotify = function () {
547 | if (unsafeWindow.application) {
548 | unsafeWindow.application.hideNotify();
549 | }
550 | };
551 |
552 | obj.run = function () {
553 | obj.httpListener();
554 | }();
555 |
556 | console.log("=== 阿里云盘 好棒棒!===");
557 |
558 | // Your code here...
559 | })();
560 |
--------------------------------------------------------------------------------