by nomendos on 2/13/25, 6:46 AM with 62 comments
by gavinsyancey on 2/13/25, 7:23 AM
by 28304283409234 on 2/13/25, 7:02 AM
by liendolucas on 2/13/25, 8:50 AM
by doctor_radium on 2/13/25, 7:12 AM
by tech234a on 2/13/25, 7:29 AM
[1]: https://chromewebstore.google.com/detail/autoplaystopper/ejd...
[2]: https://old.reddit.com/r/uBlockOrigin/comments/1d49ud1/manif...
by seneca on 2/13/25, 7:11 AM
by follower on 2/14/25, 8:08 AM
"I do recall a Firefox discussion about how they can't 100% block videos because there will always be another way - eg do animated gifs count, or javascript that shows a rapid sequence of images [...]"
I also recall this being a justification given for auto-playing muted or audio-less video (i.e. because blocking "efficient" muted video playback will just lead to malicious actors using "less efficient" means of "image sequence" playback thus increasing the negative impact further).
On a related note, the other day I also discovered (while debugging why an audio demo didn't work the same way it did six years ago :D ) that there's now also a concept called "Sticky Activation" which can also impact "Autoplay of Media and Web Audio APIs (in particular for AudioContexts)"[1].
----
[0] https://news.ycombinator.com/item?id=43033814
[1] https://developer.mozilla.org/en-US/docs/Web/Security/User_a...
by timothya on 2/13/25, 7:00 AM
tl;dr: The browser attempts to learn your preference for each site automatically based on how you interact with videos. You can see what it's calculated by visiting chrome://media-engagement
by nomendos on 2/13/25, 7:28 AM
by bdhcuidbebe on 2/13/25, 8:01 PM
If its your website, just set it up like you want in the video tag.
Not sure why this post wasnt removed tho. This is just general issues you could have googled for a solution or askes a site dedicated to it such as stack overflow.
by tim333 on 2/13/25, 7:26 PM
still seems to work for me?
by blackeyeblitzar on 2/13/25, 7:01 AM
by polotics on 2/13/25, 7:00 AM
by oulipo on 2/13/25, 8:10 AM
// ==UserScript==
// @name YouTube video page AutoPause
// @namespace https://greasyfork.org/en/users/13981-chk1
// @description Automatically pause YouTube videos on Youtube video pages
// @icon https://www.youtube.com/s/desktop/536ed9a8/img/favicon_96x96.png
// @include https://*.youtube.com/watch*
// @include http://*.youtube.com/watch*
// @version 0.3
// @grant none
// @run-at document-end
// ==/UserScript==
(function () {
'use strict';
/**
* Get element with selector and call callback with it.
* @param {string} selector Selector for the element.
* @param {function} callback Callback function to call with the element.
*/
function forElement(selector, callback) {
// Init forElement.timeoutCount.
if (forElement.timeoutCount === undefined) {
forElement.timeoutCount = {}
}
// Init forElement.timeoutCount[selector].
if (forElement.timeoutCount[selector] === undefined) {
forElement.timeoutCount[selector] = 0
}
// Get element.
const element = document.querySelector(selector)
// If element not found.
if (element === null) {
// try again after timeout.
setTimeout(
function () {
forElement(selector, callback)
},
(
// Base timeout.
100
*
// Increase timeout after each try.
(forElement.timeoutCount[selector]++)
)
)
}
// If element found
else {
// reset timeout count
forElement.timeoutCount[selector] = 0
// and call callback with element.
callback(element)
}
}
// Init previous video ID.
let videoIdCurr = null;
// Init paused video ID.
let videoIdPaused = null
// Init video element.
let videoElement = null
/**
* On playing event.
*/
function onPlaying() {
// If video ID has not changed from last paused one
if (videoIdPaused === videoIdCurr) {
// just return.
return
}
// Pause video
videoElement.pause()
// Update paused video ID.
videoIdPaused = videoIdCurr
}
/**
* Run on url change.
*/
function onUrlChange() {
// Get video id from url.
const videoIdNew = (new URLSearchParams(window.location.search)).get("v");
// If
if (
// did not get video id
videoIdNew === null
||
// or video id did not change
videoIdNew === videoIdCurr
) {
// just return.
return
}
// Update previous video id.
videoIdCurr = videoIdNew;
// Run for
forElement(
// video element that has src attribute
"video[src]",
function (video) {
// If video element is set
if (videoElement) {
// remove event listener from video element.
videoElement.removeEventListener("playing", onPlaying);
}
// Update video element.
videoElement = video
// Add event listener to video element
videoElement.addEventListener("playing", onPlaying);
}
)
}
// Add event listener for
window.addEventListener(
// Youtube page data updated event.
'yt-page-data-updated',
function () {
onUrlChange();
}
);
// Run on url change once on first load.
onUrlChange();
})();
by Justta on 2/13/25, 7:22 AM
by slowmovintarget on 2/13/25, 2:26 PM
by JTyQZSnP3cQGa8B on 2/13/25, 7:44 AM