[tor-bugs] #26279 [Applications/Tor Browser]: Needing help with a custom browser protocol

Tor Bug Tracker & Wiki blackhole at torproject.org
Sun Jun 3 21:21:55 UTC 2018


#26279: Needing help with a custom browser protocol
--------------------------------------+-----------------------------
 Reporter:  AlienDrew                 |          Owner:  cypherpunks
     Type:  enhancement               |         Status:  closed
 Priority:  Low                       |      Milestone:
Component:  Applications/Tor Browser  |        Version:
 Severity:  Normal                    |     Resolution:  fixed
 Keywords:                            |  Actual Points:
Parent ID:                            |         Points:
 Reviewer:                            |        Sponsor:
--------------------------------------+-----------------------------
Changes (by AlienDrew):

 * status:  new => closed
 * resolution:   => fixed


Comment:

 I created a this script that could be used as a browser protocol to say,
 like open a link from chrome, but in the TOR Browser. I decided to change
 the name of the protocol itself to "tor-browser" because it kinda makes
 sense.

 Below is the code I had put together, and it receives the input like any
 other protocol through the %1 param: ("opentor.bat")
 {{{
 @echo off
 REM Created by AlienDrew thealiendrew at gmail.com

 if [%1] == [] got :eof

 set "browser_dir=%windir:~0,2%\Program Files (x86)\Tor
 Browser\Browser\firefox.exe"
 set "url=%1"

 :: for some reason, args passed by the system get screwy
 echo %1 | find "tor-browser://" > nul
 if errorlevel 0 set "url=%url:~15,-1%"

 :: I do admit that this could cause problems in the future
 tasklist /fi "imagename eq firefox.exe" | find ":" > nul

 if errorlevel 1 (
 start /b "" "%browser_dir%" --allow-remote --new-tab "%url%"
 endlocal && exit
 )

 start /b "" "%browser_dir"% --allow-remote "%url%"
 endlocal && exit
 }}}

 And this I had put in the "Tor Browser\Browser" directory. As for Tor, I
 decided to put it in the "Program Files (x86)" but the script could easily
 be changed to do more than that.

 But what pieces this together is the registry keys needed to create to
 protocol. Listed below, some commands that you can use in a .bat to
 register the keys needed: (admin access required!)
 {{{
 @echo off & setlocal
 set "tor_dir=%windir:~0,2%\Program Files (x86)\Tor Browser"

 reg add HKCR\tor-browser /ve /d "URL:tor-browser Protocol" /f
 reg add HKCR\tor-browser /v "URL Protocol" /t REG_SZ /f
 reg add HKCR\tor-browser\shell\open\command /ve /d
 "\"%tor_dir%\Browser\opentor.bat\" \"%%1\"" /f
 :: same directory as when I first mentioned the "open to.bat" file
 }}}

 But these two things combined with the browser should work just fine. Not
 the best solution I'm sure but it works for me.

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/26279#comment:5>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list