New blog: Extension actions in Manifest V3

1,305 views
Skip to first unread message

Simeon Vincent

unread,
Jun 23, 2021, 10:00:02 PM6/23/21
to Chromium Extensions
Hey extension devs,

Earlier today I published a new post on Extension actions in Manifest V3. Similar to the last post on chrome.scripting, this takes a look at some of the motivations and changes Manifest V3 introduces in one part of the extension API.

As a reminder, we have an RSS feed for extensions blog posts on the developer.chrome.com and I'm aiming to keep the What's New page populated with changes across Chrome, CWS, policy, and documentation. 

Happy coding!

Simeon - @dotproto
Chrome Extensions DevRel

ka...@couponfollow.com

unread,
Jul 5, 2021, 6:14:56 AM7/5/21
to Chromium Extensions, Simeon Vincent
Hey @Simeon!

I wonder, what does the snippet in this section https://developer.chrome.com/blog/mv3-actions/#manifest-v3-changes do exactly? I mean this part "chrome.declarativeContent.onPageChanged.addRules" adding a rule that should "show an action".

I tried that with MV3 extension and to be honest, I can't figure out (also after reading the documentation), what should be the desired behavior? For example, I have a popup specified in the "action" property of my manifest:

"action": {
   "default_icon": {
   "16": "icons/icon16.png",
   "48": "icons/icon48.png"
},
   "default_title": "a title",
   "default_popup": "popup.html"
},

And in bg.js:

chrome.runtime.onInstalled.addListener(() => {
  chrome.declarativeContent.onPageChanged.removeRules(undefined, () => {
    chrome.declarativeContent.onPageChanged.addRules([
     {
     conditions: [
       new chrome.declarativeContent.PageStateMatcher({
         pageUrl: { urlContains: 'example' },
       }),
     ],
     actions: [new chrome.declarativeContent.ShowAction()],
     },
   ]);
 });
});

And it does nothing. It doesn't show the popup (I sort of expected that) but it doesn't do anything to the icon as well... I'd expect at least "pinning" the icon when it's unpinned for a brief moment, but it doesn't happen.

Best!

Simeon Vincent

unread,
Jul 8, 2021, 2:53:52 AM7/8/21
to Chromium Extensions, ka...@couponfollow.com, Simeon Vincent
In short, that snippet is supposed to make an Action behave like a Page Action. It's supposed to conditionally enable the action when the user visits example.com, but in retrospect there's a bug with that code — it never disables the action. This means that it's trying to enable an already enabled button, so nothing happens. This is easy enough to do; you just need to call chrome.action.disable() in the onInstalled callback.

You can find a more detailed walkthrough (+ the line I missed in the blog post) over on the Action API reference page

Simeon - @dotproto
Chrome Extensions DevRel

Message has been deleted

Paul Buzbee

unread,
Jul 27, 2021, 3:12:40 PM7/27/21
to Chromium Extensions, vladimira...@gmail.com, Simeon Vincent, ka...@couponfollow.com
I'm not able to make the code snippet work either, even when adding the correction. My action is always enabled in the top bar (except on chrome:// pages), even when writing pageUrl or CSS rules to restrict it.

In fact, my extension is still always enabled even when I reduce background.js to just this:

chrome.runtime.onInstalled.addListener(() => {
  chrome.action.disable();
});

On Saturday, July 17, 2021 at 1:01:51 PM UTC-7 vladimira...@gmail.com wrote:
Владимир Архипов
22:54 (5 минут назад) 
– Chromium Extensions, Simeon Vincent, Jackie Han, Chromium Extensions

как у вас дела ? мне нужна помощь я не могу перевести деньги из портфолио www.coingesko.com ,чтобы заплатить разработчикам или оплатить свои расходы ,дело срочное там большая сумма если согласитесь я заплачу после работы    how are you? I need help I can't transfer money from my portfolio www.coingesko.com to pay the developers or pay their expenses, it's urgent there is a large amount if you agree, I will pay after work, I will give the login and password to someone who can help
среда, 14 апреля 2021 г. в 12:05:27 UTC+3, Simeon Vincent:
Ответить всем
Написать сообщение автору
Переслать


четверг, 8 июля 2021 г. в 09:53:52 UTC+3, Simeon Vincent:
Reply all
Reply to author
Forward
0 new messages