Tampermonkey script that runs only in incognito?
Asked Answered
P

1

11

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)

Particia answered 19/4, 2013 at 20:11 Comment(1)
This is a duplicate of "Is it possible to determine if Chrome is in incognito mode via a user-script?". The answer is the same, you must use an extension to do this. Fortunately, @derjanb has just rolled this feature into Tampermonkey.Claycomb
G
14

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.

Glyptodont answered 22/4, 2013 at 18:23 Comment(1)
Tampermonkey needs "split" mode support by the browser: developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json/…Glyptodont

© 2022 - 2024 — McMap. All rights reserved.