// ==UserScript== // @name 百度网盘视频播放器-🚀4K高清🚀 // @namespace https://bbs.tampermonkey.net.cn/ // @version 1.1.1 // @description 一款百度网盘视频播放增强插件,支持4K高清播放,流畅不卡顿! // @antifeature ads // @author You // @license MIT // @icon https://nd-static.bdstatic.com/m-static/v20-main/home/img/icon-home-new.b4083345.png // @match *://pan.baidu.com/* // @match *://yun.baidu.com/* // @match *://pan.baidu.com/disk/home* // @match *://yun.baidu.com/disk/home* // @match *://pan.baidu.com/disk/main // @match *://yun.baidu.com/disk/main* // @match *://pan.baidu.com/s/* // @match *://yun.baidu.com/s/* // @match *://pan.baidu.com/share/* // @match *://yun.baidu.com/share/* // @connect baidu.com // @connect d.pcs.baidu.com // @connect api.gssource.com // @connect 154.201.66.44 // @connect 127.0.0.1 // @grant GM_cookie // @grant GM_addStyle // @grant GM_getResourceText // @grant GM_xmlhttpRequest // @require https://cdnjs.cloudflare.com/ajax/libs/layui/2.9.14/layui.min.js // @require https://unpkg.com/sweetalert/dist/sweetalert.min.js // @resource layuiCSS https://cdnjs.cloudflare.com/ajax/libs/layui/2.9.14/css/layui.css // @resource xgCSS https://unpkg.byted-static.com/xgplayer/3.0.23/dist/index.min.css // @require https://unpkg.byted-static.com/xgplayer/3.0.23/dist/index.min.js // @require https://unpkg.com/artplayer/dist/artplayer.js // ==/UserScript== (function () { 'use strict'; const layuicss = GM_getResourceText('layuiCSS'); GM_addStyle(layuicss); const xgCSS = GM_getResourceText('xgCSS'); GM_addStyle(xgCSS); const config = { main_url: 'https://api.gssource.com', bd_password: '1234', title_name: '播放', player:null, }; layui.use(['layer'], async function () { var layer = layui.layer, $ = layui.$; var form = layui.form; if (location.href.startsWith('https://pan.baidu.com/s/')) { $('.x-button-box').prepend( '' + config.title_name + '' ); } else { if ($('.tcuLAu').is('*')) { $('.tcuLAu').prepend( '' + config.title_name + '' ); } else { $('.wp-s-agile-tool-bar__header.is-header-tool').prepend( '
' ); } } $('#downbtn_share').click(function () { swal({ title: '提示', text: '请先保存到自己的网盘后,从网盘里解析!', icon: 'warning', }); return false; }); $('#downbtn_main').click(function () { let select = selectList(); let selected = Object.keys(select); if (selected.length == 0) { swal({ text: '请先选择一个文件', icon: 'warning', }); return false; } else if (selected.length > 1) { swal({ text: '目前仅支持单个文件解析', icon: 'warning', }); return false; } else if (select[selected[0]].isdir == 1) { swal({ text: '目前不支持文件夹解析', icon: 'warning', }); return false; } let fileName = select[selected[0]].server_filename let index = fileName.lastIndexOf("."); let fileType = ["wmv", "rmvb", "mpeg4", "mpeg2", "flv", "avi", "3gp", "mpga", "qt", "rm", "wmz", "wmd", "wvx", "wmx", "wm", "mpg", "mp4", "mkv", "mpeg", "mov", "asf", "m4v", "m3u8", "swf"]; let name = fileName.substring(index + 1); name = name.toLowerCase(); if(!fileType.includes(name)){ swal({ text: '只支持播放视频格式文件!', icon: 'error', }); return false; } const openLayer = layer.open({ type: 1, area: ['800px', '400px'], title: '提示', shade: 0.6, // 遮罩透明度 shadeClose: true, // 点击遮罩区域,关闭弹层 anim: 0, // 0-6 的动画形式,-1 不开启 content: `
`, success: function () { form.render(); form.on('submit(demo-login)', async function (data) { $('#parse').html('

正在解析中请稍后...

'); const inputValue = document.getElementById('wpCode').value; if(inputValue){ fetch(config.main_url+"/wp/catCode",{ headers: { "accept": "application/json, text/plain, */*", "content-type": "application/json;charset=UTF-8" }, body: JSON.stringify({ code:inputValue }), method: "POST", credentials: "include" }).then(function (result) { return result.ok ? result.json() : Promise.reject(); }).then(res=>{ if(res.code === 200){ share_one_baidu(openLayer); }else{ layer.close(openLayer); swal({ text: '验证码错误一个验证码只能使用一次,请重新获取!', icon: 'error', }); } }) }else{ layer.close(openLayer); swal({ text: '请输入验证码', icon: 'error', }); } }); }, }); }); }); function selectName() { var select = {}; var option = []; try { option = require('system-core:context/context.js').instanceForSystem.list.getSelected(); } catch (e) { option = document.querySelector('.wp-s-core-pan').__vue__.selectedList; } option.forEach((element) => { select[element.server_filename] = element; }); return select; } function selectList() { var select = {}; var option = []; try { option = require('system-core:context/context.js').instanceForSystem.list.getSelected(); } catch (e) { option = document.querySelector('.wp-s-core-pan').__vue__.selectedList; } option.forEach((element) => { select[element.fs_id] = element; }); return select; } function share_one_baidu(openLayer) { let select = Object.keys(selectList()); let bdstoken = ''; let data_json = {}; try { data_json = $('html') .html() .match(/(?<=locals\.mset\()(.*?)(?=\);)/)[0]; data_json = JSON.parse(data_json); config.username = data_json.username; bdstoken = data_json.bdstoken; } catch (e) { data_json = $('html') .html() .match(/(?<=window\.locals\s=\s)(.*?)(?=;)/)[0]; data_json = JSON.parse(data_json); config.username = data_json.userInfo.username; bdstoken = data_json.userInfo.bdstoken; } config.data_json = data_json; const param = { bdstoken: bdstoken, period: 1, pwd: config.bd_password, eflag_disable: true, channel_list: '%5B%5D', schannel: 4, fid_list: JSON.stringify(select), }; $.ajax({ type: 'GET', url: 'https://pan.baidu.com/share/set', async: true, data: { bdstoken: bdstoken, period: 1, pwd: config.bd_password, eflag_disable: true, channel_list: '%5B%5D', schannel: 4, fid_list: JSON.stringify(select), }, dataType: 'json', success: function (res) { if (res.show_msg.indexOf('禁止') > -1) { swal({ text: '该文件禁止分享', icon: 'error', }); return false; } else { let shorturl = ''; try { shorturl = res.link.split('/').pop(); } catch (error) { swal({ text: '初始化准备失败', icon: 'error', }); return false; } get_down_list( shorturl, config.bd_password, openLayer, res.data, ); } }, error: function (res) { swal({ text: '初始化准备请求访问失败', icon: 'error', }); }, }); } async function get_down_list(shorturl, password, openLayer, pwd) { let ajax_data = { shorturl: shorturl, pwd: password, dir: 1, root: 1, userKey: 'main', }; fetch(config.main_url + '/wp/parseCopyLink', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify(ajax_data), }) .then((resp) => resp.json()) .then((res) => { if (res.code == 200) { const requestData = { fsId: res.data.data.list[0].fs_id, shareid: res.data.data.shareid, uk: res.data.data.uk, sekey: res.data.data.seckey, randsk:res.data.data.seckey, fs_ids: [res.data.data.list[0].fs_id], path:res.data.data.list[0].server_filename, fileName:res.data.data.list[0].server_filename, size:res.data.data.list[0].size, surl: shorturl, url: `https://pan.baidu.com/s/${shorturl}`, userKey: 'main', pwd: password, dir: '/', playType:"plugin", }; console.log(requestData); GM_xmlhttpRequest({ method: 'POST', url: config.main_url + '/wp/addVideo', headers: { 'Content-Type': 'application/json', }, data: JSON.stringify(requestData), onload: function (response) { const responseData = JSON.parse(response.responseText); if (responseData.code !== 200) { layer.close(openLayer); swal({ text: responseData.msg, icon: 'warning', }); } else { $('#parse').html('

解析

'); layer.alert('解析成功,请点击播放器按钮播放视频!', { title: '提示', }); let path = "baidu/我的资源/"+responseData.data.fileName; const signUrl = "https://play.gssource.com/d/"+encodeURI(path)+"?sign="+responseData.data.sign; document.getElementById("infuse").href = "infuse://x-callback-url/play?url="+signUrl; document.getElementById("potplayer").href = "potplayer://"+signUrl; } }, onerror: function (response) { layer.close(openLayer); const errorMessage = JSON.parse(response.responseText).message || '网络错误'; swal({ text: '解析遇到问题了,请刷新重试即可!!', icon: 'warning', }); }, }); } else { layer.close(openLayer); $('#parse').html('

解析

'); swal({ text: '解析遇到问题了,请升级插件刷新重试即可!', icon: 'warning', }); } }); } // Your code here... })();