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

218
Views
¿Puede Safari Extension *Shared (App)/Resources/Script.js* comunicarse con background.js?
function show(platform, enabled) { document.body.classList.add(`platform-${platform}`); if (typeof enabled === 'boolean') { document.body.classList.toggle(`state-on`, enabled); document.body.classList.toggle(`state-off`, !enabled); } else { document.body.classList.remove(`state-on`); document.body.classList.remove(`state-off`); } } function openPreferences() { webkit.messageHandlers.controller.postMessage('open-preferences'); } document .querySelector('button.open-preferences') .addEventListener('click', openPreferences); (() => { // alert('hei'); const x = document.getElementById('message'); x.textContent = 'meh'; // This cannot communicate with background.js const h = getMeaning({ hanzi: '好' }); h.then((result) => { let s = result; x.textContent = result; }); })(); async function sendMessageAsync(args) { return new Promise((resolve, reject) => { try { // TODO: Find out why this have an error: Invalid context // eslint-disable-next-line no-undef chrome.runtime.sendMessage(args, (response) => { // eslint-disable-next-line no-undef if (!chrome.runtime.lastError) { resolve(response); } else { // eslint-disable-next-line no-undef reject(chrome.runtime.lastError.message); } }); } catch (err) { reject(err); } }); } const GET_MEANING = 'GET_MEANING'; async function getMeaning({ hanzi }) { return sendMessageAsync({ action: GET_MEANING, data: { hanzi }, }); }

chrome.runtime.sendMessage , pero no funciona

¿Hay alguna otra forma de comunicarse con background.js desde Script.js de la aplicación Safari Extension?

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!