When pasting code here, place triple backticks (```) on the line above and below the code, that will activate code format.
Regarding the issue - sadly, in MV3 in Firefox the host permissions needs to be manually granted by user:
You can use this API to ask user to grant the permissions: