<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ incognito - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ incognito - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Tue, 23 Jun 2026 22:45:49 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/incognito/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ How to outsmart incognito block ]]>
                </title>
                <description>
                    <![CDATA[ By Mátyás Fodor Recently I came across several sites that showed a warning or paywall because I was using incognito mode. I think it is unfair. I should be allowed to use whatever browser and mode I want. This is a way to enforce their tracking tools... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/disabling-browser-incognito-check-cc84288e89b3/</link>
                <guid isPermaLink="false">66c349341718310854c7aad6</guid>
                
                    <category>
                        <![CDATA[ hacking ]]>
                    </category>
                
                    <category>
                        <![CDATA[ incognito ]]>
                    </category>
                
                    <category>
                        <![CDATA[ JavaScript ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Tampermonkey ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web Development ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Wed, 27 Dec 2017 05:34:54 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*BgAlYI-fuv9BrHQHPnNZoQ.jpeg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Mátyás Fodor</p>
<p>Recently I came across several sites that showed a warning or paywall because I was using incognito mode. I think it is unfair. I should be allowed to use whatever browser and mode I want. This is a way to enforce their tracking tools. I know that <a target="_blank" href="https://thevpn.guru/is-incognito-mode-safe-secure/">incognito is not safe</a> but it’s the bare minimum you can do to avoid ads to track you.</p>
<p>The whole thing took me about two hours and I learned a lot about browser extensions and hacking client-side code as an end user. I thought this might be worth sharing.</p>
<p>First, I had to look up how to detect private mode. As per my best knowledge, there’s no browser API to detect private mode directly, so I was pretty sure it is a sneaky little script. <a target="_blank" href="https://stackoverflow.com/a/27805491/2419215">This</a> StackOverflow answer gave me a hint, so I knew I’d have to look for <code>webkitRequestFileSystem</code>. I found <a target="_blank" href="https://gist.github.com/matyasfodor/15e8863ab15baf4791a5fa4c748b64af">this</a> bit in one of those private loathing sites’ minified JavaScript code. Here’s the exciting part:</p>
<p>I could test the <a target="_blank" href="https://gist.github.com/matyasfodor/15e8863ab15baf4791a5fa4c748b64af">module</a> by pasting it in incognito and public browser window dev console and run:</p>
<pre><code><span class="hljs-keyword">var</span> <span class="hljs-built_in">module</span> = {};incognito(<span class="hljs-literal">null</span>, <span class="hljs-built_in">module</span>);<span class="hljs-built_in">module</span>.exports.detectIncognito().then(<span class="hljs-built_in">console</span>.log)
</code></pre><p>Bingo! This is it, I just have to find a way not to call the error callback in <code>window.webkitRequestFileSystem(..)</code>. The easiest way is to monkey patch the function:</p>
<pre><code>(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">webkitRequestFileSystem</span>) </span>{  <span class="hljs-built_in">window</span>.webkitRequestFileSystem = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">t, s, success, error</span>) </span>{    webkitRequestFileSystem(t, s, success, success);  }})(<span class="hljs-built_in">window</span>.webkitRequestFileSystem);
</code></pre><p>If you’re not familiar with the technique, <a target="_blank" href="https://www.audero.it/blog/2016/12/05/monkey-patching-javascript/">monkey patching</a> is a way to add, modify, or suppress the default behavior of a piece of code at runtime without changing its original source code.</p>
<p><strong>Detour 1:</strong> First I started writing my own chrome extension using <a target="_blank" href="https://extensionizr.com">Extensionizr</a>. It’s a great tool generating Chrome extension boilerplate code. But in the end, I found an easier solution.</p>
<p>Whenever it comes to customizing websites I use <a target="_blank" href="https://tampermonkey.net/">Tampermonkey</a> (for example <a target="_blank" href="https://gist.github.com/rjrudman/a472924d3fb078bd73bb12066e0319a0">hiding job ads</a> on Stack Overflow when I really shouldn’t spend time on looking for new positions). You don’t have to install a n+1th extension, and it provides a nice interface to manage your scripts. Ok, nice is probably an exaggeration, it’s ugly but handy.</p>
<p>So I added the monkey patch script I referenced above, already giggling how easy it was, but bummer, it didn’t work. I tried a few other things for example:</p>
<pre><code><span class="hljs-built_in">window</span>.foobar = <span class="hljs-string">'baz'</span>;
</code></pre><p>But in the dev console, this property was absent from the <code>window</code> variable. It turned out <a target="_blank" href="https://stackoverflow.com/a/20513730/2419215">content scripts</a> are running in an isolated environment, they only share the DOM with the webpage’s scripts. I started to work with the referenced solution from SO. There was one very important thing though, I had to execute this code before the current page’s code. Here’s what I came up with:</p>
<pre><code><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">injectScript</span>(<span class="hljs-params">file_path, node</span>) </span>{        <span class="hljs-keyword">var</span> element = <span class="hljs-built_in">document</span>.createElement(<span class="hljs-string">'script'</span>);        element.setAttribute(<span class="hljs-string">'type'</span>, <span class="hljs-string">'text/javascript'</span>);        element.setAttribute(<span class="hljs-string">'src'</span>, file_path);        element.setAttribute(<span class="hljs-string">'async'</span>, <span class="hljs-literal">false</span>);        node.appendChild(element);}injectScript(url, <span class="hljs-built_in">document</span>.documentElement);
</code></pre><p><strong>Detour 2:</strong> As I started with an extension, loading another JavaScript file was trivial. However it’s not the case with Tampermonkey scripts (at least I don’t know about it). So I decided to put my code in a GitHub gist, and tried to load the <a target="_blank" href="https://gist.githubusercontent.com/matyasfodor/ab6c92e32a35ebae0bebedff8e7cf569/raw/4f97a8fb702ae8710ba9542b5a7a8127495cf9e4/fakepublic.js">raw file</a>. But then the browser was complaining about its MIME type. Finally I ended up using <a target="_blank" href="https://rawgit.com/">https://rawgit.com/</a>, which was exactly the right tool for this.</p>
<p>I realized that I should add those few lines of monkey patch code as a string, and fill in the script element’s text with that. Here’s my final solution:</p>
<p>An important thing to know if you work with Tampermonkey in incognito mode: your changes made in incognito mode won’t appear in normal mode, and vice versa: you have to close all your private windows if you want to try your latest changes made in public mode.</p>
<p><strong>Be careful!</strong> If you decide to use my script, you have to know that this <em>might</em> (although not very likely) break some web pages. You can always turn these off in Tampermonkey. Use it at your own risk.</p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
