Rank: Member
Groups: Approved
Joined: 3/31/2024(UTC) Posts: 14
Thanks: 1 times Was thanked: 1 time(s) in 1 post(s)
|
In fact, it is much more convenient to use a browser bookmark than the script + the video speed is preserved for all videos on the page + it works on Facebook. Also, the speed display in some players will not be shown; you need to add them to the exception list here: if (showIndicator) { if (!window.location.href.includes( Also, keep in mind that it will not work if the video is embedded, for example, YouTube on another website. simply toggles the speed 1/1.5/2
javascript:(function() { var speeds = [1, 1.5, 2]; var currentSpeedIndex = parseInt(localStorage.getItem('videoSpeedIndex') || '0');
function showFixedSpeedIndicator(message, duration) { var speedIndicator = document.querySelector('.fixed-speed-indicator'); if (!speedIndicator) { speedIndicator = document.createElement('div'); speedIndicator.className = 'fixed-speed-indicator'; speedIndicator.style.cssText = 'position:fixed;top:0px;left:50%;transform:translateX(-50%);background-color:rgba(0,0,0,0.7);color:white;padding:0 1px;border-radius:0 0 3px 3px;font-size:14px;font-family:Arial,sans-serif;z-index:999999;transition:opacity 0.3s;opacity:0;display:none;'; document.body.appendChild(speedIndicator); }
speedIndicator.textContent = message; speedIndicator.style.opacity = '1'; speedIndicator.style.display = 'block'; setTimeout(function() { speedIndicator.style.opacity = '0'; setTimeout(() => { speedIndicator.style.display = 'none'; }, 300); }, duration); }
function applyToVideo(v, showIndicator = false) { if (v.playbackRate !== undefined) { v.playbackRate = speeds[currentSpeedIndex];
if (showIndicator) { if (!window.location.href.includes('rutube.ru/shorts/') && !window.location.href.includes('dzen.ru') && !window.location.href.includes('my.mail.ru')) { var container = v.closest('.jwplayer') || v.closest('.video_box_wrap') || v.closest('.player') || v.parentElement; container.style.position = 'relative';
var speedIndicator = container.querySelector('.speed-indicator'); if (!speedIndicator) { speedIndicator = document.createElement('div'); speedIndicator.className = 'speed-indicator'; speedIndicator.style.cssText = 'position:absolute;top:0px;left:50%;transform:translateX(-50%);background-color:rgba(0,0,0,0.7);color:white;padding:0 1px;border-radius:0 0 3px 3px;font-size:14px;font-family:Arial,sans-serif;z-index:999999;transition:opacity 0.3s;opacity:0;display:none;'; container.appendChild(speedIndicator); }
speedIndicator.textContent = v.playbackRate.toFixed(1) + 'x'; speedIndicator.style.opacity = '1'; speedIndicator.style.display = 'block'; setTimeout(() => { speedIndicator.style.opacity = '0'; setTimeout(() => { speedIndicator.style.display = 'none'; }, 300); }, 1000); } else { showFixedSpeedIndicator(v.playbackRate.toFixed(1) + 'x', 1000); } } } }
function changeSpeed() { var videos = document.querySelectorAll('video'); if (videos.length > 0) { var currentSpeed = videos[0].playbackRate; var currentIndex = speeds.indexOf(currentSpeed); if (currentIndex === -1) { currentIndex = speeds.findIndex(speed => speed > currentSpeed) - 1; if (currentIndex === -2) currentIndex = speeds.length - 1; } currentSpeedIndex = (currentIndex + 1) % speeds.length; localStorage.setItem('videoSpeedIndex', currentSpeedIndex); videos.forEach(v => applyToVideo(v, true)); } else { showFixedSpeedIndicator('No video found on this page', 2000); } }
function handleNewVideos(mutations) { mutations.forEach(function(mutation) { if (mutation.addedNodes) { mutation.addedNodes.forEach(function(node) { if (node.nodeName === 'VIDEO') { applyToVideo(node, false); } else if (node.classList && (node.classList.contains('jwplayer') || node.classList.contains('player'))) { var video = node.querySelector('video'); if (video) { applyToVideo(video, false); } } else if (node.querySelector) { var videos = node.querySelectorAll('video'); videos.forEach(v => applyToVideo(v, false)); } }); } }); } function checkAndApplySpeed() { document.querySelectorAll('video').forEach(v => { if (v.playbackRate !== speeds[currentSpeedIndex]) { applyToVideo(v, false); } }); }
document.addEventListener('seeked', function(e) { if (e.target.tagName === 'VIDEO') { setTimeout(() => applyToVideo(e.target, false), 0); } }, true);
['loadedmetadata', 'canplay', 'playing'].forEach(function(event) { document.addEventListener(event, function(e) { if (e.target.tagName === 'VIDEO') { applyToVideo(e.target, false); } }, true); });
var observer = new MutationObserver(handleNewVideos);
observer.observe(document.body, { childList: true, subtree: true });
var videos = document.querySelectorAll('video'); if (videos.length > 0) { var currentSpeed = videos[0].playbackRate; var currentIndex = speeds.indexOf(currentSpeed); if (currentIndex === -1) { currentIndex = speeds.findIndex(speed => speed > currentSpeed) - 1; if (currentIndex === -2) currentIndex = speeds.length - 1; } currentSpeedIndex = currentIndex; localStorage.setItem('videoSpeedIndex', currentSpeedIndex); } videos.forEach(v => applyToVideo(v, false));
document.addEventListener('play', function(e) { if (e.target.tagName === 'VIDEO') { applyToVideo(e.target, false); } }, true);
window.addEventListener('popstate', checkAndApplySpeed);
changeSpeed();
})();
manually enter the desired speed
javascript:(function() { var speed = 1.5; var userSpeed = parseFloat(prompt("Enter playback speed (e.g., 1.5):", speed)); if (!isNaN(userSpeed) && userSpeed > 0) { speed = userSpeed; }
function showFixedSpeedIndicator(message, duration) { if (window.location.href.includes('rutube.ru/shorts/') || window.location.href.includes('dzen.ru') || window.location.href.includes('my.mail.ru')) { var speedIndicator = document.querySelector('.fixed-speed-indicator'); if (!speedIndicator) { speedIndicator = document.createElement('div'); speedIndicator.className = 'fixed-speed-indicator'; speedIndicator.style.cssText = 'position:fixed;top:0px;left:50%;transform:translateX(-50%);background-color:rgba(0,0,0,0.7);color:white;padding:0 1px;border-radius:0 0 3px 3px;font-size:14px;font-family:Arial,sans-serif;z-index:999999;transition:opacity 0.3s;opacity:0;display:none;'; document.body.appendChild(speedIndicator); }
speedIndicator.textContent = message; speedIndicator.style.opacity = '1'; speedIndicator.style.display = 'block'; setTimeout(function() { speedIndicator.style.opacity = '0'; setTimeout(() => { speedIndicator.style.display = 'none'; }, 300); }, duration); } }
function applyToVideo(v, showIndicator = false) { if (v.playbackRate !== undefined) { v.playbackRate = speed;
if (showIndicator) { if (!window.location.href.includes('rutube.ru/shorts/') && !window.location.href.includes('dzen.ru') && !window.location.href.includes('my.mail.ru')) { var container = v.closest('.jwplayer') || v.closest('.video_box_wrap') || v.closest('.player') || v.parentElement; container.style.position = 'relative';
var speedIndicator = container.querySelector('.speed-indicator'); if (!speedIndicator) { speedIndicator = document.createElement('div'); speedIndicator.className = 'speed-indicator'; speedIndicator.style.cssText = 'position:absolute;top:0px;left:50%;transform:translateX(-50%);background-color:rgba(0,0,0,0.7);color:white;padding:0 1px;border-radius:0 0 3px 3px;font-size:14px;font-family:Arial,sans-serif;z-index:999999;transition:opacity 0.3s;opacity:0;display:none;'; container.appendChild(speedIndicator); }
speedIndicator.textContent = v.playbackRate.toFixed(1) + 'x'; speedIndicator.style.opacity = '1'; speedIndicator.style.display = 'block'; setTimeout(() => { speedIndicator.style.opacity = '0'; setTimeout(() => { speedIndicator.style.display = 'none'; }, 300); }, 1000); } else { showFixedSpeedIndicator(v.playbackRate.toFixed(1) + 'x', 1000); } } } }
function handleNewVideos(mutations) { mutations.forEach(function(mutation) { if (mutation.addedNodes) { mutation.addedNodes.forEach(function(node) { if (node.nodeName === 'VIDEO') { applyToVideo(node, false); } else if (node.classList && (node.classList.contains('jwplayer') || node.classList.contains('player'))) { var video = node.querySelector('video'); if (video) { applyToVideo(video, false); } } else if (node.querySelector) { var videos = node.querySelectorAll('video'); videos.forEach(v => applyToVideo(v, false)); } }); } }); }
function checkAndApplySpeed() { document.querySelectorAll('video').forEach(v => { if (v.playbackRate !== speed) { applyToVideo(v, false); } }); }
document.addEventListener('seeked', function(e) { if (e.target.tagName === 'VIDEO') { setTimeout(() => applyToVideo(e.target, false), 0); } }, true);
['loadedmetadata', 'canplay', 'playing'].forEach(function(event) { document.addEventListener(event, function(e) { if (e.target.tagName === 'VIDEO') { applyToVideo(e.target, false); } }, true); });
var observer = new MutationObserver(handleNewVideos);
observer.observe(document.body, { childList: true, subtree: true });
document.querySelectorAll('video').forEach(v => applyToVideo(v, true));
document.addEventListener('play', function(e) { if (e.target.tagName === 'VIDEO') { applyToVideo(e.target, false); } }, true);
window.addEventListener('popstate', checkAndApplySpeed); })();
v2
works for most video players Before the script will work, you need to do this. press ctrl+shift+j and manually type in “allow pasting” and you're done. Warning: Don't paste code into the DevTools Console that you don't understand or haven't reviewed yourself. This could allow attackers to steal your identity or take control of your computer. Please type 'allow pasting' below to allow pasting. 1x and 2x notification via alert Code:
function toggleVideoSpeed() {
var script = `
(function() {
var videos = document.querySelectorAll('video');
var newSpeed;
videos.forEach(function(v) {
newSpeed = v.playbackRate === 1 ? 2 : 1;
v.playbackRate = newSpeed;
});
setTimeout(function() {
alert('New speed: ' + newSpeed + 'x');
}, 100);
})();
`;
var oldClipboard = clip.GetText() || '';
clip.SetText(script);
sp.SendModifiedVKeys([vk.LCONTROL,vk.LSHIFT], [vk.VK_J]);
sp.Sleep(1200);
sp.SendModifiedVKeys([vk.LCONTROL], [vk.VK_L]);
sp.Sleep(100);
sp.SendModifiedVKeys([vk.LCONTROL], [vk.VK_V]);
sp.Sleep(100);
sp.SendKeys("{ENTER}");
sp.Sleep(100);
sp.SendModifiedVKeys([vk.LCONTROL,vk.LSHIFT], [vk.VK_J]);
if (oldClipboard) {
clip.SetText(oldClipboard);
}
sp.Sleep(1000);
sp.SendVKey(vk.ESCAPE);
}
toggleVideoSpeed();
switching between 1x and 2x with constant notification on the top right of the video with fade out Code:
function toggleVideoSpeed() {
var script = `
(function(){
var speedKey = 'currentVideoSpeed';
var currentSpeed = parseFloat(localStorage.getItem(speedKey) || '1');
function toggleSpeed() {
currentSpeed = currentSpeed === 1 ? 2 : 1;
localStorage.setItem(speedKey, currentSpeed);
return currentSpeed;
}
var speed = toggleSpeed();
function applyToVideo(v) {
if (v.playbackRate !== undefined) {
v.playbackRate = speed;
var container = v.closest('.jwplayer') || v.closest('.video_box_wrap') || v.closest('.player') || v.parentElement;
var speedIndicator = container.querySelector('.speed-indicator');
if (!speedIndicator) {
speedIndicator = document.createElement('div');
speedIndicator.className = 'speed-indicator';
speedIndicator.style.position = 'absolute';
speedIndicator.style.top = '0px';
speedIndicator.style.right = '0px';
speedIndicator.style.backgroundColor = 'rgba(0, 0, 0, 0.7)';
speedIndicator.style.color = 'white';
speedIndicator.style.padding = '1px';
speedIndicator.style.borderRadius = '1px';
speedIndicator.style.fontSize = '14px';
speedIndicator.style.fontFamily = 'Arial, sans-serif';
speedIndicator.style.zIndex = '9999';
speedIndicator.style.transition = 'opacity 0.3s';
container.style.position = 'relative';
container.appendChild(speedIndicator);
}
updateIndicator(speedIndicator);
}
}
function updateIndicator(indicator) {
var hideTimeout;
function showIndicator() {
if (speed !== 1) {
indicator.textContent = speed + 'x';
indicator.style.opacity = '1';
indicator.style.display = 'block';
clearTimeout(hideTimeout);
hideTimeout = setTimeout(hideIndicator, 500); // Sets a timer to hide the indicator after 500 ms
} else {
indicator.style.display = 'none';
}
}
function hideIndicator() {
if (speed !== 1) {
indicator.style.opacity = '0';
} else {
indicator.style.display = 'none';
}
}
indicator.parentElement.addEventListener('mousemove', showIndicator);
indicator.parentElement.addEventListener('mouseleave', hideIndicator);
showIndicator();
}
var allVideos = document.querySelectorAll('video');
allVideos.forEach(applyToVideo);
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.addedNodes) {
mutation.addedNodes.forEach(function(node) {
if (node.nodeName === 'VIDEO') {
applyToVideo(node);
} else if (node.classList && (node.classList.contains('jwplayer') || node.classList.contains('player'))) {
var video = node.querySelector('video');
if (video) {
applyToVideo(video);
}
} else if (node.querySelector) {
var videos = node.querySelectorAll('video');
videos.forEach(applyToVideo);
}
});
}
});
});
observer.observe(document.body, {
childList: true,
subtree: true
});
})();
`;
var oldClipboard = clip.GetText();
clip.SetText(script);
sp.SendModifiedVKeys([vk.LCONTROL,vk.LSHIFT], [vk.VK_J]);
sp.Sleep(1200);
sp.SendModifiedVKeys([vk.LCONTROL], [vk.VK_L]);
sp.Sleep(100);
sp.SendModifiedVKeys([vk.LCONTROL], [vk.VK_V]);
sp.Sleep(150);
sp.SendKeys("{ENTER}");
sp.Sleep(100);
sp.SendModifiedVKeys([vk.LCONTROL,vk.LSHIFT], [vk.VK_J]);
clip.SetText(oldClipboard);
}
toggleVideoSpeed();
if you want to manually select the speed each time Code:
function toggleVideoSpeed() {
var script = `
(function(){
var speed = prompt("Set playback rate:", "1.5");
if (speed != null && speed != "") {
function applyToVideo(v) {
if (v.playbackRate !== undefined) {
v.playbackRate = parseFloat(speed);
var container = v.closest('.jwplayer') || v.closest('.video_box_wrap') || v.closest('.player') || v.parentElement;
var speedIndicator = container.querySelector('.speed-indicator');
if (!speedIndicator) {
speedIndicator = document.createElement('div');
speedIndicator.className = 'speed-indicator';
speedIndicator.style.position = 'absolute'; // Positions the element relative to its nearest positioned ancestor
speedIndicator.style.top = '0px'; // Distance from the top edge of the container
speedIndicator.style.left = '50%'; // Places it horizontally centered
speedIndicator.style.transform = 'translateX(-50%)'; // Adjusts position so the center of the indicator is centered
speedIndicator.style.backgroundColor = 'rgba(0, 0, 0, 0.7)'; // Background color (black with 70% opacity)
speedIndicator.style.color = 'white'; // Text color (white)
speedIndicator.style.padding = '0 1px'; // Minimal horizontal padding, no vertical padding
speedIndicator.style.borderRadius = '0 0 3px 3px'; // Rounds only the bottom corners
speedIndicator.style.fontSize = '14px'; // Font size
speedIndicator.style.fontFamily = 'Arial, sans-serif'; // Font family
speedIndicator.style.zIndex = '9999'; // Stacking order (high value to be above other elements)
speedIndicator.style.transition = 'opacity 0.3s'; // Smooth opacity change over 0.3 seconds
container.style.position = 'relative';
container.appendChild(speedIndicator);
var hideTimeout;
function showIndicator() {
updateIndicator();
if (v.playbackRate !== 1) {
speedIndicator.style.opacity = '1';
speedIndicator.style.display = 'block';
clearTimeout(hideTimeout);
hideTimeout = setTimeout(hideIndicator, 500);
} else {
hideIndicator();
}
}
function hideIndicator() {
if (v.playbackRate !== 1) {
speedIndicator.style.opacity = '0';
} else {
speedIndicator.style.display = 'none';
}
}
function updateIndicator() {
if (v.playbackRate !== 1) {
speedIndicator.textContent = v.playbackRate.toFixed(1) + 'x';
speedIndicator.style.display = 'block';
} else {
speedIndicator.style.display = 'none';
}
}
container.addEventListener('mousemove', showIndicator);
container.addEventListener('mouseleave', hideIndicator);
v.addEventListener('play', showIndicator);
v.addEventListener('ratechange', updateIndicator);
}
updateIndicator();
}
}
var videos = document.querySelectorAll('video');
videos.forEach(applyToVideo);
var jwVideos = document.querySelectorAll('.jwplayer video');
jwVideos.forEach(applyToVideo);
var vimeoVideos = document.querySelectorAll('.player video');
vimeoVideos.forEach(applyToVideo);
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.addedNodes) {
mutation.addedNodes.forEach(function(node) {
if (node.nodeName === 'VIDEO') {
applyToVideo(node);
} else if (node.classList && (node.classList.contains('jwplayer') || node.classList.contains('player'))) {
var video = node.querySelector('video');
if (video) {
applyToVideo(video);
}
} else if (node.querySelector) {
var videos = node.querySelectorAll('video');
videos.forEach(applyToVideo);
}
});
}
});
});
observer.observe(document.body, {
childList: true,
subtree: true
});
}
})();
`;
var oldClipboard = clip.GetText();
clip.SetText(script);
sp.SendModifiedVKeys([vk.LCONTROL,vk.LSHIFT], [vk.VK_J]);
sp.Sleep(1300);
sp.SendModifiedVKeys([vk.LCONTROL], [vk.VK_L]);
sp.Sleep(100);
sp.SendModifiedVKeys([vk.LCONTROL], [vk.VK_V]);
sp.Sleep(150);
sp.SendKeys("{ENTER}");
sp.Sleep(100);
sp.SendModifiedVKeys([vk.LCONTROL,vk.LSHIFT], [vk.VK_J]);
clip.SetText(oldClipboard);
}
toggleVideoSpeed();
v1
Code:
function toggleVideoSpeed() {
var script = `
(function() {
var speedMessage = '';
var videos = document.querySelectorAll('video');
videos.forEach(function(v) {
v.playbackRate = v.playbackRate === 1 ? 2 : 1; //By default, it is set to 1/2.
speedMessage = 'Current playback speed: ' + v.playbackRate + 'x';
console.log(speedMessage);
// Creating an element to display a message on the screen
var messageDiv = document.createElement('div');
messageDiv.style.position = 'fixed';
messageDiv.style.top = '60px';
messageDiv.style.left = '50%';
messageDiv.style.transform = 'translateX(-50%)';
messageDiv.style.backgroundColor = 'black';
messageDiv.style.color = 'white';
messageDiv.style.padding = '10px 20px';
messageDiv.style.borderRadius = '5px';
messageDiv.style.zIndex = 10000;
messageDiv.style.fontSize = '24px';
messageDiv.style.fontFamily = 'Segoe UI, Arial, sans-serif';
messageDiv.style.textAlign = 'center';
messageDiv.textContent = speedMessage;
// Adding the element to the page
document.body.appendChild(messageDiv);
// Removing the element after 2 seconds
setTimeout(function() {
document.body.removeChild(messageDiv);
}, 2000);
});
})();
`;
// Saving the current clipboard content
var oldClipboard = clip.GetText();
// Copying the script to the clipboard
clip.SetText(script);
// Opening the developer console
sp.SendVKey(vk.F12);
sp.Sleep(1600); // Pause for opening the console. If the script does not work, increase the value.
// Pasting the script
sp.SendModifiedVKeys([vk.LCONTROL], [vk.VK_V]);
//sp.Sleep(200);
// Executing the script
sp.SendKeys("{ENTER}");
// Closing the developer console
sp.SendVKey(vk.F12);
// Restoring the old clipboard content
//sp.Sleep(200);
clip.SetText(oldClipboard);
}
toggleVideoSpeed();
if you want to manually select the speed each time Code:
function toggleVideoSpeed() {
var script = `
(function(){
var speed = prompt("Set playback rate:", "1.5");
if (speed != null && speed != "") {
var videos = document.querySelectorAll('video');
videos.forEach(function(v) {
v.playbackRate = parseFloat(speed);
});
var messageDiv = document.createElement('div');
messageDiv.style.position = 'fixed';
messageDiv.style.top = '60px';
messageDiv.style.left = '50%';
messageDiv.style.transform = 'translateX(-50%)';
messageDiv.style.backgroundColor = 'black';
messageDiv.style.color = 'white';
messageDiv.style.padding = '10px 20px';
messageDiv.style.borderRadius = '5px';
messageDiv.style.zIndex = 10000;
messageDiv.style.fontSize = '24px';
messageDiv.style.fontFamily = 'Segoe UI, Arial, sans-serif';
messageDiv.style.textAlign = 'center';
messageDiv.textContent = 'Скорость воспроизведения: ' + speed + 'x';
document.body.appendChild(messageDiv);
// Removing the element after 2 seconds
setTimeout(function() {
document.body.removeChild(messageDiv);
}, 2000);
}
})();
`;
var oldClipboard = clip.GetText();
clip.SetText(script);
sp.SendVKey(vk.F12);
sp.Sleep(2000); // // Pause for opening the console. If the script does not work, increase the value.
sp.SendModifiedVKeys([vk.LCONTROL], [vk.VK_V]);
sp.SendKeys("{ENTER}");
sp.SendVKey(vk.F12);
clip.SetText(oldClipboard);
}
toggleVideoSpeed();
Edited by user Thursday, July 18, 2024 3:52:33 PM(UTC)
| Reason: updated 2
|