Opened 15 months ago

Closed 15 months ago

Last modified 15 months ago

#26279 closed enhancement (fixed)

Needing help with a custom browser protocol

Reported by: AlienDrew Owned by: cypherpunks
Priority: Low Milestone:
Component: Applications/Tor Browser Version:
Severity: Normal Keywords:
Cc: AlienDrew Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

So what I'm trying to do is create a protocol called "opentor" and when used like "opentor://http://www.website.com/" it'll open that website in tor from another browser. I've gotten the URI scheme working, and it's opening tor when I use it, but it's not opening the link in it. What is the problem to this? Is it a bug in tor? Is there something I'm missing? Or is it just not possible at all?

Child Tickets

Change History (6)

comment:1 Changed 15 months ago by Dbryrtfbcbhgf

This is also a ticket with helpful information on the URI scheme for macOS and Linux. #24052
This bug report may explain why you can not use the URI scheme. #22419

Last edited 15 months ago by Dbryrtfbcbhgf (previous) (diff)

comment:2 Changed 15 months ago by AlienDrew

Actually, nah, it wasn't that. I actually figured it out, but I needed to use a .bat file to configure user input correctly. I have the protocol working just fine now 😉

comment:3 Changed 15 months ago by cypherpunks

Owner: changed from phoul to cypherpunks
Status: newaccepted

comment:4 Changed 15 months ago by cypherpunks

Component: Community/Tor SupportApplications/Tor Browser
Keywords: custom uri scheme browser link url protocol website removed
Milestone: Tor: unspecified
Status: acceptednew
Type: projectenhancement
Version: Tor: unspecified

comment:5 Changed 15 months ago by AlienDrew

Resolution: fixed
Status: newclosed

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@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.

comment:6 Changed 15 months ago by AlienDrew

Oh and... Just typing something like "tor-browser://www.link-to-a-site.com/" in most browsers should work (some you have to press Ctrl-Enter to accept the protocol).

Note: See TracTickets for help on using tickets.