[Ext] PrefBar - The all in one button container

Announce and Discuss the Latest Theme and Extension Releases.
Post Reply
M-Reimer
Posts: 76
Joined: July 2nd, 2013, 4:29 am

Re: [Ext] PrefBar - The all in one button container

Post by M-Reimer »

dickvl wrote:I notice that the colors extension uses basic colors like text color:black the background-color:white and link color blue.

Would it be possible to make it possible to customize the colors as there are a lot of people that have a problem with such a high contrast and would prefer less contrast like color:#444 and background-color:#eee ?
Yes, this would be possible, but this would make the Addon code much more complicated as for real "free choice", we would need dynamic CSS generation.
If there are more people who need this, I may consider this change, but I would prefer to keep the addon as simple as possible.
So far the CSS is very basic. I still have to add some more default colors like "link visited".

I also don't like that I have to add the context menu entry to the page context menu, but https://bugzilla.mozilla.org/show_bug.cgi?id=1215376 makes it impossible to add this entry to the tab context menu. Maybe I'll move the entry as soon as this bug is fixed.
Will it be possible to port DocShell type framescript buttons to a WebExtension like allowJavascript and allowImages and allowMedia?
https://developer.mozilla.org/Mozilla/T ... sIDocShell
"Domain specific handling" is already possible for images and media. Javascript may follow in future. "Per tab", so far, is not possible. It may be requested to be added, but only if there is a good reason for this. And at least I don't know a good reason why I would need a tab which is not allowed to run Javascript. I also never used the buttons in PrefBar.
I have a lot of PrefBar buttons to invoke JavaScript bookmarklets via a keyboard shortcut.(PlacesUtils.keywords.fetch(keyword)), but such action won't be possible anymore I assume
Shortcuts are still possible. In fact it even is possible for the user to change them, if the addon developer exposes this setting to his settings page. But there is only one shortcut per Addon. Again, the idea is to have small Addons doing one task. So if you have three or more "bookmarklets", each one could be an Addon. It's actually pretty easy to convert a bookmarklet into an Addon. Would also make it much easier to edit the code which has to be in one line in bookmarklets.
as well as buttons that run privileged code like the Scratchpad in Browser mode allows.
Exactly. This doesn't work. If there is a good reason for this, API features can be requested to Mozilla.
Is it possible to come up with a WebExtension to have a Tab List of all open tabs and windows?
Yes, this is possible. All the API, needed for this, is already available.
User avatar
dickvl
Posts: 54145
Joined: July 18th, 2005, 3:25 am

Re: [Ext] PrefBar - The all in one button container

Post by dickvl »

Thanks Manuel.

If I would place the JavaScript bookmarklet code in the extension wouldn't I have to modify the extension and sign it with every change or can this data be read from an external file?

I'm using for instance a bookmarklet to quickly enter text in a forum reply by using a key sequence that consists of a few letters (e.g. fx = Firefox) using T=document.activeElement;if(/textarea|input/i.test(T.nodeName)){...} to do the actual insert/replace.
I regularly make changes to the code of these bookmarklets, so having this as a bookmark is the easiest way to maintain these bookmarklets (they are all saved in a bookmark backup, so I have them in one place).

I haven't read up that much about what WebExtensions permissions there are and how to use them.
I know that you can use about:debugging to load an extension temporarily for testing.
M-Reimer
Posts: 76
Joined: July 2nd, 2013, 4:29 am

Re: [Ext] PrefBar - The all in one button container

Post by M-Reimer »

I don't know if you can read an external file, but if Mozilla did their homework, you probably can't escape the sandboxed environment.

What I've seen several times is, that someone injects javascript files hosted on some webserver. This is pretty common for "fast changing" stuff like addons which modifiy some website. If the targeted website changes, the developer wants to ship the required changes as fast as possible. In this case he just updates his .js file on his webserver. No new review needed.

But in your case, I think you have to look at the problem from a different angle.

If I understand you correctly, then what you have/want is some addon which replaces abbreviations in text input fields.

So your code, which does this, is somewhat static. If there are bugs, you want to fix them and get your fix reviewed by Mozilla again.

The variable part in this case are the abbreviations and the replacements.

So just create a settings page. Easiest way would be a multiline text box. One line per entry starting with the abbreviation and a space character and ending with the replacement.
Also add a text box for setting the shortcut to your settings page. I think every addon with keyboard shortcuts should add this as there is no global "shortcut reservation table" and so at some point we will get conflicts.

With the new Webextensions API it is really easy to make use of Firefox Sync. This would not only back up your data but also keep different PC's in sync.
User avatar
dickvl
Posts: 54145
Joined: July 18th, 2005, 3:25 am

Re: [Ext] PrefBar - The all in one button container

Post by dickvl »

What I'm talking about is not just a few lines of text, but it can contain references to other items and a single bookmarklet can contain almost 100 KB (I just checked the largest and decompressed all 1375 entries).
Having that many data in an extension or in a PrefBar button wouldn't be a good idea and that is why I use places.sqlite to store this data and use keyword bookmarklets.
I can of course click a toolbar on the Bookmarks Toolbar, but using the keyboard is much easier.
A short example of a text definition:

Code: Select all

T=['a:about','ac:#a#:config','acb:[b]#ac#[/b]','acbo:You can open the #acp# via the location bar.\n','acp:#acb# page','bmk:bookmarklet','sf:Safe Mode'];
M-Reimer
Posts: 76
Joined: July 2nd, 2013, 4:29 am

Re: [Ext] PrefBar - The all in one button container

Post by M-Reimer »

dickvl wrote:What I'm talking about is not just a few lines of text, but it can contain references to other items and a single bookmarklet can contain almost 100 KB (I just checked the largest and decompressed all 1375 entries).
Having that many data in an extension or in a PrefBar button wouldn't be a good idea and that is why I use places.sqlite to store this data and use keyword bookmarklets.
The webextension storage API is meant to be used for such stuff and if this doesn't work, Mozilla has to fix that. I guess in the end, the storage data will also be placed into some sqlite database, but this doesn't matter.
I can of course click a toolbar on the Bookmarks Toolbar, but using the keyboard is much easier.
A short example of a text definition:

Code: Select all

T=['a:about','ac:#a#:config','acb:[b]#ac#[/b]','acbo:You can open the #acp# via the location bar.\n','acp:#acb# page','bmk:bookmarklet','sf:Safe Mode'];
And in an extension for this task, it could look like this:

Code: Select all

a:about
ac:#a#:config
acb:[b]#ac#[/b]
acbo:You can open the #acp# via the location bar.\n
acp:#acb# page
bmk:bookmarklet
sf:Safe Mode
roninx
Posts: 106
Joined: May 25th, 2017, 3:07 pm

Re: [Ext] PrefBar - The all in one button container

Post by roninx »

I just started using this and like it so far, but I have a question.

Is it possible to have a submenu under a submenu?
morat
Posts: 6404
Joined: February 3rd, 2009, 6:29 pm

Re: [Ext] PrefBar - The all in one button container

Post by morat »

@roninx

Please do not ask the same question in more than one thread.

http://forums.mozillazine.org/viewtopic ... #p14749887

Crossposting
http://forums.mozillazine.org/faq.php?mode=rules#f4r0
roninx
Posts: 106
Joined: May 25th, 2017, 3:07 pm

Re: [Ext] PrefBar - The all in one button container

Post by roninx »

Sorry, but his suggestion did not work.
M-Reimer
Posts: 76
Joined: July 2nd, 2013, 4:29 am

Re: [Ext] PrefBar - The all in one button container

Post by M-Reimer »

PrefBar can only handle one level of submenus.
And no, this won't change as PrefBar will be discontinued anyway.
Elhem Enohpi
Posts: 49
Joined: March 19th, 2016, 8:49 am

Re: [Ext] PrefBar - The all in one button container

Post by Elhem Enohpi »

Hi,

I'm trying to make a button to kill the timers on a web page, for example to stop an annoying slideshow animation and so on. The code should be like this:

Code: Select all

killTimers() {
	var c, tID, iID;
	tID = setTimeout(function(){}, 0);
	for (c=1; c<1000 && c<=tID; ++c) clearTimeout(tID - c);
	iID = setInterval(function(){},1000);
	for (c=0; c<1000 && c<=iID; ++c) clearInterval(iID - c);
}
It works as a bookmarklet, but I'd like to make a Prefbar button from it. Is that possible?

I made a button like this, but it doesn't work:

Code: Select all

{
  "prefbar:info": {
    "formatversion": 3
  },
  "prefbar:menu:enabled": {
    "items": [
      "prefbar:button:killtimers"
    ]
  },
  "prefbar:button:killtimers": {
    "type": "button",
    "label": "Kill Timers",
    "onclick": "CallFrameScript()",
    "framescript": "var c, tID, iID;\ntID = setTimeout(function(){}, 0);\nfor (c=1; c<1000 && c<=tID; ++c) clearTimeout(tID - c);\niID = setInterval(function(){},1000);\nfor (c=0; c<1000 && c<=iID; ++c) clearInterval(iID - c);"
  }
}
I'm using Firefox 54 with multiprocess on.
Thanks for any advice...
M-Reimer
Posts: 76
Joined: July 2nd, 2013, 4:29 am

Re: [Ext] PrefBar - The all in one button container

Post by M-Reimer »

I've tried to make this clear several times, but again: PrefBar will not survive Firefox 57 so whatever you plan to do should be done in a different, more future proof, way. I, myself, am on my way to porting all important PrefBar features into dedicated Addons:
http://prefbar.tuxfamily.org/migration.html
I have another one ready to be uploaded this weekend.

Is there any reason why you don't want to keep this as a bookmarklet?
Elhem Enohpi
Posts: 49
Joined: March 19th, 2016, 8:49 am

Re: [Ext] PrefBar - The all in one button container

Post by Elhem Enohpi »

Hi Manuel, thanks for your reply. I'm not planning to update to Firefox 57. There are too many addons that are indispensable to me (most importantly Tree Style Tab and Session Manager, but also many others including PrefBar) which will not be supported. I think I can stick with 56 or 52 ESR for another two years or so. For that time, PrefBar is still useful for me. After that, who knows..??

I just wanted to know if it's possible to change a bookmarklet into a PrefBar button. I couldn't make it work, and I couldn't find a good example. Is it easy?

The reason I want to, is just to have them all together. So if I want to turn off Javascript or change an about:config preference, or I want to disable Javascript timers or CSS animations, I go to the same place. I don't want to have to remember for which adjustments I need to go to the bookmarks menu, and for which I need to go to the PrefBar button. I think the bookmarks menu should be for websites I visit, not for utilities. Also I don't use a bookmarks toolbar or the PrefBar toolbar, in order to reduce clutter - I don't like to have a lot of buttons on the screen.

It's a shame that Mozilla can't support PrefBar anymore. What I really like about PrefBar is that it's a system where I can write many very simple little scripts in an easy way. I'm not a "pro" web developer, I'm not so good at Javascript programming, mostly I just find some examples and try to modify them a little. I can play around with it easily and experiment. I also use Greasemonkey a little, but I don't know how to run the scripts from buttons, if it's even possible. And I use Keyconfig. But I don't think I will learn how to write my own web extensions, design icons, and get them approved by Mozilla and so on. I don't have that much time. Anyway I don't want a separate toolbar button and icon for every little bit of script I might want to run. I like having the one button with the dropdown text menu. It's great that you're porting the important parts of PrefBar to new individual addons, for Firefox 57. But for me, the original PrefBar is better. Thanks for making it!
User avatar
notonymous
Posts: 157
Joined: November 6th, 2002, 6:57 pm
Location: Beyond the fringe

Re: [Ext] PrefBar - The all in one button container

Post by notonymous »

M-Reimer wrote:I, myself, am on my way to porting all important PrefBar features into dedicated Addons:
http://prefbar.tuxfamily.org/migration.html
Hello Manuel -
Would you be able to add the following two Prebar buttons to your to-do list for conversion:

Proxy Serverlist
Cookie Behavior Menulist

Without them, quick migration between different environments is a pain.

Thanks ...
M-Reimer
Posts: 76
Joined: July 2nd, 2013, 4:29 am

Re: [Ext] PrefBar - The all in one button container

Post by M-Reimer »

Elhem Enohpi wrote: I just wanted to know if it's possible to change a bookmarklet into a PrefBar button. I couldn't make it work, and I couldn't find a good example. Is it easy?
It is possible but not easy. As you are fiddling with page internal javascript objects this is not possible directly for security reasons. So we would end up with injecting a <script> tag containing your code. As it has no future, I'd say that it isn't worth to waste time on this.

The easiest way would be if you just place your unchanged bookmarklet as "Link" to PrefBar.

It would also work to port this bookmarklet into an WebExtension, but as this doesn't seem to be what you want, I won't waste time on this.
I don't like to have a lot of buttons on the screen.
That's why most of my new addons also create context menu entries at the appropriate positions. If you need the feature, provided by the addon, regularly, you may use the button for fast access. Just remove the button and use the context menu otherwise.
It's a shame that Mozilla can't support PrefBar anymore.
Even if they did, I wouldn't want to keep maintaining it. In fact I can't even guarantee that every feature still works as I don't use every feature and so I don't test them with every new Firefox release.
It is far better to have each feature in its own addon. Much easier to maintain and way more ways to add useful stuff to each individual feature.
M-Reimer
Posts: 76
Joined: July 2nd, 2013, 4:29 am

Re: [Ext] PrefBar - The all in one button container

Post by M-Reimer »

notonymous wrote: Proxy Serverlist
I'm almost 100% sure that there is already some proxy selection list available. I'll have a look at this later. If this in fact is missing, I'll add this one.
Cookie Behavior Menulist
The preference behind this no longer exists for Addons. There is API for managing cookies and to get told when websites set new cookies, but to do something with this, I need to know what exactly you set with "Cookie Behaviour Menulist". Or in other words: For what reason do you use it? I don't use it myself and never used it in the past...
Post Reply