Created
March 24, 2018 00:26
-
-
Save lchanouha/06b51423bc60693af216ebdce37d86a8 to your computer and use it in GitHub Desktop.
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
| // ==UserScript== | |
| // @name Disable Page Visibility API | |
| // @namespace http://tampermonkey.net/ | |
| // @version 0.1 | |
| // @description Disables JS events on whole page focus/unfocus. Usefull to prevent ads stop when switching to another tab. | |
| // @author Louis Chanouha | |
| // @match *://*/* | |
| // @grant none | |
| // ==/UserScript== | |
| // Sourced from: https://stackoverflow.com/questions/47660653/chrome-extension-how-to-disable-page-visibility-api | |
| // Tested on Google Chrome 64 / Tampermonkey (24/03/2018) | |
| for (event_name of ["visibilitychange", "webkitvisibilitychange", "blur"]) { | |
| window.addEventListener(event_name, function(event) { | |
| event.stopImmediatePropagation(); | |
| }, true); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment