Last active
June 19, 2025 16:17
-
-
Save David7ce/50a57344d237a59281a8f09783d5111d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name YouTube Reverse Hack (Mejorado) | |
// @namespace https://chat.openai.com/ | |
// @version 0.3 | |
// @description Simula reproducción reversa más suave en YouTube (solo vídeo) | |
// @match https://www.youtube.com/watch* | |
// @grant none | |
// ==/UserScript== | |
(function () { | |
'use strict'; | |
let reverseActive = false; | |
let rafId = null; | |
const step = 0.04; // segundos por frame ~25fps | |
const delay = 40; // ms entre frames | |
function waitForVideo(callback) { | |
const check = setInterval(() => { | |
const video = document.querySelector('video'); | |
if (video && video.readyState >= 2) { | |
clearInterval(check); | |
callback(video); | |
} | |
}, 300); | |
} | |
function createButton(video) { | |
const btn = document.createElement('button'); | |
btn.textContent = '⏪ Reverse'; | |
Object.assign(btn.style, { | |
position: 'fixed', | |
bottom: '100px', | |
left: '20px', | |
zIndex: 9999, | |
padding: '10px', | |
background: '#111', | |
color: '#fff', | |
border: 'none', | |
borderRadius: '6px', | |
cursor: 'pointer', | |
fontSize: '14px', | |
opacity: 0.85, | |
}); | |
btn.onclick = () => { | |
reverseActive = !reverseActive; | |
if (reverseActive) { | |
video.pause(); | |
stepBack(video); | |
btn.textContent = '⏹️ Stop Reverse'; | |
} else { | |
cancelAnimationFrame(rafId); | |
btn.textContent = '⏪ Reverse'; | |
} | |
}; | |
document.body.appendChild(btn); | |
} | |
function stepBack(video) { | |
if (!reverseActive) return; | |
const now = video.currentTime; | |
if (now <= 0.04) { | |
reverseActive = false; | |
return; | |
} | |
video.currentTime = now - step; | |
rafId = requestAnimationFrame(() => { | |
setTimeout(() => stepBack(video), delay); | |
}); | |
} | |
waitForVideo((video) => { | |
createButton(video); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment