MozillaZine

[Ext] PrefBar - The all in one button container

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

Post Posted May 26th, 2017, 12:12 pm

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.

dickvl

User avatar
 
Posts: 52057
Joined: July 18th, 2005, 3:25 am

Post Posted May 26th, 2017, 5:00 pm

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: 59
Joined: July 2nd, 2013, 4:29 am

Post Posted May 27th, 2017, 1:07 am

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.

dickvl

User avatar
 
Posts: 52057
Joined: July 18th, 2005, 3:25 am

Post Posted May 27th, 2017, 11:58 am

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: 59
Joined: July 2nd, 2013, 4:29 am

Post Posted May 28th, 2017, 2:12 am

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: 9
Joined: May 25th, 2017, 3:07 pm

Post Posted May 28th, 2017, 5:58 am

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: 2261
Joined: February 3rd, 2009, 6:29 pm

Post Posted May 29th, 2017, 8:34 am

@roninx

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

viewtopic.php?p=14749887#p14749887

Crossposting
faq.php?mode=rules#f4r0

roninx
 
Posts: 9
Joined: May 25th, 2017, 3:07 pm

Post Posted May 29th, 2017, 10:06 am

Sorry, but his suggestion did not work.

M-Reimer
 
Posts: 59
Joined: July 2nd, 2013, 4:29 am

Post Posted May 29th, 2017, 11:31 pm

PrefBar can only handle one level of submenus.
And no, this won't change as PrefBar will be discontinued anyway.

Elhem Enohpi
 
Posts: 8
Joined: March 19th, 2016, 8:49 am

Post Posted June 23rd, 2017, 10:36 am

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...

Return to Extension/Theme Releases


Who is online

Users browsing this forum: No registered users and 3 guests