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
| /// 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")); |
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
| /// 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; |