Solved: Cannot read property 'executeScript' of undefined
So you are trying to use the new chrome.scripting.executeScript API, but chrome.scripting is undefined. It is undefined due to the new more granular permissions system in Chrome extension manifest v3 version. You are missing a permission.
Chrome manifest v3 migration guide adds to the confusion by showing an example of executeScript call without mentioning that a new permission needs to be declared.
In order to execute content scripts you now need to declare or optionally request “scripting” permission. On it’s own the permissions is not very useful, so you will most likely pair it with host permissions or activeTab permission. Quick fix Add “scripting” to permissions. Or alternatively in “optional_permissions”, but then you need to prompt the user to grant this permissions before calling chrome.scripting API.
"permissions": [ "activeTab", "scripting" ]