Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Open links in external browsers #22

Closed
wattelengineering opened this issue Jun 6, 2022 · 16 comments · Fixed by #42
Closed

Feature Request: Open links in external browsers #22

wattelengineering opened this issue Jun 6, 2022 · 16 comments · Fixed by #42
Labels
enhancement New feature or request

Comments

@wattelengineering
Copy link

It would be great to be able to open non-discord links in external browsers with one click. Currently, datcord will open links in a new window of itself (firefox, effectively). This is a little inconvenient since I mostly want to open them in my default browser. Work-arounds include:

  1. Copy/pasting URL.
  2. Installing an add-on such as Open With (https://addons.mozilla.org/en-US/firefox/addon/open-with/) and using right-click menu.
  3. Dragging the link to the preferred browser window. This is not bad with multiple monitors, but a single click would be nicer.

I think that's fairly self-explanatory, but if feel free to ask questions if I haven't been specific enough.

@gamingdoom gamingdoom added the enhancement New feature or request label Jun 6, 2022
gamingdoom added a commit that referenced this issue Sep 6, 2022
gamingdoom added a commit that referenced this issue Sep 6, 2022
gamingdoom added a commit that referenced this issue Oct 8, 2022
Add preliminary "open with" support for #22
@gamingdoom
Copy link
Owner

gamingdoom commented Oct 8, 2022

In my latest commit to master, I have made a preliminary implementation of Open With. To activate open with on Datcord:

  • Run datcord "about:addons" in the shell.
  • Click the "meatball menu" (3 horizontal dots) next to the on/off switch for Open With and select preferences.
  • Follow all setup instructions for Open With.
  • Press ctrl+w to close tabs until Datcord closes.

I would like to refine this setup procedure but for now, it works.

@Cobradabest
Copy link

Hey, I installed this program via appimage, and I'm not sure what you mean by shell/command line? I tried to use the command in the terminal, and it didn't recognise it, and it didn't do anything different if I used it with the appimage file?

@gamingdoom
Copy link
Owner

@Cobradabest the newest release (0.3.2) is now available and there are now special instructions in the README for AppImages. The AppImage for Datcord now has support for arguments. The terminal is the correct place to run the commands.

@wattelengineering
Copy link
Author

Was this patch just about making the installation of addons easier? I had already installed Open With (and still have it installed), but was hoping for a "one-click" solution. Much like if you click a link in the official Discord app (or Slack or whatever). Is that possible or just too hard?

@gamingdoom
Copy link
Owner

This patch just pre-installs the Open With extension. I was looking for another solution but I couldn't find one (there is surprisingly little documentation about this type of stuff). I am still looking for a more elegant solution for the setup. I might have to make a custom extension to do this.

@gamingdoom gamingdoom mentioned this issue Jan 25, 2023
@gamingdoom
Copy link
Owner

I have implemented a solution to this problem that opens every link in the default browser. I registered a custom protocol and I have setup the handler to be a bash script (linux) or a batch script (windows) which opens your default browser with the link. I will be releasing v0.4.0 with these changes.

gamingdoom added a commit that referenced this issue Jan 25, 2023
@gamingdoom gamingdoom reopened this Jan 25, 2023
@gamingdoom
Copy link
Owner

It turns out that this stills needs a little more work for appimages.

gamingdoom added a commit that referenced this issue Jan 26, 2023
@gamingdoom gamingdoom reopened this Jan 26, 2023
@wattelengineering
Copy link
Author

Does the Linux script just run xdg-open? Because I think that's all that's required on that platform. Unsure about others. If you need help testing it, let me know.

@gamingdoom
Copy link
Owner

Does the Linux script just run xdg-open? Because I think that's all that's required on that platform. Unsure about others. If you need help testing it, let me know.

Yes, the script just runs xdg-open but Firefox sends the data with the name of the protocol still attached and I need to remove it. I must put an executable in the policies.json so I need to make a script to remove the protocol. I am having trouble doing this with the appimage because I can not use any environment variables or relative paths in policies.json so I need to have the script somewhere on the system in a constant and known location.

@wattelengineering
Copy link
Author

That sounds really annoying.

Sorry if these questions aren't helpful, but can you give me an example of what Firefox sends to xdg-open?

Also, I take it the script can't just be in the same directory as the executable (i.e. "./script.sh" or just "script.sh")? You mention no relative paths, but maybe the current directory is an exception?

Does modifying security.fileuri.strict_origin_policy to false change anything?

@gamingdoom
Copy link
Owner

@akengconsulting for example, Firefox would send nameofprotocol:https://github.com to xdg-open. Using just the script name or ./script doesn't work (The error that I get when I try to use a relative path is "Unable to create handler executable (./script)"). It looks like the file in Firefox's source code to edit to change this behavior would be called Policies.jsm according to the terminal output. Setting security.fileuri.strict_origin_policy to false doesn't seem to do anything either.

@wattelengineering
Copy link
Author

OK thanks. I'm out of ideas for now.

@wattelengineering
Copy link
Author

I suppose there's one more thing I can think of. On each start, maybe you can copy the script to a known location (e.g. somewhere in /tmp) and then use that for the duration of the session? Not sure how robust it would be.

@gamingdoom
Copy link
Owner

I suppose there's one more thing I can think of. On each start, maybe you can copy the script to a known location (e.g. somewhere in /tmp) and then use that for the duration of the session? Not sure how robust it would be.

This works and it also seems like a very good way of going about this because I can have the path to the script controlled by Datcord and not static which isn't a great idea for obvious reasons. I can just add to my AppRun that copy the script to /tmp and remove the script from /tmp. I think I will also launch Datcord using a script and have that handle moving the script.

@gamingdoom
Copy link
Owner

The moving script idea works great but now I am having issues with Firefox's profiles. When I launch Firefox through the script it tells me Firefox already running. For now I am selecting the default profile when launching but this only works sometimes.

@gamingdoom
Copy link
Owner

The moving script idea works great but now I am having issues with Firefox's profiles. When I launch Firefox through the script it tells me Firefox already running. For now I am selecting the default profile when launching but this only works sometimes.

I fixed this issue and possibly many other issues involving profiles by making datcord have it's own profile folder (.datcord instead of .mozilla). Now, things are working great and I think this is pretty much ready.

gamingdoom added a commit that referenced this issue Feb 4, 2023
v0.4.0. Fix #22, use cross compilation for Windows builds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants