partitioning-utils.js (515B)
1 function getOrCreateID(key) { 2 if (!localStorage.getItem(key)) { 3 const newID = +new Date() + "-" + Math.random(); 4 localStorage.setItem(key, newID); 5 } 6 return localStorage.getItem(key); 7 } 8 9 function addIframePromise(url) { 10 return new Promise(resolve => { 11 const iframe = document.createElement("iframe"); 12 iframe.style.display = "none"; 13 iframe.src = url; 14 iframe.addEventListener("load", (e) => { 15 resolve(iframe); 16 }, {once: true}); 17 18 document.body.appendChild(iframe); 19 }); 20 }