Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)

like image 494
ModS Avatar asked Apr 19 '13 20:04

ModS


People also ask

Can Tampermonkey scripts be malicious?

Let's quickly summarize: Tampermonkey itself is neither safe nor unsafe; it's just a tool for managing user scripts. However, many user scripts can potentially be dangerous and contain malware. Other user scripts can be bad in the sense that they have unintended side effects, like bad CPU performance.

Can you run extensions in Incognito?

Extensions are not allowed to be enforced by the administrators in Incognito, whereas users can individually enable extensions in Incognito mode.

What is the difference between Greasemonkey and Tampermonkey?

While Greasemonkey supports Firefox and some other open-source browsers, Tampermonkey supports all the major browsers including Firefox, Chrome, and Safari.

Can a webpage detect a Tampermonkey userscript?

Bottom line, is for a "read only" userscript, that does not require global libraries in @grant none mode, the page cannot detect it.


1 Answers

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.

like image 66
derjanb Avatar answered Nov 07 '22 23:11

derjanb