'use strict' const IPFS = require('ipfs') function App() { let node create() function create() { if ('serviceWorker' in navigator) { const this_script_url = document.currentScript.src; const base_script_url = this_script_url.slice(0, this_script_url.lastIndexOf('/')) navigator.serviceWorker.register(base_script_url + '/fetcher.js') .then((registration) => { console.log('registered the service worker successfully') // Now that a service worker is registered to intercept URLs, reload the page so // this page's URL gets loaded from IPFS by the service worker. if (window.location.pathname.startsWith('/ipfs/')) { window.location.reload(false) } }) .catch((err) => { console.log('failed to register the service worker:', err) }) } } } module.exports = App App()