Add a counter to a toolbar button, like nMatrix?

Talk about code development, features, specific bugs, enhancements, patches, and similar things.
Forum rules
Please keep everything here strictly on-topic.
This board is meant for Pale Moon source code development related subjects only like code snippets, patches, specific bugs, git, the repositories, etc.

This is not for tech support! Please do not post tech support questions in the "Development" board!
Please make sure not to use this board for support questions. Please post issues with specific websites, extensions, etc. in the relevant boards for those topics.

Please keep things on-topic as this forum will be used for reference for Pale Moon development. Expect topics that aren't relevant as such to be moved or deleted.
User avatar
moonbat
Knows the dark side
Knows the dark side
Posts: 4942
Joined: 2015-12-09, 15:45
Contact:

Add a counter to a toolbar button, like nMatrix?

Unread post by moonbat » 2020-04-19, 09:30

I'm revamping Pure URL, converting it from Jetpack to a regular overlay extension, and trying to add a few visual improvements (helps me learn more about extension development as well). Currently it has a toolbar button that launches an options dialog (with an easier to use list of garbage fields to add/remove).How do I display a mini counter on top of the toolbar icon for links processed, similar to nMatrix or uBlock Origin?
"One hosts to look them up, one DNS to find them and in the darkness BIND them."

Image
Linux Mint 21 Xfce x64 on HP i5-5200 laptop, 12 GB RAM.
AutoPageColor|PermissionsPlus|PMPlayer|Pure URL|RecordRewind|TextFX

vannilla
Moon Magic practitioner
Moon Magic practitioner
Posts: 2183
Joined: 2018-05-05, 13:29

Re: Add a counter to a toolbar button, like nMatrix?

Unread post by vannilla » 2020-04-19, 10:27

It's probably a good starting point to read the source code of the extensions you listed.

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

Re: Add a counter to a toolbar button, like nMatrix?

Unread post by moonbat » 2020-04-19, 10:36

Does it make a difference if they're addon/jetpack vs the regular overlay extension I'm working on?
"One hosts to look them up, one DNS to find them and in the darkness BIND them."

Image
Linux Mint 21 Xfce x64 on HP i5-5200 laptop, 12 GB RAM.
AutoPageColor|PermissionsPlus|PMPlayer|Pure URL|RecordRewind|TextFX

vannilla
Moon Magic practitioner
Moon Magic practitioner
Posts: 2183
Joined: 2018-05-05, 13:29

Re: Add a counter to a toolbar button, like nMatrix?

Unread post by vannilla » 2020-04-19, 13:57

moonbat wrote:
2020-04-19, 10:36
Does it make a difference if they're addon/jetpack vs the regular overlay extension I'm working on?
I don't think so, no.
Just make sure you call the code only if the toolbar button is actually on a toolbar.

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

Re: Add a counter to a toolbar button, like nMatrix?

Unread post by moonbat » 2020-04-19, 14:10

Can't make head or tail of the code in uBO - there is no XUL to define the toolbar icon since it is a bootstrap/jetpack extension. I searched the code for words like 'icon' but no luck, it is almost entirely only related with processing pages (as expected).
"One hosts to look them up, one DNS to find them and in the darkness BIND them."

Image
Linux Mint 21 Xfce x64 on HP i5-5200 laptop, 12 GB RAM.
AutoPageColor|PermissionsPlus|PMPlayer|Pure URL|RecordRewind|TextFX

User avatar
adesh
Board Warrior
Board Warrior
Posts: 1277
Joined: 2017-06-06, 07:38

Re: Add a counter to a toolbar button, like nMatrix?

Unread post by adesh » 2020-04-19, 14:23

Look for "badge" in uMatrix codebase.

https://github.com/gorhill/uMatrix/comm ... e64a921f6e

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

Re: Add a counter to a toolbar button, like nMatrix?

Unread post by moonbat » 2020-04-19, 14:44

Interesting, he's using CSS to superimpose a badge. Good point to start looking, thanks :thumbup:
"One hosts to look them up, one DNS to find them and in the darkness BIND them."

Image
Linux Mint 21 Xfce x64 on HP i5-5200 laptop, 12 GB RAM.
AutoPageColor|PermissionsPlus|PMPlayer|Pure URL|RecordRewind|TextFX

Locked