tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

push-sw.js (589B)


      1 async function postAll(data) {
      2  const clients = await self.clients.matchAll({ includeUncontrolled: true });
      3  for (const client of clients) {
      4    client.postMessage(data);
      5  }
      6 }
      7 
      8 function getJSON(data) {
      9  const result = {};
     10  try {
     11    result.value = data.json();
     12    result.ok = true;
     13  } catch (e) {
     14    result.ok = false;
     15  }
     16  return result;
     17 }
     18 
     19 onpush = async ev => {
     20  postAll({
     21    constructor: ev.constructor.name,
     22    data: ev.data && {
     23      text: ev.data.text(),
     24      arrayBuffer: ev.data.arrayBuffer(),
     25      json: getJSON(ev.data),
     26      blob: ev.data.blob(),
     27    },
     28  })
     29 }