Protocol handler configuration

Discussions about the development and maturation of the platform code (UXP).
Warning: may contain highly-technical topics.

Moderators: trava90, athenian200

Pelican
Lunatic
Lunatic
Posts: 276
Joined: 2018-02-23, 06:51

Protocol handler configuration

Post by Pelican » 2023-06-23, 23:54

I have been testing the PaleMoonURL registry setting for Protocol Handler on both version 32 and 28 (Windows) and found that it does work but with problems.

Using a link like PaleMoonURL://uploaded-media.link/pages/10037_success.html I get a popup like

https://uploaded-media.link/images/1003 ... arning.jpg

So far, so good, but if I tick the box for "Always allow" it keeps opening that page in a new tab... endlessly, resulting in 100's of tabs. If I don't tick the box and click "Open Link" it opens the page (but still prompts until I cancel). Not sure if I had to modify my registry key or not. However I have noticed that FirefoxURL does not work yet the registry keys look identical. I have no idea what "-osint" or "-url" mean and found no explanation from search. Perhaps PM imitated Firefox but was never tested, because after all, there may be little use for this.

https://uploaded-media.link/images/10037_registry1.jpg

https://uploaded-media.link/images/10037_registry3.jpg

The important questions for me at this point is:

1. How to prevent multiple instances of opening that same tab?
2. How to undo the setting created by ticking "Always allow"? Could not find it in about:config, registry or cookies.

PS: tried to add the images but got an error... It was not possible to determine the dimensions of the image. Please verify that the URL you entered is correct.

User avatar
Moonchild
Project founder
Project founder
Posts: 38665
Joined: 2011-08-28, 17:27
Location: Sweden

Re: Protocol handler configuration

Post by Moonchild » 2023-06-24, 07:46

I don't have a quick answer to (1) but for (2) you want to look in Pale Moon's preferences, category "Applications"
"There is no point in arguing with an idiot, because then you're both idiots." - Anonymous
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

Pelican
Lunatic
Lunatic
Posts: 276
Joined: 2018-02-23, 06:51

Re: Protocol handler configuration

Post by Pelican » 2023-06-24, 21:24

Moonchild wrote:
2023-06-24, 07:46
for (2) you want to look in Pale Moon's preferences, category "Applications"
That worked and I was able to revert that option to "Always ask".

https://uploaded-media.link/images/1003 ... s-apps.jpg

But now that I have prevented multiple tabs from opening, I can see that the action is not actually opening the designated link. Even when I select Pale Moon and click to "Remember choice..." it fails to open the link... I stopped it at 807 tabs and they all display "about:blank".

Question: where exactly is that "Launch Application" setting stored?

Kris_88
Board Warrior
Board Warrior
Posts: 1168
Joined: 2021-01-26, 11:18

Re: Protocol handler configuration

Post by Kris_88 » 2023-06-25, 00:24


Pelican
Lunatic
Lunatic
Posts: 276
Joined: 2018-02-23, 06:51

Re: Protocol handler configuration

Post by Pelican » 2023-06-25, 01:27

The recommended procedure for Chrome did not work. In any case Chrome will be very different.

Kris_88
Board Warrior
Board Warrior
Posts: 1168
Joined: 2021-01-26, 11:18

Re: Protocol handler configuration

Post by Kris_88 » 2023-06-25, 01:39

Pelican wrote:
2023-06-24, 21:24
Question: where exactly is that "Launch Application" setting stored?
See PM_profile_folder\mimeTypes.rdf
Pelican wrote:
2023-06-25, 01:27
The recommended procedure for Chrome did not work.
Another thing is important there. The system transmits a custom URL and the browser does not know what to do with it.

Pelican
Lunatic
Lunatic
Posts: 276
Joined: 2018-02-23, 06:51

Re: Protocol handler configuration

Post by Pelican » 2023-06-25, 02:12

Kris_88 wrote:
2023-06-25, 01:39
See PM_profile_folder\mimeTypes.rdf
Found mine at C:\Users\MyName\AppData\Roaming\Moonchild Productions\Pale Moon\Profiles\202ruplk.default\
Interesting but nothing needs changing there.

Kris_88
Board Warrior
Board Warrior
Posts: 1168
Joined: 2021-01-26, 11:18

Re: Protocol handler configuration

Post by Kris_88 » 2023-06-25, 02:33

Pelican wrote:
2023-06-25, 02:12
Found mine at C:\Users\MyName\AppData\Roaming\Moonchild Productions\Pale Moon\Profiles\202ruplk.default\
Interesting but nothing needs changing there.
You can define a custom URL scheme here, which will become known for Pale Moon.
For example, I made a description for the protocol test://
It works, the batch file is run and receives an url as a parameter.
u1.png
You do not have the required permissions to view the files attached to this post.

Kris_88
Board Warrior
Board Warrior
Posts: 1168
Joined: 2021-01-26, 11:18

Re: Protocol handler configuration

Post by Kris_88 » 2023-06-25, 02:38

a.htm

Code: Select all

<html>
<body>
<a href="test://aaaaa">test://aaaaa</a>
</body>
</html>
test.cmd

Code: Select all

echo %1
pause
u2.png
You do not have the required permissions to view the files attached to this post.

Pelican
Lunatic
Lunatic
Posts: 276
Joined: 2018-02-23, 06:51

Re: Protocol handler configuration

Post by Pelican » 2023-06-25, 03:04

Kris_88 wrote:
2023-06-25, 02:38
a.htm
This is not quite the use of protocol handler that I was refering to. I need to place a link on a web page that will launch Pale Moon from any other web browser and open the url in that link. To make that happen, it starts with adding a registry key to associate PM to the link so that the hyperlink used can be like PaleMoonURL://example.com/some-page.html

Where it can be useful is to provide link that opens in Pale Moon regardless of which browser the user is using, to login pages that require Pale Moon, for example if the next pages require the use of NPAPI plugins.

Kris_88
Board Warrior
Board Warrior
Posts: 1168
Joined: 2021-01-26, 11:18

Re: Protocol handler configuration

Post by Kris_88 » 2023-06-25, 03:13

Pelican wrote:
2023-06-25, 03:04
This is not quite the use of protocol handler that I was refering to.
You asked: "Question: where exactly is that "Launch Application" setting stored?"
I answered you.
If you don't need it, then why are you asking? I don't have endless free time.
Pelican wrote:
2023-06-25, 03:04
it starts with adding a registry key to associate PM to the link so that the hyperlink used can be like PaleMoonURL://example.com/some-page.html
Regarding this problem, I have already given information with which you can make it work.

Pelican
Lunatic
Lunatic
Posts: 276
Joined: 2018-02-23, 06:51

Re: Protocol handler configuration

Post by Pelican » 2023-06-25, 04:23

Kris_88 wrote:
2023-06-25, 03:13
Question: where exactly is that "Launch Application" setting stored?
I meant when one ticks to "allow Always", where is that preference stored?
Kris_88 wrote:
2023-06-25, 03:13
Regarding this problem, I have already given information with which you can make it work.
Actually no. The reference for adding a protocol handler to Chrome is not relevant for Pale Moon. In fact that recommendation doesn't even work for Chrome.

Kris_88
Board Warrior
Board Warrior
Posts: 1168
Joined: 2021-01-26, 11:18

Re: Protocol handler configuration

Post by Kris_88 » 2023-06-25, 04:41

Pelican wrote:
2023-06-25, 04:23
The reference for adding a protocol handler to Chrome is not relevant for Pale Moon.
Of course.
But there is an explanation - why it does not work. The browser cannot open a link like PaleMoonURL://, it can only launch a third-party application. If you choose PaleMoon itself as this application, then it will run itself again and again. You need to make an adapter - the batch file that converts the link and launches a browser.
Actually, here is the whole problem, now you know the reason...
And now - you can do it yourself, especially since you have an example of a batch file.

Pelican
Lunatic
Lunatic
Posts: 276
Joined: 2018-02-23, 06:51

Re: Protocol handler configuration

Post by Pelican » 2023-06-25, 05:18

A batch file is of no use. Yes, we are trying to open Pale Moon from another application (not from Pale Moon). I already explained in my first post how to create the registry key for any browser... that process is repeated below.

The link below can be visited in any browser (with Pale Moon closed) and by clicking the Firefox link it will indeed open Firefox, and if you click the link for Pale Moon it will indeed open Pale Moon. But in no case will the requested page open and with Pale Moon it owns new tabs endlessly. But before you use those test links you need to add a protocol handler in Windows registry. For now we are only testing in Windows. How it works on mobile has yet to be tested. I tried the mac version of PM and it doesn't have registry key set. On Windows PM does already have a registry key set (PaleMoonURL) but I think that I had to modify it to make it work, even as badly as it does.

The problems to fix may need fixing in PM source:

1. Nominated link does not open. Instead it opens "about:blank" (happens in both PM and FF).
2. PM opens multiple tabs if "Allow Always" is ticked (does not happen in FF).
3. Does the registry key need to be different to make this work properly?

How to add registry key for protocol Handler (if not already exists):

1. Create KEY at Computer\HKEY_CLASSES_ROOT\PaleMoonURL
2. Add new STRING VALUE for "URL Protocol" and leave value blank
3. Create KEY at Computer\HKEY_CLASSES_ROOT\PaleMoonURL\shell
4. Create KEY at Computer\HKEY_CLASSES_ROOT\PaleMoonURL\shell\open
5. Create KEY at Computer\HKEY_CLASSES_ROOT\PaleMoonURL\shell\open\command
6. Modify data for Computer\HKEY_CLASSES_ROOT\PaleMoonURL\shell\open\command\... "C:\Program Files (x86)\Pale Moon\palemoon.exe" -osint -url "%1"

To test on Firefox and Chrome you will need to create registry keys for them using the steps above. Then you can test this link...

https://uploaded-media.link/pages/10037_test-launcher.html

Note: It does not matter if the browser used to start with is Pale Moon or not because it still opens "about:blank" endlessly.

Kris_88
Board Warrior
Board Warrior
Posts: 1168
Joined: 2021-01-26, 11:18

Re: Protocol handler configuration

Post by Kris_88 » 2023-06-25, 05:52

Pelican wrote:
2023-06-25, 05:18
6. Modify data for Computer\HKEY_CLASSES_ROOT\PaleMoonURL\shell\open\command\... "C:\Program Files (x86)\Pale Moon\palemoon.exe" -osint -url "%1"
Wonderful.
Please tell me what string is passed to the Pale Moon when you open a link "PaleMoonURL://aaaaa/bbbbb" ?
What value is substituted for parameter "%1" in the line:
"C:\Program Files (x86)\Pale Moon\palemoon.exe" -osint -url "%1"

Pelican
Lunatic
Lunatic
Posts: 276
Joined: 2018-02-23, 06:51

Re: Protocol handler configuration

Post by Pelican » 2023-06-25, 06:26

Kris_88 wrote:
2023-06-25, 05:52
Please tell me what string is passed to the Pale Moon when you open a link "PaleMoonURL://aaaaa/bbbbb" ?
What value is substituted for parameter "%1" in the line:
"C:\Program Files (x86)\Pale Moon\palemoon.exe" -osint -url "%1"
How can I do this? Within seconds I can have 800+ tabs open displaying "about:blank" with no option of debugging/view source.

You can test my page using any browser and clicking the "Test Pale Moon" link. But check your registry entry for PaleMoonURL first.

Kris_88
Board Warrior
Board Warrior
Posts: 1168
Joined: 2021-01-26, 11:18

Re: Protocol handler configuration

Post by Kris_88 » 2023-06-25, 06:37

Pelican wrote:
2023-06-25, 06:26
How can I do this? Within seconds I can have 800+ tabs open displaying "about:blank" with no option of debugging/view source.
No problem... I'll tell you.
%1 is replaced with url.

That is, the system executes the command:
"C:\Program Files (x86)\Pale Moon\palemoon.exe" -osint -url "PaleMoonURL://aaaaa/bbbbb"
This command starts Palemoon and forces it to open a link "PaleMoonURL://aaaaa/bbbbb".
Palemoon creates a new empty tab and tries navigate it to "PaleMoonURL://aaaaa/bbbbb".
Since "PaleMoonURL" is not "http" or "https", the protocol handler for "PaleMoonURL" is started.

The system executes the command:
"C:\Program Files (x86)\Pale Moon\palemoon.exe" -osint -url "PaleMoonURL://aaaaa/bbbbb"
This command starts Palemoon and forces it to open a link "PaleMoonURL://aaaaa/bbbbb".
Palemoon creates a new empty tab and tries navigate it to "PaleMoonURL://aaaaa/bbbbb".
Since "PaleMoonURL" is not "http" or "https", the protocol handler for "PaleMoonURL" is started.

The system executes the command:
"C:\Program Files (x86)\Pale Moon\palemoon.exe" -osint -url "PaleMoonURL://aaaaa/bbbbb"
This command starts Palemoon and forces it to open a link "PaleMoonURL://aaaaa/bbbbb".
Palemoon creates a new empty tab and tries navigate it to "PaleMoonURL://aaaaa/bbbbb".
Since "PaleMoonURL" is not "http" or "https", the protocol handler for "PaleMoonURL" is started.

The system executes the command:
"C:\Program Files (x86)\Pale Moon\palemoon.exe" -osint -url "PaleMoonURL://aaaaa/bbbbb"
This command starts Palemoon and forces it to open a link "PaleMoonURL://aaaaa/bbbbb".
Palemoon creates a new empty tab and tries navigate it to "PaleMoonURL://aaaaa/bbbbb".
Since "PaleMoonURL" is not "http" or "https", the protocol handler for "PaleMoonURL" is started.
... and so on.

Pelican
Lunatic
Lunatic
Posts: 276
Joined: 2018-02-23, 06:51

Re: Protocol handler configuration

Post by Pelican » 2023-06-25, 07:41

Kris_88 wrote:
2023-06-25, 06:37
Since "PaleMoonURL" is not "http" or "https", the protocol handler for "PaleMoonURL" is started... and so on.
Hmm... it has been told that the handler is for a url. PM opens a new tab repeatedly but FF does not... just one tab displaying "about:blank".

Pelican
Lunatic
Lunatic
Posts: 276
Joined: 2018-02-23, 06:51

Re: Protocol handler configuration

Post by Pelican » 2023-06-27, 22:19

A protocol handler added to registry doesn't open the nominated url because it doesn't know that its meant to be "https:". All browsers are failing here. Unfortunately PM reacts badly and keeps trying to open over and over again resulting in 100's of new tabs... that looping needs to be prevented as it creates a dilemma for the average user.

If PM can be modified to replace PaleMoonURL:// with https:// even better. In the meantime, for our use we can use an EXE to launch the browser while converting PaleMoonURL:// to https://

Potkeny
Fanatic
Fanatic
Posts: 159
Joined: 2018-08-03, 17:00

Re: Protocol handler configuration

Post by Potkeny » 2023-06-27, 23:26

Pelican wrote:
2023-06-27, 22:19
If PM can be modified to replace PaleMoonURL:// with https:// even better.
Would something like Url Rewriter addon work? Or is that trying to read/modify the url "too late" in the process?