Search code examples
tampermonkeyincognito-mode

Tampermonkey script that runs only in incognito?


Is it possible to make any script into a script that only runs on www.example.com, Only if the website is being accessed from an incognito window? (chrome)


Solution

  • I've added a isIncognito flag to Tampermonkey's GM_info. So you now can check the incognito mode like this:

    // ==UserScript==
    // @name       testIncognito
    // @namespace  http://tampermonkey.net/
    // @version    0.1
    // @description  enter something useful
    // @match      http://*/*
    // @copyright  2012+, You
    // ==/UserScript==
    
    if (GM_info.isIncognito) {
        alert([ GM_info.scriptHandler, 'detected incognito mode @', window.location.href ].join(' '));
    }
    

    Please not that this at the moment only is available at TM beta version 3.0.3353 and higher.