Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

209
Views
Cómo conectar background.js con content.js para ejecutar la acción en content.js después de presionar el botón

Tengo un problema al conectar content.js a background.js, de modo que después de presionar el "interruptor" se activa la acción con background.js en content.js. No sé si debería usar popup.js además y cómo usarlo. Quiero habilitar y deshabilitar el tema usando "cambiar". Estoy tratando de hacer esto unos días.

Mi manifiesto.json:

 { "manifest_version": 3, "name": "moonext", "description": "Change UserAgent, Language, Background", "version": "1.0", "permissions": ["storage", "declarativeContent", "activeTab", "scripting"], "action":{ "default_popup": "Popup.html", "default_title": "moonext" }, "icons": { "16": "/images/moon.png", "48": "/images/moontwo.png" }, "content_scripts": [ { "matches": ["https://synergia.librus.pl/*"], "js": ["content.js"], "css": ["main.css"], "run_at": "document_end" } ], "background":{ "service_worker": "background.js" }}

Mi contenido.js:

 console.log("content.js is working"); var style = document.createElement('style'); style.innerHTML = ` // my styles `; document.head.appendChild(style);

Mi Popup.html (código cortado):

 <script src="popup.js" type="text/javascript"></script> </head> <body> <div> <h1>MOONEXT</h1> <table> <tr> <td> <p>Switch</p> </td> <td> <label class="switch"> <input type="checkbox" id="switch1"> <span class="slider round"> </span> </label> </td> </tr> </table> </div> </div> </body>

Mi fondo.js:

 console.log("background.js is working");
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!