chrome.tabs.executeScript + activeTab -> MV3 transition?

683 views
Skip to first unread message

Jói Sigurdsson

unread,
May 4, 2022, 5:44:09 PM5/4/22
to Chromium Extensions
Hi folks,

I'm working on porting our MV2 extension to MV3.

Our MV2 extension has the "activeTab" permission, and uses chrome.tabs.executeScript to inject a file (packaged as a static part of the extension) into browser tabs that the user has interacted with (via our browser action button). This all works great.

MV3 has removed chrome.tabs.executeScript and instead wants us to use chrome.scripting.executeScript, which requires a new permission, "scripting".

Two questions, if anybody knows the answer:

a) Will chrome.scripting play nice with "activeTab" permission and allow us to inject into tabs the user has interacted with? We don't want to have any host permissions, we only want to base injection on tabs the user has chosen.

b) If we add "scripting" to our "permissions" key in manifest.json at the same moment that we update to MV3, given that we previously had the capability to do scripting via chrome.tabs.executeScript, will Chrome decide we "added a permission" or will it allow the update without user action?

My concern is that at least in the past, adding a permission would cause extensions to get disabled for all users, without any special prompt about allowing them again, so likely we'd lose all installs, get a flood of support requests, and need to help tens of thousands of users to reinstall or re-enable the extension.

The alternative would be to add this as an "optional_permission" and prompt the user to allow it, but this is a sub-optimal user experience and strictly worse than how the extension exists today.

Thanks for any feedback you might have!

Best regards,
Jói


Simeon Vincent

unread,
May 4, 2022, 9:21:34 PM5/4/22
to Jói Sigurdsson, Chromium Extensions
a) Will chrome.scripting play nice with "activeTab" permission and allow us to inject into tabs the user has interacted with? We don't want to have any host permissions, we only want to base injection on tabs the user has chosen.

Yes, chrome.scripting plays nice with activeTab. 


b) If we add "scripting" to our "permissions" key in manifest.json at the same moment that we update to MV3, given that we previously had the capability to do scripting via chrome.tabs.executeScript, will Chrome decide we "added a permission" or will it allow the update without user action?

The "scripting" permission does not present a warning to the end user, so adding it to your extension will not trigger a permission prompt.


Simeon - @dotproto
Chrome Extensions DevRel


--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/688cbe21-8dd6-4beb-9e20-7486c6e3c460n%40chromium.org.

Jói Sigurdsson

unread,
May 5, 2022, 4:13:37 AM5/5/22
to Chromium Extensions, Simeon Vincent, Chromium Extensions, Jói Sigurdsson
Thank you Simeon for the authoritative answers. I'm very relieved on both counts!

Best regards,
Jói

styleb...@gmail.com

unread,
Jul 21, 2022, 3:37:32 PM7/21/22
to Chromium Extensions, j...@crankwheel.com, Simeon Vincent, Chromium Extensions
Hey Jói !

I have faced exactly the same issues and exactly the same questions 🤓
How smooth was your migration to v3?
Did adding 'scripting' permission cause extension 'disabling'? 

- Sergey
четвер, 5 травня 2022 р. о 11:13:37 UTC+3 j...@crankwheel.com пише:

Jói Sigurdsson

unread,
Jul 22, 2022, 12:40:24 PM7/22/22
to Chromium Extensions, styleb...@gmail.com, Jói Sigurdsson, Simeon Vincent, Chromium Extensions
Hi Sergey,

The migration to MV3 wasn't too difficult but required some restructuring of our extension, as our background page previously was making use of things like window.screen and more.

We have only launched the MV3 version as a beta, since there are still serious stability concerns with MV3 (worse than the Chrome bug some of our users are facing with MV2) so we are waiting to launch.

You can see the before and after source code by unpacking the different versions, it's not obfuscated at all:

Cheers,
Jói

Jói Sigurdsson

unread,
Jul 22, 2022, 12:41:37 PM7/22/22
to Chromium Extensions, Jói Sigurdsson, styleb...@gmail.com, Simeon Vincent, Chromium Extensions
I forgot to answer your question:

> Did adding 'scripting' permission cause extension 'disabling'? 

No, it did not, we tested by upgrading our staging extension to the MV3 code with 'scripting' permission and did not get a prompt when the update happened. We also tested that we were able to roll the staging extension from MV3 back to MV2 (this is something Simeon had mentioned was allowed for extensions that were originally MV2).

Cheers,
Jói

Se rg

unread,
Jul 23, 2022, 8:49:53 AM7/23/22
to Jói Sigurdsson, Chromium Extensions, Simeon Vincent
Hi Jói,

Thanks for answering the questions and sharing the details!

best regards,
- Sergey

пт, 22 лип. 2022 р. о 19:41 Jói Sigurdsson <j...@crankwheel.com> пише:
Reply all
Reply to author
Forward
0 new messages