MediaWiki:VanguardTools/service-worker.js

(function {   "use strict";

/**    * Dummy 'mw' object fix by OneTwoThreeFall */   self.mw = { loader: { state: function {} }   };

/**    * Generate a service worker notification */   self.registration.showNotification('Do you want to create an infobox in source mode?', {        actions: [            {                action: 'ok',                title: 'Ok',                icon: 'https://images.wikia.nocookie.net/common/extensions/wikia/DesignSystem/node_modules/design-system/dist/svg/wds-icons-plus-tiny.svg'            },            {                action: 'cancel',                title: 'Cancel',                icon: 'https://images.wikia.nocookie.net/common/extensions/wikia/DesignSystem/node_modules/design-system/dist/svg/wds-icons-cross-tiny.svg'            }        ]    });

/**    * Wait for action */   self.addEventListener('notificationclick', function(e) {        if (e.action !== 'ok') { return; }        var msg_chan = new MessageChannel;        client.postMessage({van: true}, [msg_chan.port2]);    });

});