A way to increase the number of items in the history drop-down menu? Topic is solved

Add-ons for Pale Moon and other applications
General discussion, compatibility, contributed extensions, themes, plugins, and more.

Moderators: FranklinDM, Lootyhoof

Enobarbous
Apollo supporter
Apollo supporter
Posts: 42
Joined: 2022-12-06, 17:44

A way to increase the number of items in the history drop-down menu?

Unread post by Enobarbous » 2023-05-17, 11:38

I mean this menu:
1_pm.jpg
The number of items in it is hardcoded in browser.js -

Code: Select all

PlacesMenu.call(this, aPopupShowingEvent, "place:sort=4&maxResults=15");
So far, the only workable option I've found is to modify the browser.js and pack it into a new extension, which looks... impractical for such a small change. Perhaps someone has come across a better solution? Extension or code for custombutton / userchromejs?

P.S. I know about the ability to open history in the sidebar or in a tab. What I'm interested in is the ability to enlarge the drop-down list.
I am sorry for the use of auto-translator to post

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

Re: A way to increase the number of items in the history drop-down menu?

Unread post by Moonchild » 2023-05-17, 11:46

Enobarbous wrote:
2023-05-17, 11:38
So far, the only workable option I've found is to modify the browser.js and pack it into a new extension
... don't do this. Your extension will likely break the browser with every update that involves changes to browser.js.

What you can do, however, is create an extension that replaces only what you want using the browser's interfaces.
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

Enobarbous
Apollo supporter
Apollo supporter
Posts: 42
Joined: 2022-12-06, 17:44

Re: A way to increase the number of items in the history drop-down menu?

Unread post by Enobarbous » 2023-05-17, 11:58

Moonchild wrote:
2023-05-17, 11:46
Enobarbous wrote:
2023-05-17, 11:38
So far, the only workable option I've found is to modify the browser.js and pack it into a new extension
... don't do this. Your extension will likely break the browser with every update that involves changes to browser.js.
This is the reason I decided to ask the question)
What you can do, however, is create an extension that replaces only what you want using the browser's interfaces.
And that's what I tripped over. I tried some ideas, but... In the end, I came to the forum with a question
I am sorry for the use of auto-translator to post

Blacklab
Board Warrior
Board Warrior
Posts: 1080
Joined: 2012-06-08, 12:14

Re: A way to increase the number of items in the history drop-down menu?

Unread post by Blacklab » 2023-05-17, 12:06

You might like to look at using or modifying one of several history menu extensions saved in the Classic Add-ons Archive: https://github.com/JustOff/ca-archive

Blacklab
Board Warrior
Board Warrior
Posts: 1080
Joined: 2012-06-08, 12:14

Re: A way to increase the number of items in the history drop-down menu?

Unread post by Blacklab » 2023-05-17, 14:52

Enobarbous wrote:What I'm interested in is the ability to enlarge the drop-down list.
Or.... if all you want is a 'one click' extended history drop-down menu... why not create a Bookmarklet?

Not sure if you've considered or tried this... just another way the browser can display the output from querying the 'Places' database as a Smart Bookmarks folder... so no need for extensions or anything very complex at all. :)

If unfamiliar with howto create 'Smart Bookmarks' folders... easiest method probably to modify jscher2000's instructions for creating a 'custom Recently Bookmarked smart folder' here:
Creating a custom Recently Bookmarked smart folder

(From: jscher2000's polite and helpful reply to a lazy OP on Reddit back in 2018: https://reddit.com/r/firefox/comments/7 ... bility_to/)

This is a bit roundabout, but bear with me.

First, select and copy the following places query string:

Code: Select all

place:sort=12&excludeQueries=1&maxResults=50&queryType=1
Open up the Library window (Windows: Ctrl+Shift+b, Mac Command+Shift+b, or "Show All Bookmarks")

In the left column, click Bookmarks Menu

On the right side, right-click a blank area (not on a folder row) and choose New Bookmark (Note: Or you can click the 'Organize' tab at top left... and select 'New Bookmark')

In the Name, type something like Last 50 Bmks and in the Location, paste the query string.

Note about the number of bookmarks: maxResults=50 is what sets the number of results.

Click the Add button. Then drag the new bookmark to the Bookmarks Toolbar in the left column and drop it there. When you expand the bar, you should see that the new bookmark now has the "smart folder" gear icon indicating that it is a query folder. (Note: Browser may need a restart for a new bookmarklet to appear with its Places "smart folder" blue magnifying glass favicon... the "smart folder" gear icon jscher2000 describes applies to current versions of Firefox. :) )

If you actually want it on the menu, now you can move it back.

So there's another tool for your kit if you need it.

If you get curious about what else you can do with place: queries, see https://developer.mozilla.org/docs/Mozi ... query_URIs (Note: Now a dead link... last version via WayBackMachine (WBM) captured in April 2021: https://web.archive.org/web/20210402123 ... query_URIs)
In your case you would take the 'Places' database's 'history drop-down menu' code you found hardcoded in browser.js:

Code: Select all

PlacesMenu.call(this, aPopupShowingEvent, "place:sort=4&maxResults=15");
... and edit for use as your history bookmarklet's URL... adjusting the 'maxResults' number to suit... e.g. '30' results below:

Code: Select all

place:sort=4&maxResults=30
--------------------

FYI - Almost all the old MDN 'Places' database information pages have been kindly archived for Pale Moon users and devs by RealityRipple in his excellent 'Archive of obsolete content' here: https://udn.realityripple.com/docs/Archive

Alternatively, most of these very useful pages have been captured at various dates by WayBackMachine (WBM)... these were the final WBM captures:

MDN 'Places' overview (Oct 2020): https://web.archive.org/web/20201026000 ... ech/Places.

MDN 'Querying Places' (Jun 2021): https://web.archive.org/web/20210622084 ... s/Querying

MDN 'Places query URIs' (Apr 2021): https://web.archive.org/web/20210402123 ... query_URIs

User avatar
Kris_88
Keeps coming back
Keeps coming back
Posts: 932
Joined: 2021-01-26, 11:18

Re: A way to increase the number of items in the history drop-down menu?

Unread post by Kris_88 » 2023-05-17, 17:57

Enobarbous wrote:
2023-05-17, 11:58
I tried some ideas, but... In the end, I came to the forum with a question
This is Java.
You can override some objects...

Code: Select all

 window.oldHistoryMenu = window.HistoryMenu;
 window.HistoryMenu = function (aPopupShowingEvent) {
  this.__proto__.__proto__ = window.PlacesMenu.prototype;
  window.XPCOMUtils.defineLazyServiceGetter(this, "_ss",
                                     "@mozilla.org/browser/sessionstore;1",
                                     "nsISessionStore");
  window.PlacesMenu.call(this, aPopupShowingEvent,
                  "place:sort=4&maxResults=3");
};
window.HistoryMenu.prototype = window.oldHistoryMenu.prototype;

person45
Fanatic
Fanatic
Posts: 104
Joined: 2017-10-20, 07:00

Re: A way to increase the number of items in the history drop-down menu?

Unread post by person45 » 2023-05-17, 18:10

"History Submenus II" add-on works.

User avatar
Kris_88
Keeps coming back
Keeps coming back
Posts: 932
Joined: 2021-01-26, 11:18

Re: A way to increase the number of items in the history drop-down menu?

Unread post by Kris_88 » 2023-05-17, 18:16

Of course, in a good way, the browser should take this line from preferences.
It's bad form to hammer this directly into the code.
"place:sort=4&maxResults=15"

Blacklab
Board Warrior
Board Warrior
Posts: 1080
Joined: 2012-06-08, 12:14

Re: A way to increase the number of items in the history drop-down menu?

Unread post by Blacklab » 2023-05-17, 19:25

Kris_88 wrote:Of course, in a good way, the browser should take this line from preferences.
If one was to ask very, very nicely... always possible Moonchild and Devs might oblige with a lovely hidden pref... :angel: :shh:

Wouldn't be the first time either... Re: adjusting previously 'baked-in' Places database outputs... see forum topic 'Configure Smart Bookmarks Folders (i.e. Recently Bookmarked)': viewtopic.php?f=5&t=23712&p=183490#p183490 :thumbup:

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

Re: A way to increase the number of items in the history drop-down menu?

Unread post by Moonchild » 2023-05-18, 07:46

Issue #1925

Been poking at it for a little, and it's simple to do.
Attachments
Image1.png
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

Enobarbous
Apollo supporter
Apollo supporter
Posts: 42
Joined: 2022-12-06, 17:44

Re: A way to increase the number of items in the history drop-down menu?

Unread post by Enobarbous » 2023-05-18, 08:28

Kris_88 wrote:
2023-05-17, 17:57
Thank you very much.
Now, looking at your solution, and comparing it to my own attempts, I feel I should have thought a little more before asking questions. To override HistoryMenu, but forget to declare HistoryMenu.prototype and be surprised with errors... That was too stupid even for me :)
Moonchild wrote:
2023-05-18, 07:46
Thanks even more. I even somehow forgot that browser developers can be asked for something...
I am sorry for the use of auto-translator to post

User avatar
jobbautista9
Keeps coming back
Keeps coming back
Posts: 780
Joined: 2020-11-03, 06:47
Location: Philippines
Contact:

Re: A way to increase the number of items in the history drop-down menu?

Unread post by jobbautista9 » 2023-05-18, 09:05

Moonchild wrote:
2023-05-18, 07:46
Issue #1925

Been poking at it for a little, and it's simple to do.
Huh, I have been poking at this too, and was actually able to get it working too. It was very similar to yours, with the only difference being that I didn't restrict the amount of results and I didn't process the variable holding the int pref with .toString().trim(). The only reason I didn't PR is because I was figuring out how to make it restartless like History Submenus II did. But if you think it's fine requiring a restart (and it's not really a big deal anyway because one wouldn't change this setting constantly), well I guess that's cool! :thumbup:

By the way, it should be possible to make the history menu unpopulated with links if the pref is set to zero and below; just simply call PlacesMenu.call only if the pref is greater than zero. I will be creating a PR for that. Also I'm not sure if it's better to revert the maxResults variable to the default 15 if the pref exceeds 50. I do agree with limiting the amount of results to prevent a footgun (there's extensions anyway if they REALLY want that :P), but the average user might be expecting to see more results if they are setting the value high, rather than seeing no change at all. So IMO we should just set the variable back to the maximum 50 rather than the default 15.
Image

merry mimas

XUL add-ons developer. You can find a list of add-ons I manage at http://rw.rs/~job/software.html.

Mima avatar by 絵虎. Pixiv post: https://www.pixiv.net/en/artworks/15431817

Image

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

Re: A way to increase the number of items in the history drop-down menu?

Unread post by Moonchild » 2023-05-18, 11:48

jobbautista9 wrote:
2023-05-18, 09:05
one wouldn't change this setting constantly
Indeed it would be set and forget. So a restart is fine.
jobbautista9 wrote:
2023-05-18, 09:05
So IMO we should just set the variable back to the maximum 50 rather than the default 15.
Well my initial check was a catch-all for too low AND too high values.
Negative values and values > 50 should both be an error, IMO. only 0 for "none" makes sense.
I guess I'll just have it print a console error in both cases, and cap too large values, defaulting negatives.
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

Locked