|
|
|
很不错的视频网站 但是偶尔播放会卡顿 找到了s0urcelab大佬的的脚本 替换ddys播放器移除Adblock屏蔽,修复滚轮和全屏快捷键失效bug,优化选集和线路功能,自动记忆选集
我之前加了一个调倍速的功能 新增: zxc调整倍速 z 变回1x x 减低0.1x c 加快0.1x
疗养院测试了一下,应该没什么问题 
- // ==UserScript==
- // @name 替换ddys(低端影视)播放器
- // @version 1.6
- // @description 替换ddys播放器,移除Adblock屏蔽,修复滚轮和全屏快捷键失效bug,优化选集和线路功能,自动记忆选集(添加了倍速功能
- // @author s0urce
- // @match https://ddys.art/*
- // @match https://ddys.pro/*
- // [url=home.php?mod=space&uid=682785]@icon[/url] https://ddys.pro/favicon-16x16.png
- // @grant GM_addStyle
- // @grant GM_xmlhttpRequest
- // @require https://fastly.jsdelivr.net/npm/[email protected]/browser/index.min.js
- // @run-at document-end
- // @downloadURL https://update.greasyfork.org/scripts/464925/%E6%9B%BF%E6%8D%A2ddys%EF%BC%88%E4%BD%8E%E7%AB%AF%E5%BD%B1%E8%A7%86%EF%BC%89%E6%92%AD%E6%94%BE%E5%99%A8.user.js
- // @updateURL https://update.greasyfork.org/scripts/464925/%E6%9B%BF%E6%8D%A2ddys%EF%BC%88%E4%BD%8E%E7%AB%AF%E5%BD%B1%E8%A7%86%EF%BC%89%E6%92%AD%E6%94%BE%E5%99%A8.meta.js
- // ==/UserScript==
- const QS = (q) => document.querySelector(q)
- const QSA = (q) => document.querySelectorAll(q)
- const domain = window.location.hostname
- const src4domain = `v.ddys.pro`
- const globalStyle = `
- .wp-playlist-tracks {
- display: none!important;
- }
- .wp-video-playlist {
- display: flex;
- padding: 0!important;
- border: none!important;
- background: none!important;
- }
- .entry > p {
- display: none;
- }
- .player-sider {
- width: 220px;
- display: flex;
- flex-direction: column;
- background-color: #2e2e2e;
- border-radius: 8px;
- margin-left: 10px;
- padding: 4px;
- }
- .tab-item {
- cursor: pointer;
- margin-bottom: 6px;
- padding: 8px;
- color: white;
- background-color: #5a5a5a;
- border-radius: 5px;
- }
- .tab-item.playing {
- font-weight: bold;
- color: #3a8fb7;
- background-color: #232323;
- }
- .tab-item:not(.playing):hover {
- background-color: #232323;
- }
- .tab-item > .indicator {
- height: 14px;
- width: 14px;
- font-size: 14px;
- margin-right: 5px;
- }
- .speed-display {
- position: absolute;
- top: 10px;
- left: 10px;
- background: rgba(0,0,0,0.7);
- color: white;
- padding: 5px 10px;
- border-radius: 4px;
- font-size: 14px;
- z-index: 100;
- display: none;
- }
- .xgplayer-playbackrate {
- display: none !important;
- }
- `
- function parseResUrl(d) {
- return { ...d, url: `https://${src4domain}${d[`src${d.srctype - 1}`]}` }
- }
- class Tabs {
- constructor(init) {
- this.root = init.root
- this.data = init.data
- this.onSelect = init.onSelect
- this.selectedKey = init.data[0].key
- }
- render(key = this.selectedKey) {
- this.selectedKey = key
- this.root.innerHTML = this.data.reduce((acc, curr) => {
- const isTarget = key === curr.key
- return `${acc}
- <div class="tab-item ${isTarget ? 'playing' : ''}" data-tab-key="${curr.key}">
- ${isTarget ? '<img class="indicator" src="//s1.hdslb.com/bfs/static/jinkela/video/asserts/playing.gif"></img>' : ''}
- ${curr.label}
- </div>
- `
- }, '')
- const self = this
- for (const tabElment of this.root.children) {
- tabElment.onclick = function() {
- const tabKey = tabElment.dataset.tabKey
- const record = self.data.find(v => v.key === tabKey)
- self.render(tabKey)
- self.onSelect(tabKey, record)
- }
- }
- }
- }
- ; (async function () {
- 'use strict';
- const originContainer = QS('.wp-video-playlist')
- if (!originContainer) return;
- GM_addStyle(globalStyle)
- for (const item of originContainer.children) {
- item.style.display = 'none'
- }
- originContainer.innerHTML += `
- <div id="xgplayer">
- <div class="speed-display"></div>
- </div>
- <div class="player-sider">
- <div class="tabs-root"></div>
- <select id="playbackRate">
- <option value="0.75">0.75x</option>
- <option value="1" selected>1x</option>
- <option value="1.25">1.25x</option>
- <option value="1.5">1.5x</option>
- <option value="2">2x</option>
- </select>
- </div>
- `
- const res = JSON.parse(QS('.wp-playlist-script').textContent)
- const resPromise = res.tracks
- .map((track, idx) => ({ ...track, key: `${idx + 1}`, label: track.caption }))
- .map(parseResUrl)
- const resGroups = await Promise.all(resPromise)
- const initVolume = window.localStorage['volume'] ? parseFloat(window.localStorage['volume']) : 1
- const isWatched = window.localStorage[location.pathname]
- const initEp = isWatched ? JSON.parse(isWatched).ep : '1'
- const initPlayUrl = resGroups.find(v => v.key === initEp).url
- console.warn(`当前播放资源url:${initPlayUrl}`)
- const player = new window.Player({
- id: 'xgplayer',
- url: initPlayUrl,
- volume: initVolume,
- fluid: true,
- videoInit: true,
- lastPlayTimeHideDelay: 3,
- playbackRate: window.localStorage['playbackRate'] ? parseFloat(window.localStorage['playbackRate']) : 1,
- ...isWatched && {lastPlayTime: JSON.parse(isWatched).seek},
- })
- const tabs = new Tabs({
- root: QS('.tabs-root'),
- data: resGroups,
- onSelect: (key, record) => {
- console.warn(`切换选集:【${key}】${record.label}`)
- player.src = record.url
- console.warn(`当前播放资源url:${record.url}`)
- player.play()
- }
- })
- tabs.render(initEp)
- player.on('timeupdate', function({ currentTime }) {
- window.localStorage[location.pathname] = JSON.stringify({
- seek: currentTime,
- ep: tabs.selectedKey,
- })
- })
- player.on('volumechange', function({ volume }) {
- window.localStorage['volume'] = volume
- })
- const playbackRateSelect = QS('#playbackRate');
- playbackRateSelect.value = player.playbackRate;
- playbackRateSelect.addEventListener('change', function() {
- const selectedRate = parseFloat(this.value);
- player.playbackRate = selectedRate;
- window.localStorage['playbackRate'] = selectedRate;
- showSpeed(selectedRate);
- });
- player.on('playbackRateChange', function({ playbackRate }) {
- window.localStorage['playbackRate'] = playbackRate;
- playbackRateSelect.value = playbackRate;
- });
- function showSpeed(speed) {
- const display = QS('.speed-display');
- display.textContent = `当前倍速: ${speed.toFixed(1)}x`;
- display.style.display = 'block';
- setTimeout(() => {
- display.style.display = 'none';
- }, 2000);
- }
- document.addEventListener('keydown', (e) => {
- if (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA') return;
- const currentRate = player.playbackRate;
- let newRate = currentRate;
- switch(e.key.toLowerCase()) {
- case 'z':
- newRate = 1;
- break;
- case 'x':
- newRate = Math.max(0.1, currentRate - 0.1);
- break;
- case 'c':
- newRate = Math.min(5, currentRate + 0.1);
- break;
- default:
- return;
- }
- if (newRate !== currentRate) {
- player.playbackRate = newRate;
- playbackRateSelect.value = newRate;
- showSpeed(newRate);
- }
- });
- })();
复制代码
|
评分
-
查看全部评分
|