Giter Site home page Giter Site logo

Comments (6)

SanderRonde avatar SanderRonde commented on May 28, 2024

Unfortunately there's no easy way to do this. Chrome (and other browsers) are pretty strict with shielding off incognito. However, you can launch the chrome program in incognito mode and pass the URL you want as an argument. This might be a bit tough to do if you're not that experienced with the commandline and how windows works (I'll assume you're on windows).

The goal is to launch the chrome process with the --incognito flag and the new URL as the argument. This will open that tab in incognito mode. Here's a link to the syntax for the flag: https://stackoverflow.com/questions/11857123/how-to-open-a-url-in-chrome-incognito-mode. In order to do that you need to register a new URL scheme that opens given parameter in incognito mode. You can use the "opening a desktop program" wiki page for setting up a custom scheme, which can be found here: https://github.com/SanderRonde/CustomRightClickMenu/wiki/Opening-a-desktop-program. The only tricky part is getting the syntax of the custom URI scheme correct (i.e. the order of the arguments should be correct). For some help on that check out this page: https://msdn.microsoft.com/en-us/windows/desktop/aa767914. Unfortunately I'm not an expert on the area of custom URI schemes so I can't help you a lot in that regard. It's also for a big part a matter of trying until you get it right.

I hope this can help you somehow and if there's anything else I can help you with please let me know.

from customrightclickmenu.

tbmuc avatar tbmuc commented on May 28, 2024

Hello, may I ask you a followup question?

I created an registry entry for "mychrome" whith the value ""C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" "%1" "--incognito""

When I call mychrome:// from the browser, a incognito window is opened but I have no clue, how to pass the value (eg). mychrome://http://www.google.de does not work, neither mychrome://abc .

from customrightclickmenu.

SanderRonde avatar SanderRonde commented on May 28, 2024

I tried to do this myself as well and found that the reason it doesn't work is the following. %1 passes the full matched scheme to the target application. This means that if you run mychrome://abc chrome gets run with "mychrome://abc". Since this is, again, a URI scheme (it's the very same one you passed in the first place), it will basically keep infinitely opening new chrome windows. I assume someone has added a check for that in the chrome code because that's not what happens.

What you can see though, is that if you invalidate the scheme (for example you don't use "%1" but "'%1'" with added quotes inside), it will open the passed URL but it's invalid. Because of this there's no infinite loop and it opens it.

The result here is that it's not directly possible to open a URL in chrome, as chrome gets the whole scheme as a parameter and doesn't know what to do with it. Something you can do though, is to create/use a different program that slices out the custom scheme and then finally calls chrome with the sliced version. Fortunately, I've gone ahead and created a program that does that over here. All you need for the program is python. Here's a short summary of how it works, since the program itself contains a better explanation that you can see when you pass "-h".

Call the program with the scheme as the first parameter (this is the "%1") in the scheme in the registry. Then pass what you want to be run, replacing the to-be-passed data with a "#" followed by the index of the to-be-passed value in the scheme. Since this sounds a bit complicated, here's an example:

In the registry (where python.exe and sliceuri.py's locations will change)
"python.exe" "sliceuri.py" "%1" "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" "--incognito" "#1"

This will be called (when using the URI mychrome://www.google.com) as:
python.exe sliceuri.py "mychrome://www.google.com" "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" "--incognito" "#1"

And will be translated to run:
C:\Program Files (x86)\Google\Chrome\Application\chrome.exe "--incognito" "www.google.com"

from customrightclickmenu.

tbmuc avatar tbmuc commented on May 28, 2024

from customrightclickmenu.

SanderRonde avatar SanderRonde commented on May 28, 2024

Oh yeah that's actually quite a bit limitation. I've revised the script to take this into account. You can now pass "-s" as the first argument to ignore any slashes past the scheme itself. The URL to the script will be the same, you'll just have to re-download it.

from customrightclickmenu.

tbmuc avatar tbmuc commented on May 28, 2024

from customrightclickmenu.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.