├── LICENSE
├── README.md
└── PotplayerPanVideo.js
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 bleu
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # PotplayerPanVideo
2 |
3 | |百度网盘| 迅雷云盘|阿里云盘|
4 | |:---|:----|:---|
5 | |🌕720p|🌔720p|🌕1080p|
6 | |🌔需配置potplayer|🌕可配置potplayer|🌕可配置potplayer|
7 | |🌔链接时间限制|🌕链接时间限制|🌒链接时间限制|
8 | |🌕nplayer|🌕nplayer|🌑nplayer|
9 |
10 | ## 前排提醒
11 |
12 | 1.百度网盘,普通用户不支持1080p(会员暂时没测试),请选择720p观看。
13 |
14 | 2.迅雷云盘和阿里云盘用户可跳转到新脚本,体验更好[PotPlayer云盘-专供版](https://github.com/Bleu404/PotplayerPanVideoSV/)
15 |
16 | 3.没有网盘,或是不想用网盘,只想在线看视频,跳转到[Github_PotplayerM3U8](https://github.com/Bleu404/PotplayerM3U8)
17 |
18 | ## 📢使用前,准备事项📢
19 |
20 |
1.注册附带webdav的网盘(坚果云、TeraCLOUD等),
21 | 2.安装PotPlayer 或者其他的带有webdav功能的播放器(手机端推荐nplayer)
22 | 3.百度网盘支持新旧版,违规资源不能播放
23 |
24 | 1️⃣、TeraCLOUD 原始10g空间,用我的推荐码:DDGYA ,可额外获得5g
25 | 2️⃣、配置中的密码不是登陆密码,是授权第三方应用的密码,坚果云的 开启方法 ;
26 | TeraClOUD的mypage ,中找到Apps Connection,保存好密码,不然下一次要重置
27 | 3️⃣、PotPlayer下载蓝奏云: https://bleu.lanzoue.com/iFZgu07w69vg 密码:3mk7
28 | nPlayer安卓破解版蓝奏云:https://bleu.lanzoue.com/ioczh01n0hqd 密码:705r
29 |
30 |
31 | ## 📖视频使用教程📖
32 |
33 | [ACFUN-PotPlayer播放云盘视频](https://www.acfun.cn/v/ac34091426)
34 |
35 | ## ⚙配置脚本⚙
36 |
37 |
38 | ***上图是以坚果云为例,填写的脚本WEBDAV画质配置***
39 |
40 | ## ⚙配置PotPlayer专辑⚙
41 |
42 | **====👇百度网盘👇====
**
43 | >***1.画质尽量选择1080p或者720p***
44 | ***2.选择Wbdav协议,其他复制脚本配置即可,如果使用TeraCLOUD,勾选ssl选项***
45 | ***3.选择PanPlaylist文件夹,就可以看到baidu***
46 |
47 |
48 | **====👇迅雷云盘👇====
**
49 | >***网页版迅雷云盘对有些视频解码不到位。所以用webdav协议,很多视频不能观看
50 | 改成下面的用法:***
51 | >>1️⃣、首先新建.dpl文件,内容为:
52 | >>>DAUMPLAYLIST
53 | >>>playname=
54 | >>>playtime=
55 | >>>topindex=
56 | >>>extplaylist=
57 |
58 | >>2️⃣、上面链接`用户`、`密码`、`主机`,都以可以在脚本配置中找到
59 | **注意:用户中`@`应改为`%40` 其他的@不用改=**
60 |
61 | >>3️⃣、设置potplayer专辑,选择**外部播放列表**,选择之前新建的.dpl文件
62 |
63 | **====👇阿里云盘👇====
**
64 | >***与迅雷云盘的设置类似,.dpl文件的链接将`xunlei`改为`aliyun`***
65 |
66 | **====👇自定义网站👇====
**
67 | >主要是解决小型网站的播放器不太好用的问题
68 | >可以在脚本设置页面,添加自定义网站,如下图,记得加`*`
69 |
70 | 如果嫌麻烦,也可以添加全匹配,代码中加 `// @match *://*/*`
71 |
72 | >**1️⃣、脚本管理器有‘转存页面m3u文件’按钮**
73 |
74 |
75 | >**2️⃣、webdav会生成一个.m3u文件用法:**
76 | >>
77 | >>- 1.先打开`此电脑`,
78 | >>- 2.在上方选择`添加一个网络位置`,
79 | >>- 3.一直点击`下一页`,
80 | >>- 4.再输入地址:`https://用户:密码@主机/PanPlaylist/`(参考迅雷云盘),
81 | >>- 5.打开文件夹,找到.m3u文件用potplayer播放或其它播放器
82 |
83 | 🍜喜欢此脚本,可以给个好评或收藏。
84 |
--------------------------------------------------------------------------------
/PotplayerPanVideo.js:
--------------------------------------------------------------------------------
1 | // ==UserScript==
2 | // @name PotPlayer播放云盘视频
3 | // @namespace https://greasyfork.org/zh-CN/users/798733-bleu
4 | // @version 1.2.7
5 | // @description 支持🐱💻百度网盘(720p)、🐱👤迅雷云盘(720p)、🐱🏍阿里云盘(1080p)👉右键👈导入播放信息到webdav网盘;支持劫持自定义匹配网站的m3u文件导入webdav网盘。PotPlayer实现🥇倍速、🏆无边框、更换解码器、渲染器等功能。
6 | // @author bleu
7 | // @compatible edge Tampermonkey
8 | // @compatible chrome Tampermonkey
9 | // @compatible firefox Tampermonkey
10 | // @license MIT
11 | // @match http*://pan.baidu.com/*
12 | // @match http*://yun.baidu.com/*
13 | // @match https://pan.xunlei.com/*
14 | // @match https://www.aliyundrive.com/*
15 | // @icon https://fastly.jsdelivr.net/gh/Bleu404/PRPO@latest/png/ppv.png
16 | // @grant GM_setValue
17 | // @grant GM_getValue
18 | // @grant GM_xmlhttpRequest
19 | // @grant GM_registerMenuCommand
20 | // @grant unsafeWindow
21 | // @connect *
22 | // @connect xunlei.com
23 | // @connect aliyundrive.com
24 | // @connect jianguoyun.com
25 | // @connect teracloud.jp
26 | // @run-at document-body
27 | // @require https://fastly.jsdelivr.net/npm/sweetalert2@11.1.0/dist/sweetalert2.all.min.js
28 | // @require https://fastly.jsdelivr.net/npm/bleutools@1.0.2/bleutools.min.js
29 | // ==/UserScript==
30 | (function () {
31 | 'use strict';
32 | const ORGXHRSRH = XMLHttpRequest.prototype.setRequestHeader;
33 | let bleuc,
34 | contextMenu,
35 | itemsInfo,
36 | arryIndex,
37 | tempPath,
38 | flag,Option,observer,cloud,
39 | isCheckWebdav = true,
40 | m3u8File = "#EXTM3U",
41 | flieTypeStr = ".wmv,.rmvb,.avi,.mp4,.mkv,.flv,.swf.mpeg4,.mpeg2,.3gp,.mpga,.qt,.rm,.wmz,.wmd,.wvx,.wmx,.wm,.mpg,.mpeg,mov,.asf,.m4v,.ts,";
42 | const tools = {
43 | getCloudName() {
44 | switch (document.domain) {
45 | case 'pan.baidu.com':
46 | cloud = baidu;
47 | break;
48 | case 'yun.baidu.com':
49 | cloud = baidu;
50 | break;
51 | case 'xunlei.com':
52 | cloud = xunlei;
53 | break;
54 | case 'pan.xunlei.com':
55 | cloud = xunlei;
56 | break;
57 | case 'www.aliyundrive.com':
58 | cloud = aliyun;
59 | break;
60 | default:
61 | cloud = others;
62 | }
63 | },
64 | checkFileType(name) {
65 | let type = name.toLowerCase().substring(name.lastIndexOf('.'))||"bleu"
66 | return flieTypeStr.indexOf(`${type},`) >= 0 ? true : false
67 | },
68 | async addDavDir(){
69 | if(flag==='xunlei'||flag==='aliyun')return
70 | await tools.checkPath();
71 | await this._addDir(`https://${bleuc.cip}/PanPlaylist/${flag}${tempPath}`)
72 | },
73 | async _addDir(url){
74 | let header = {
75 | "authorization": `Basic ${btoa(`${bleuc.cun}:${bleuc.cpw}`)}`
76 | }
77 | let method = bleuc.cip.indexOf('teracloud')>0?'GET':'PROPFIND';
78 | await bleu.XHR(method, url, undefined, header, undefined).then(async() => {
79 | }, async() => {
80 | await bleu.XHR('MKCOL', url, undefined, header, undefined);
81 | })
82 | },
83 | async checkPath(){
84 | let url = `https://${bleuc.cip}/PanPlaylist/`;
85 | if (isCheckWebdav) {
86 | isCheckWebdav = false;
87 | await this._addDir(url);
88 | url = `https://${bleuc.cip}/PanPlaylist/${flag}/`
89 | await this._addDir(url);
90 | }
91 | },
92 | async putFileInWebdav(name, info) {
93 | let header = {
94 | "authorization": `Basic ${btoa(`${bleuc.cun}:${bleuc.cpw}`)}`
95 | }
96 | if(info === '#EXTM3U')return
97 | await tools.checkPath();
98 | await bleu.XHR('PUT', `https://${bleuc.cip}/PanPlaylist/${flag}${tempPath}/${name}`, info, header, 'xml').then((res) => {
99 | bleu.swalInfo(`✅${name}`, 3000, 'center');
100 | }, () => bleu.swalInfo(`❌${name}`, 3000, 'center'));
101 | },
102 | checkConfig(){
103 | bleuc = JSON.parse(GM_getValue('bleuc')||null)||{cip:'',cun:'',cpw:'',cbdqs:'bd720',cxlqs:'xl0',calqs:'FHD'}
104 | if(!(bleuc.cip!=''&&bleuc.cun!=''&&bleuc.cpw!='')){
105 | bleu.swalInfo(`❗请先设置WEBDAV画质`, '', 'center')
106 | return false
107 | }
108 | return true
109 | },
110 | saveConfig(){
111 | let temp =document.querySelector('#cip').value.trim()
112 | temp = temp.charAt(temp.length-1)==='/'?temp.substring(0,temp.length-1):temp
113 | temp = temp.indexOf('https://')<0?temp:temp.replace('https://','')
114 | GM_setValue("bleuc", JSON.stringify({
115 | 'cip': temp,
116 | 'cun': document.querySelector('#cun').value.trim(),
117 | 'cpw': document.querySelector('#cpw').value.trim(),
118 | 'cbdqs': document.querySelector('#cbdqs').value,
119 | 'cxlqs': document.querySelector('#cxlqs').value,
120 | 'calqs': document.querySelector('#calqs').value,
121 | }));
122 | },
123 | configHtml(){
124 | bleuc = JSON.parse(GM_getValue('bleuc')||null)||{cip:'',cun:'',cpw:'',cbdqs:'bd720',cxlqs:'xl0',calqs:'FHD'}
125 | let html = `
126 |
130 | 画质
131 | 百度网盘:
132 | 1080p
133 | 720p
134 | 480p
135 | 360p
136 | 迅雷云盘:
137 | 从高到低
138 | 从低到高
139 | 阿里云盘:
140 | 1080p
141 | 720p
142 | 540p
143 | 360p
144 | `
145 | //bleuc.cbdqs?bleuc.cbdqs:bleuc.cbdqs='FHD';
146 | return html.replace(`${bleuc.cbdqs}\"`,`${bleuc.cbdqs}\" selected`)
147 | .replace(`${bleuc.cxlqs}\"`,`${bleuc.cxlqs}\" selected`)
148 | .replace(`${bleuc.calqs}\"`,`${bleuc.calqs}\" selected`)
149 | },
150 | cssStyle:`
151 | .bleuc_config_item{border-radius: 10px;font-size: 20px;margin: 12px 50px;color: #fff;background: linear-gradient(45deg,#12c2e9, #c471ed, #f64f59);box-shadow: 2px 2px 2px 1px rgba(0, 0, 0, 0.2);}
152 | .bleuc_config_item label{font-size: 15px}
153 | .bleuc_config_item input.bleuc_inp{margin: 0px 10px;font-size: 15px;background: linear-gradient(45deg,#12c2e9, #c471ed, #f64f59);border-style:none;color:black;width:200px}
154 | .bleuc_config_item p{text-align: left;margin: 0px 20px;}
155 | .bleuc_sel{margin: 0px 10px;background: linear-gradient(45deg,#12c2e9, #c471ed, #f64f59);font-size: 15px;border: none;color:black;width:160px}`,
156 |
157 | }
158 | const baidu = {
159 | hostname(){
160 | flag = 'baidu';
161 | baidu._isNew = location.href.indexOf('/disk/main') > 0?true:false;
162 | },
163 | addTag() {
164 | if (contextMenu.firstChild.innerText.match(/转存播放信息|查看/)) return
165 | let ul = document.createElement('ul');
166 | baidu._isNew?ul.innerHTML = ``
167 | :ul.innerHTML = ` 转存播放信息 `;
168 | contextMenu.firstChild.prepend(ul.firstChild);
169 | main.addClickEvent();
170 | },
171 | getselectFilesInfo() {
172 | let temp;
173 | if(baidu._isNew){
174 | temp = [];
175 | let collection = document.querySelector('.wp-s-pan-table__body.mouse-choose-list').__vue__.canSelectListMap;
176 | document.querySelectorAll('.wp-s-pan-table__body-row.mouse-choose-item.selected').forEach(i=>{
177 | temp.push(collection[i.getAttribute('data-id')].item);
178 | })
179 | }else{
180 | temp = require('system-core:context/context.js').instanceForSystem.list.getSelected();
181 | }
182 | baidu._pushItem(temp);
183 | },
184 | async updateFile(item) {
185 | let streamUrl = `https://${location.host}/api/streaming?path=${encodeURIComponent(item.id)}&app_id=250528&clienttype=0&type=M3U8_AUTO_${bleuc.cbdqs.substring(2)}&vip=2&isplayer=0&check_blue=1`;
186 | await bleu.XHR('GET', streamUrl, undefined, {
187 | withCredentials: true
188 | },'txt').then(async(res) => {
189 | await tools.putFileInWebdav(item.name, res);
190 | }, () => {
191 | bleu.swalInfo(`❌${item.name}`, 3000, 'center') ;
192 | })
193 | },
194 | async openNextDir(item) {
195 | let listUrl = `https://${location.host}/api/list?order=name&desc=0&showempty=0&web=1&page=1&num=100&dir=${encodeURIComponent(item.id)}&channel=chunlei&web=1&app_id=250528&clienttype=0`;
196 | await bleu.XHR('GET', listUrl, undefined, {
197 | withCredentials: true
198 | }).then((res) => {
199 | arryIndex++;
200 | baidu._pushItem(res.list);
201 | })
202 | },
203 | findContext(node) {
204 | if (baidu._isNew) {
205 | node = document.querySelectorAll('.ctx-menu-container')[4];
206 | if (!(node&&node.querySelector('.wp-s-ctx-menu__item.cursor-p'))) return;
207 | contextMenu = node;
208 | baidu.addTag();
209 | }
210 | else if(node.className ==='context-menu'){
211 | observer.disconnect();
212 | contextMenu = node;
213 | baidu.addTag();
214 | }
215 | },
216 | closeMenu(){
217 | if(!baidu._isNew)contextMenu.firstChild.style.display = "none"
218 | else contextMenu.__vue__.hideMenu()
219 | },
220 | _pushItem(temp) {
221 | itemsInfo[arryIndex] = [];
222 | temp.forEach(item => {
223 | if (item.isdir === 0 && !tools.checkFileType(item.server_filename)) return
224 | let itemInfo = {
225 | 'id': item.path,
226 | 'isdir': item.isdir === 1 ? true : false,
227 | 'name': item.server_filename,
228 | };
229 | itemsInfo[arryIndex].push(itemInfo);
230 | });
231 | },
232 |
233 | _isNew:false,
234 |
235 | finallyFunc(){unsafeWindow.location.href = `potplayer://`;}
236 | }
237 | const xunlei = {
238 | hostname(){
239 | flag = 'xunlei'
240 | },
241 | addTag() {
242 | if (contextMenu.innerText.indexOf('转存')===0) return
243 | let ul = document.createElement('ul');
244 | ul.innerHTML = ``;
245 | contextMenu.firstChild.prepend(ul.firstChild);
246 | main.addClickEvent();
247 | },
248 | getselectFilesInfo() {
249 | let temp = document.querySelectorAll('li.SourceListItem__item--XxpOC.SourceListItem__active--4U0f4');
250 | temp.forEach((item)=>{
251 | this._pushItem(item.__vue__.info);
252 | })
253 | },
254 | async updateFile(item) {
255 | let url = `https://api-pan.xunlei.com/drive/v1/files/${item.id}`;
256 | await bleu.XHR('GET', url, undefined,Option.header).then((res) => {
257 | let temp=[];
258 | res.medias.forEach((item)=>{
259 | if (item.link != null) {
260 | temp.push(item.media_name === '原始画质' ? res.web_content_link : item.link.url)}
261 | })
262 | url = bleuc.cxlqs === 'xl0'?temp[0]:temp[temp.length-1];
263 | m3u8File=m3u8File.replace('#EXTM3U',`#EXTM3U\n#EXTINF:-1 ,${item.name}\n${url}`)
264 | }, () => {
265 | bleu.swalInfo("❗进出目录之后重新转存", '', 'center');
266 | throw "PPV:迅雷-文件超时,重新转存";
267 | })
268 | },
269 | async openNextDir(item) {
270 | let url = `https://api-pan.xunlei.com/drive/v1/files?limit=100&parent_id=${item.id}&filters={"phase":{"eq":"PHASE_TYPE_COMPLETE"},"trashed":{"eq":false}}&with_audit=true`;
271 | await bleu.XHR('GET', url, undefined,Option.header).then((res) => {
272 | arryIndex++;
273 | res.files.forEach((item)=>{
274 | xunlei._pushItem(item);
275 | })
276 | }, () => {
277 | bleu.swalInfo("❗进出目录之后重新转存", '', 'center');
278 | throw "PPV:迅雷-文件夹超时,重新转存";
279 | })
280 | },
281 | findContext(node) {
282 | if (node.className === 'pan-content') {
283 | node = node.querySelector('div.pan-dropdown-menu.context-menu');
284 | if(!node)return;
285 | this._getHeaderInfo();
286 | contextMenu = node;
287 | xunlei.addTag();
288 | }
289 | },
290 | closeMenu(){
291 | },
292 | _pushItem(temp) {
293 | if(!itemsInfo[arryIndex]) itemsInfo[arryIndex]= [];
294 | if (temp.kind === 'drive#file' && !tools.checkFileType(temp.name)) return
295 | let itemInfo = {
296 | 'id': temp.id,
297 | 'isdir': temp.kind === 'drive#file' ? false : true,
298 | 'name': temp.name,
299 | };
300 | itemsInfo[arryIndex].push(itemInfo);
301 | },
302 | _getHeaderInfo(){
303 | Option={},Option.header={};
304 | Option.header.withCredentials=false;
305 | Option.header['content-type']='application/json';
306 | for (let key in localStorage) {
307 | let temp = localStorage.getItem(key)
308 | if(key.indexOf('credentials')===0){
309 | Option.header.Authorization = JSON.parse(temp).token_type+' '+JSON.parse(temp).access_token;
310 | Option.clientid = key.substring(key.indexOf('_')+1);
311 | }
312 | if(key.indexOf('captcha')===0)
313 | Option.header['x-captcha-token']=JSON.parse(temp).token
314 | if(key==='deviceid')
315 | Option.header['x-device-id'] = temp.substring(temp.indexOf('.')+1,32+temp.indexOf('.')+1)
316 | }
317 | },
318 | async finallyFunc(){
319 | await tools.putFileInWebdav('Playlist.m3u', m3u8File);
320 | unsafeWindow.location.href = `potplayer://https://${encodeURIComponent(bleuc.cun)}:${bleuc.cpw}@${bleuc.cip}/PanPlaylist/xunlei/Playlist.m3u`;
321 | }
322 | }
323 | const aliyun = {
324 | hostname(){
325 | flag = 'aliyun';
326 | this.hookXHRHeader();
327 | },
328 | addTag() {
329 | if (contextMenu.innerText.match(/转存播放信息|新建/)) return
330 | let ul = document.createElement('ul');
331 | ul.innerHTML = ``;
332 | contextMenu.prepend(ul.firstChild);
333 | main.addClickEvent();
334 | },
335 | getselectFilesInfo() {
336 | let temp = document.querySelectorAll('div[data-index]')
337 | let attrName;
338 | for(let attr in temp[0]){
339 | if(attr.indexOf('__reactFiber')==0){
340 | attrName = attr;
341 | break;
342 | }
343 | }
344 | temp.forEach((item)=>{
345 | if(item.querySelector('input')&&item.querySelector('input').checked){
346 | let value = item[attrName].return.pendingProps;
347 | aliyun._pushItem(value.data[value.index]||value.data[value.rowIndex][value.columnIndex]);
348 | }
349 | })
350 |
351 | },
352 | async updateFile(item) {
353 | let url = `https://api.aliyundrive.com/v2/file/get_video_preview_play_info`,
354 | token = JSON.parse(localStorage.getItem('token')),
355 | data = {
356 | category: "live_transcoding",
357 | 'drive_id': token.default_drive_id,
358 | 'file_id': item.id,
359 | 'template_id': ""
360 | },
361 | header = {
362 | 'x-canary': 'client=web,app=adrive,version=v2.4.0',
363 | 'x-device-id': document.cookie.match(/cna=([^;]*)/)[1],
364 | authorization: `${token.token_type} ${token.access_token}`,
365 | 'x-signature':this._signature
366 | };
367 | await bleu.XHR('POST', url, JSON.stringify(data), header).then((res) => {
368 | let temp = res.video_preview_play_info.live_transcoding_task_list;
369 | url =temp.find((item)=>item.template_id===bleuc.calqs)?temp.find((item)=>item.template_id===bleuc.calqs).url:temp[temp.length-1].url;
370 | m3u8File+=`\n#EXTINF:-1 ,${item.name}\n#EXTVLCOPT:http-referrer=https://www.aliyundrive.com/\n${url}`;
371 | }, () => {
372 | bleu.swalInfo("🔴💬刷新页面,重新获取", '', 'center');
373 | throw "PPV:阿里-文件超时,重新转存";
374 | })
375 | },
376 | async openNextDir(item) {
377 | let url = `https://api.aliyundrive.com/adrive/v3/file/list?jsonmask=next_marker%2Citems(name%2Cfile_id%2Cdrive_id%2Ctype%2Csize%2Ccreated_at%2Cupdated_at%2Ccategory%2Cfile_extension%2Cparent_file_id%2Cmime_type%2Cstarred%2Cthumbnail%2Curl%2Cstreams_info%2Ccontent_hash%2Cuser_tags%2Ctrashed%2Cvideo_media_metadata%2Cvideo_preview_metadata)`,
378 | token = JSON.parse(localStorage.getItem('token')),
379 | data = {
380 | 'drive_id': token.default_drive_id,
381 | 'parent_file_id': item.id,
382 | 'limit': 100,
383 | },
384 | header = {
385 | 'x-canary': 'client=web,app=adrive,version=v2.4.0',
386 | 'x-device-id': document.cookie.match(/cna=([^;]*)/)[1],
387 | authorization: `${token.token_type} ${token.access_token}`,
388 | 'x-signature':this._signature
389 | };
390 | await bleu.XHR('POST', url, JSON.stringify(data),header).then((res) => {
391 | arryIndex++;
392 | res.items.forEach((item)=>{
393 | aliyun._pushItem(item);
394 | }, () => {
395 | bleu.swalInfo("🔴💬刷新页面,重新获取", '', 'center');
396 | throw "PPV:阿里-文件夹超时,重新转存";
397 | })
398 | })
399 | },
400 | findContext(node) {
401 | node = document.querySelector('ul.ant-dropdown-menu');
402 | if (!node) return;
403 | //observer.disconnect();
404 | contextMenu = node;
405 | aliyun.addTag();
406 | },
407 | closeMenu(){
408 | contextMenu.parentNode.className='ant-dropdown dropdown-menu--1KRbu ant-dropdown-placement-bottomLeft ant-dropdown-hidden';
409 | contextMenu.parentNode.style.left='-578px';
410 | contextMenu.parentNode.style.top='-646px';
411 | },
412 | _pushItem(temp) {
413 | if(!itemsInfo[arryIndex]) itemsInfo[arryIndex]= [];
414 | if (temp.type==='file'&&temp.category!="video") return
415 | let itemInfo = {
416 | 'id': temp.fileId||temp.file_id,
417 | 'isdir': temp.type === 'file' ? false : true,
418 | 'name': temp.name,
419 | };
420 | itemsInfo[arryIndex].push(itemInfo);
421 | },
422 | _signature:'',
423 | hookXHRHeader() {
424 | XMLHttpRequest.prototype.setRequestHeader = function(header, value) {
425 | if(header == "x-signature"){
426 | aliyun._signature=value;
427 | }
428 | return ORGXHRSRH.apply(this, arguments);
429 | }
430 | },
431 | async finallyFunc(){
432 | await tools.putFileInWebdav('Playlist.m3u', m3u8File);
433 | unsafeWindow.location.href = `potplayer://https://${encodeURIComponent(bleuc.cun)}:${bleuc.cpw}@${bleuc.cip}/PanPlaylist/aliyun/Playlist.m3u`;
434 | }
435 | }
436 | const others = {
437 | hostname() {
438 | flag ='others' ;
439 | tempPath='/'+location.hostname.replace('www.','')
440 | itemsInfo=[];
441 | const oriXSend = XMLHttpRequest.prototype.send;
442 |
443 | XMLHttpRequest.prototype.send = function () {
444 | others._onLoad(this);
445 | return oriXSend.apply(this, arguments);
446 | }
447 | },
448 | _onLoad(xhr) {
449 | xhr.addEventListener("load", async function () {
450 | if (others._watchM3u&&xhr.readyState == 4 && xhr.status >= 200&&xhr.status < 300) {
451 | if (typeof (xhr.response) === 'string'&&xhr.responseURL.match(/^http/)) {
452 | if (xhr.response.indexOf('#EXTM3U') === 0) { //通用
453 | observer.disconnect();
454 | itemsInfo.push(xhr.responseURL);
455 | others._getHtmlMenu();
456 | } else if (tempPath === '/agemys.com' && xhr.response.match('http.*mp4')) { //age动漫
457 | observer.disconnect();
458 | itemsInfo.push(decodeURIComponent(xhr.response.match('http.*mp4')[0]));
459 | others._getHtmlMenu();
460 | }
461 | }
462 | }
463 | });
464 | },
465 | findContext(node) {
466 | if ((node.tagName == 'VIDEO' || node.tagName == 'IFRAME')&&node.getAttribute('src')&&
467 | node.getAttribute('src').match(/http.*mp4/)) {
468 | observer.disconnect()
469 | this._watchM3u=false;
470 | itemsInfo.push(node.getAttribute('src'));
471 | others._getHtmlMenu();
472 | }
473 | },
474 | _getHtmlMenu() {
475 | if (this._onceEnough) return
476 | GM_registerMenuCommand('转存页面m3u文件',()=>{this._saveas()}, 'm');
477 | document.addEventListener("keydown", (e)=>{
478 | if (e.key == "z" && e.altKey) {
479 | this._saveas()
480 | }
481 | })
482 | this._onceEnough = true;
483 | },
484 | _saveas(){
485 | if (itemsInfo.length === 0) {
486 | bleu.swalInfo(`❌没有加载m3u文件,等一会再尝试!`, 3000, 'center')
487 | return;
488 | }
489 | bleu.swalUI('转存页面m3u文件', this._html(), '550px');
490 | let nameIPT = document.querySelector('#bleu_name');
491 | nameIPT.select();
492 | nameIPT.focus();
493 | nameIPT.addEventListener('keypress',(e)=>{
494 | e.keyCode == 13&&document.querySelector('#saveas').click();
495 | })
496 | document.querySelector('#saveas').addEventListener('click', async () => {
497 | m3u8File = "#EXTM3U";
498 | if(!this._direxit){
499 | await tools.addDavDir();
500 | this._direxit=true;
501 | }
502 | let tempname = nameIPT.value
503 | let isreferrer = document.querySelector('#bleu_ref').checked?document.referrer:'';
504 | itemsInfo.forEach((item, index) => {
505 | m3u8File += `\n#EXTINF:-1 ,${tempname}_${index}\n#EXTVLCOPT:http-referrer=${isreferrer}\n${decodeURIComponent(item)}`;
506 | })
507 | await tools.putFileInWebdav(tempname + '.m3u', m3u8File);
508 | unsafeWindow.location.href = `potplayer://https://${encodeURIComponent(bleuc.cun)}:${bleuc.cpw}@${bleuc.cip}/PanPlaylist/others/${location.hostname.replace('www.','')}/${tempname}.m3u`;
509 | })
510 | },
511 | _direxit:false,
512 | _onceEnough:false,
513 | _watchM3u:true,
514 | _html(){return `.m3u 转存
包含referrer `},
515 | }
516 | const main = {
517 | init() {
518 | observer = new MutationObserver(function (mutations) {
519 | for (let mutation of mutations) {
520 | if (mutation.type === 'childList') {
521 | cloud.findContext(mutation.target);
522 | }
523 | }
524 | });
525 | observer.observe(document, {
526 | 'childList': true,
527 | 'subtree': true
528 | });
529 | },
530 | addClickEvent() {
531 | let bleuButton = document.getElementById('bleuReSave');
532 | bleuButton.addEventListener('click', async function () {
533 | itemsInfo = [[]];
534 | arryIndex = 0;
535 | tempPath='';
536 | m3u8File = "#EXTM3U";
537 | if(!tools.checkConfig())return;
538 | cloud.closeMenu();
539 | cloud.getselectFilesInfo();
540 | if (itemsInfo[arryIndex].length === 0) {
541 | bleu.swalInfo(`❌未选择文件转存!`, 3000, 'center')
542 | return;
543 | }
544 | try {
545 | await main.updateAllFiles(itemsInfo[arryIndex]);
546 | } catch (e) {
547 | console.log(e);
548 | return;
549 | }
550 | m3u8File != "#EXTM3U"&&cloud.finallyFunc();
551 | })
552 | },
553 | async updateAllFiles(loopArry) {
554 | for (let index = 0; index < loopArry.length; index++) {
555 | if (!loopArry[index].isdir) {
556 | await cloud.updateFile(loopArry[index]);
557 | } else {
558 | tempPath += `/${loopArry[index].name}`;
559 | await tools.addDavDir();
560 | await cloud.openNextDir(loopArry[index]);
561 | await main.updateAllFiles(itemsInfo[arryIndex]);
562 | }
563 | bleu.sleep(800);
564 | }
565 | tempPath = tempPath.substring(0, tempPath.lastIndexOf('/'));
566 | },
567 | };
568 | tools.getCloudName();
569 | cloud.hostname();
570 | //tools.checkConfig();
571 | bleu.addCssStyle(tools.cssStyle);
572 | GM_registerMenuCommand('配置WEBDAV画质', () => {
573 | bleu.swalUI('WEBDAV画质', tools.configHtml(), '400px').then(tools.saveConfig)
574 | },'w')
575 | main.init();
576 | })();
577 |
--------------------------------------------------------------------------------