// ==UserScript== // @name 百度网盘在线视频播放器 // @namespace https://example.com/ // @version 2.3 // @description 百度网盘视频在线播放,文件内视频自动解析,支持倍速调节(0.25x-4x)、画质切换(360P-1080P) // @match https://pan.baidu.com/s/* // @grant unsafeWindow // @run-at document-end // @icon https://nd-static.bdstatic.com/m-static/wp-brand/favicon.ico // @license MIT // ==/UserScript== (function() { 'use strict'; console.log('=== 百度网盘在线视频播放器 v2.3 ==='); function formatDuration(seconds) { if (!seconds || seconds <= 0) return ''; var s = Math.floor(seconds); var h = Math.floor(s / 3600); var m = Math.floor((s % 3600) / 60); var sec = s % 60; if (h > 0) { return h + ':' + String(m).padStart(2, '0') + ':' + String(sec).padStart(2, '0'); } else { return m + ':' + String(sec).padStart(2, '0'); } } function getFileName(file) { return file.server_filename || file.filename || file.name || file.title || '未知文件'; } function getFolderName() { var hash = location.hash; var match = hash.match(/path=([^&]+)/); if (match) { var path = decodeURIComponent(match[1]); var idx = path.indexOf('sharelink'); if (idx >= 0) { var sub = path.substring(idx); var parts = sub.split('/'); if (parts.length > 1) parts.shift(); return parts.join('/') || '根目录'; } return path || '根目录'; } return '根目录'; } function getSurId() { return (location.pathname.match(/\/s\/(\w+)/) || [])[1] || ''; } function getCurrentList() { try { var ctx = unsafeWindow.require('system-core:context/context.js'); var list = ctx.instanceForSystem.list.getCurrentList(); if (list && list.length) { sessionStorage.setItem(getSurId(), JSON.stringify(list)); return list; } } catch(e) {} var cached = sessionStorage.getItem(getSurId()); if (cached) { try { return JSON.parse(cached); } catch(e) {} } return []; } function buildPlayerPage(videos, shareInfo, folderName) { var enhancedVideos = videos.map(function(v, idx) { return { id: idx, name: getFileName(v), fid: v.fs_id || v.fid, duration: 0 }; }); enhancedVideos.sort(function(a, b) { return a.name.localeCompare(b.name, 'zh-CN', {numeric:true}); }); enhancedVideos.forEach(function(v, i) { v.id = i; }); var videoDataJson = JSON.stringify(enhancedVideos); var shareDataJson = JSON.stringify(shareInfo); videoDataJson = videoDataJson.replace(/<\/script>/gi, '<\\/script>'); shareDataJson = shareDataJson.replace(/<\/script>/gi, '<\\/script>'); folderName = folderName.replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"'); return '百度网盘视频播放器'+ ''+ ''+ '
'+ ''+ '

点击开始播放

⏳ 加载中...
'+ '
0:00 / 0:00
'+ '
|倍速:'+ ''+ '
🔊
'+ '|清晰度:'+ ''+ '|'+ ''+ ''+ ''+ '
'+ '
'+ '