Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

1.3K
Visualizações
Chrome manifest v3: runtime.lastError specify 'func' and 'files'?

I'm searching for a solution everywhere and I can't find nothing about this error. I'm trying to "update" a Chrome extension to manifest v3 and I get this error:

Unchecked runtime.lastError: Exactly one of 'func' and 'files' must be specified

Does somebody have an idea on what can I do to solve this? Here is my manifest.json:

{
    "manifest_version": 3,
    "name": "Extension_Name",
    "description": "Extension_Desc",
    "version": "5.0",
    "icons": {
        "16": "/images/image16.png",
        "48": "/images/image48.png",
        "128": "/images/image128.png"
    },
    "action": {
        "default_popup": "popup.html"
    },
    "permissions": [
        "storage",
        "activeTab",
        "scripting",
        "tabs"
    ],
    "host_permissions": [
        "https://example.com/*"
    ]
}

And here is my popup.html, that is referenced in the error (but without a specific line, only popup.html:0):

<!DOCTYPE html>
<html lang="en">
<head>
    <link rel="stylesheet" href="popup.css">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://example.com">
    <title>Extension Test</title>
</head>
<body>
    <h2>Ghost</h2>
    <form name ="form" id="login_form" action="#">
        <input type="text" id="mdp" placeholder="Password"/>
        <input type ="button" name="submit" value="Login" id="login"/>
    </form>
    
    <button id="logout">Logout</button>
    <script src="popup.js"></script>
</body>
</html>

I know that unsafe-eval is not supported in manifest v3, but I will deal with this error later. If I delete unsafe-eval, the other error remains, so the two are not linked. Thank you in advance!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Finally, the error is solved by adding "files" in the executeScript() function. Before I had:

chrome.scripting.executeScript(
                {
                    target: {tabId: tab.id},
                    function: functionToExecute()
                })

The solution found is:

chrome.scripting.executeScript(
                {
                    target: {tabId: tab.id},
                    files: ['popup.js'],
                    function: functionToExecute()
                })

Thanks again for the help!

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda