1try 2{ 3 function write(text) 4 { 5 document.body.appendChild(document.createTextNode(text)); 6 }; 7 8 function writeln(text) 9 { 10 write(text); 11 document.body.appendChild(document.createElement('br')); 12 }; 13 14 write('Clearing Cache...'); 15 16 navigator.serviceWorker.getRegistrations().then(function(registrations) 17 { 18 if (registrations != null && registrations.length > 0) 19 { 20 for (var i = 0; i < registrations.length; i++) 21 { 22 registrations[i].unregister(); 23 } 24 25 writeln('Done'); 26 } 27 else 28 { 29 writeln('OK'); 30 } 31 32 if ((/test\.draw\.io$/.test(window.location.hostname)) || 33 (/app\.diagrams\.net$/.test(window.location.hostname))) 34 { 35 var link = document.createElement('a'); 36 link.setAttribute('href', './'); 37 link.appendChild(document.createTextNode('Start App')); 38 document.body.appendChild(link); 39 } 40 }); 41} 42catch (e) 43{ 44 write('Error: ' + e.message); 45} 46