Skip to content

Instantly share code, notes, and snippets.

View Issam28's full-sized avatar

MAHMOUDI Issam Issam28

View GitHub Profile
/// disable-autoplay.js
(function () {
'use strict';
// 1. Intercept programmatic calls to HTMLMediaElement.prototype.play
const originalPlay = HTMLMediaElement.prototype.play;
HTMLMediaElement.prototype.play = function (...args) {
if (this instanceof HTMLVideoElement && !this._userApproved) {
this.pause();
return Promise.reject(new DOMException("Autoplay blocked by Userscript", "NotAllowedError"));
@Issam28
Issam28 / instagram-autoplay-fix.js
Last active July 2, 2026 08:01
prevent-insta-autoplay
/// instagram-autoplay-fix.js
(function() {
'use strict';
function isWhitelisted() {
const path = window.location.pathname;
return path.includes('/stories/') || path.includes('/direct/');
}
document.addEventListener('play', function(e) {
const video = e.target;
if (video.tagName !== 'VIDEO') return;