onst port document createElement span

From script, 1 Week ago, written in JavaScript, viewed 17 times.
URL https://pb.dynavirt.com/view/f806bb01 Embed
Download Paste or View Raw
  1. // console.log('main.js', location.href);
  2.  
  3. {
  4.   const port = document.createElement('span');
  5.   port.id = 'uas-port';
  6.   port.prepare = () => {
  7.     port.prefs = JSON.parse(decodeURIComponent(port.dataset.str));
  8.     port.dataset.ready = true;
  9.     port.dataset.type = port.prefs.type;
  10.   };
  11.   port.ogs = new Map();
  12.   port.addEventListener('register', e => {
  13.     const win = e.detail.hierarchy.reduce((p, c) => {
  14.       return p.frames[c];
  15.     }, parent);
  16.     port.ogs.set(e.detail.id, win);
  17.   });
  18.  
  19.   document.documentElement.append(port);
  20.  
  21.   // find user-agent data
  22.   for (const entry of performance.getEntriesByType('navigation')) {
  23.     for (const timing of entry.serverTiming || []) {
  24.       if (timing.name === 'uasw-json-data') {
  25.         port.dataset.str = timing.description;
  26.       }
  27.     }
  28.   }
  29.   // cached
  30.   for (const entry of performance.getEntriesByType('navigation')) {
  31.     if (entry.deliveryType === 'cache-storage') {
  32.       port.dataset.cached = true;
  33.       break;
  34.     }
  35.   }
  36.  
  37.   if (port.dataset.str) {
  38.     port.prepare();
  39.   }
  40.   else {
  41.     // extension is not active for this tab or top-level request is from service worker
  42.     if (self.top === self) {
  43.       if (port.dataset.cached !== 'true') {
  44.         port.dataset.disabled = true;
  45.       }
  46.     }
  47.   }
  48. }
  49.  

Reply to "onst port document createElement span"

Here you can reply to the paste above

captcha