Skip to content

Instantly share code, notes, and snippets.

View tkhorik's full-sized avatar
😀
hello

Dmitry tkhorik

😀
hello
View GitHub Profile
@tkhorik
tkhorik / YouTube — disable autoplay until I press Play-2.0.0.user.js
Last active January 1, 2026 09:49
Tampermonkey script preventing autoplay in YouTube on Chrome
// ==UserScript==
// @name YouTube — disable autoplay until I press Play
// @namespace local.dmitry.youtube.autoplay.block
// @version 2.0.0
// @description Prevent YouTube videos from auto-playing on open; only play after a recent user gesture.
// @author you
// @match https://www.youtube.com/*
// @run-at document-start
// @grant none
// ==/UserScript==
ChromeOptions options = new ChromeOptions();
options.addArguments("--user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.4 Safari/605.1.15");
clearBrowserCookies();
Configuration.browserCapabilities.setCapability(ChromeOptions.CAPABILITY, options);