Triggering dialog for adding a bookmark from the web page

General project discussion.
Use this as a last resort if your topic does not fit in any of the other boards but it still on-topic.
Forum rules
This General Discussion board is meant for topics that are still relevant to Pale Moon, web browsers, browser tech, UXP applications, and related, but don't have a more fitting board available.

Please stick to the relevance of this forum here, which focuses on everything around the Pale Moon project and its user community. "Random" subjects don't belong here, and should be posted in the Off-Topic board.
User avatar
UCyborg
Lunatic
Lunatic
Posts: 293
Joined: 2019-01-10, 09:37
Location: Slovenia

Triggering dialog for adding a bookmark from the web page

Unread post by UCyborg » 2024-10-23, 13:37

Found something interesting in Pale Moon. If you put a link like this to a page:

Code: Select all

<a href="https://mywebsite.com/" rel="sidebar" title="A title">Add to bookmarks</a>
And click it, it opens dialog for adding https://mywebsite.com/ to bookmarks with the bookmark name set the same as title attribute. Judging by the code I found (can't link to it, part of app at work), old browsers had ways to trigger adding bookmarks from web page or even JavaScript. The important part here is rel="sidebar". This behavior is triggered only by plain left click.

It seems these things were browser specific. I wonder if this feature can be properly detected on Mozilla-based browser. Looks like checking for existence of window.sidebar in JavaScript doesn't guarantee the feature is supported and in this case the link will act as plain link to the web page.

There's nothing interesting in window.sidebar in Pale Moon, looks the same as window.external. Maybe the only realistic way these days is using something like navigator.userAgent.includes('Goanna') for UXP browsers. Maybe there's another reason user agent sniffing was (is still?) popular?

User avatar
moonbat
Knows the dark side
Knows the dark side
Posts: 5445
Joined: 2015-12-09, 15:45
Contact:

Re: Triggering dialog for adding a bookmark from the web page

Unread post by moonbat » 2024-10-23, 15:05

You can do this in Borealis, as it's the browser component of the Mozilla Suite. It even exposes navigator.sidebar in the DOM. My TextFX extension (link in sig) had to do some Borealis specific code to make it work there.
"One hosts to look them up, one DNS to find them and in the darkness BIND them."

Image
KDE Neon on a Slimbook Excalibur (Ryzen 7 8845HS, 64 GB RAM)
AutoPageColor|PermissionsPlus|PMPlayer|Pure URL|RecordRewind|TextFX

User avatar
UCyborg
Lunatic
Lunatic
Posts: 293
Joined: 2019-01-10, 09:37
Location: Slovenia

Re: Triggering dialog for adding a bookmark from the web page

Unread post by UCyborg » 2024-10-23, 16:27

What's left in Pale Moon looks like a relic to me, window.sidebar seems to be about actual sidebar where you can add a tab, but there's no sidebar in Pale Moon, at least I don't find it in menus. Judging from http://www.javascripter.net/faq/bookmarkaddfavorite.htm, calling window.sidebar.addPanel() opened the dialog for adding bookmark and adding to the sidebar was optional in Firefox.

SeaMonkey still has the sidebar, but adding a code like above in HTML and clicking the link just follows the link as usual, but calling window.sidebar.addPanel() opens a prompt for adding to sidebar alone, no possibility to add to bookmarks.

Where do I find this Borealis Navigator? I only found roytam1's version, is there another?

Can't say I can find anything related to bookmarks in your extension. :?

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 36976
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: Triggering dialog for adding a bookmark from the web page

Unread post by Moonchild » 2024-10-23, 19:21

UCyborg wrote:
2024-10-23, 16:27
but there's no sidebar in Pale Moon, at least I don't find it in menus
You should look closely.
Or press either Ctrl+B (bookmarks) or Ctrl+H (History)
"The world will not be destroyed by those who do evil, but by those who watch them without doing anything." - Albert Einstein
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

User avatar
UCyborg
Lunatic
Lunatic
Posts: 293
Joined: 2019-01-10, 09:37
Location: Slovenia

Re: Triggering dialog for adding a bookmark from the web page

Unread post by UCyborg » 2024-10-24, 09:57

Sorry, I meant SeaMonkey style sidebar. Or whatever old Firefox versions had, the ones that still had window.sidebar.addPanel(). Judging from SeaMonkey, it just let you load the actual web page on sidebar's tab.

Sometimes I open bookmarks sidebar in Pale Moon by accident with keyboard shortcut, otherwise, I just forgot a form of it exists and I was probably too tired when looking. But I just wanted to know if there's a way to detect from JavaScript (from the plain web page, not extension) if browser will treat <a> tag specially if its attribute rel is set to sidebar.

User avatar
UCyborg
Lunatic
Lunatic
Posts: 293
Joined: 2019-01-10, 09:37
Location: Slovenia

Re: Triggering dialog for adding a bookmark from the web page

Unread post by UCyborg » 2025-01-22, 10:30

This dialog opens in Pale Moon when clicking that kind of link:

Code: Select all

<a rel="sidebar" href="https://forum.palemoon.org/" title="Test">Add to bookmarks</a>
Image

But the checkbox doesn't have any meaning. Or am I missing something? Dialog just normally stores the bookmark in selected folder.

In SeaMonkey, that kind of link behaves as normal link on the page, though you can call window.sidebar.addPanel, that opens this question:

Image

Confirming it lands it like this in the sidebar.

Image

It seems they were experimenting sidebars / bookmarks, but didn't really know what should it look like in finished state, at least I see two browsers with different "sidebar" features.

User avatar
FranklinDM
Add-ons Team
Add-ons Team
Posts: 608
Joined: 2017-01-14, 02:40
Location: Philippines
Contact:

Re: Triggering dialog for adding a bookmark from the web page

Unread post by FranklinDM » 2025-01-22, 15:37

UCyborg wrote:
2025-01-22, 10:30
But the checkbox doesn't have any meaning. Or am I missing something? Dialog just normally stores the bookmark in selected folder.
It does. If you click the resulting bookmark with that option checked, the browser opens it in a web sidebar panel. TGS further expands that panel by adding in a more or less full "browser" UI.
Attachments
Screenshot_2025-01-22_23-38-20.png

User avatar
UCyborg
Lunatic
Lunatic
Posts: 293
Joined: 2019-01-10, 09:37
Location: Slovenia

Re: Triggering dialog for adding a bookmark from the web page

Unread post by UCyborg » 2025-01-22, 20:32

Thanks, didn't actually click the added bookmark, I was oblivious that this was an option associated with each bookmark. I haven't actually used them in many years.

Post Reply