PageSourceSearch

https://www.duaexplorer.com/service-worker-0001.js

js duaexplorer.com collected 2026-10-02 00:29:45 UTC 4,689 bytes, 119 lines download raw bytes

1self.addEventListener('push', function (event) {
2    console.log("look script   " + JSON.stringify(event));
3
4    var title = "";//_data.title;
5    var body = ""; //_data.body;
6    var icon = ""; //_data.icon + '/images/icon-192x192.png';
7    var tag = ""; //_data.tag;
8    var image = "";
9    var redirectUrl = ""; //_data.redirectUrl;
10    var dataObj = {
11        redirectUrl: '',
12        primaryKey: ''
13    };
14
15    event.waitUntil(
16        self.registration.pushManager.getSubscription().then(function (subscription) {
17            var endpointSections = subscription.endpoint.split('/');
18            var subscriptionId = endpointSections[endpointSections.length - 1];
19            console.log("Look endpoint  final  " + subscriptionId);
20            return fetch('processNotification.aspx?subscriptionId=' + subscriptionId).then(function (data) {
21            return data.text().then(function (json) {
22                    console.log(json);
23                    var _data = JSON.parse(json);
24                    console.log(_data.body + '   ' + _data.title + '   ' + _data.icon + '   ' + _data.tag);
25                    title = _data.title;
26                    body = _data.body;
27                    icon = _data.icon;
28                    tag = _data.tag;
29                    image = _data.image,
30                    dataObj.redirectUrl = _data.redirectUrl;
31                    dataObj.primaryKey = _data.primaryKey
32
33                    return self.registration.showNotification(title, {
34                        body: body,
35                        icon: icon,
36                        image: image,
37                        tag: tag,
38                        data: dataObj,
39                        requireInteraction: true
40                    })
41                });
42            }).catch(function (err) {
43                return console.log(err);
44            })
45        })
46    );
47    //event.waitUntil(
48    //    self.registration.showNotification(title, {
49    //        body: body,
50    //        icon: icon,
51    //        tag: tag
52    //    })..
53    //);
54});
55
56self.addEventListener('notificationclick', function (event) {
57    var UrlToOpen = event.notification.data.redirectUrl;
58    console.log('On notification click: url ', UrlToOpen);
59    // Android doesn’t close the notification when you click on it
60    // See: http://crbug.com/463146
61    event.notification.close();
62
63    // This looks to see if the current is already open and
64    // focuses if it is
65    event.waitUntil(clients.matchAll({
66        type: "window"
67    }).then(function (clientList) {
68    return fetch('TrackClickOnNotification.aspx?CampaignDetailId=' + event.notification.data.primaryKey).then(function (data) {
69            return data.text().then(function (json) {
70            console.log('On notification click: url 4444    ', UrlToOpen);
71                for (var i = 0; i < clientList.length; i++) {
72                    var client = clientList[i];
73                    if (client.url == '/' && 'focus' in client)
74                        return client.focus();
75                }
76                if (clients.openWindow)
77                {
78                console.log('On notification click: url 55555    ', UrlToOpen);
79                    return clients.openWindow(UrlToOpen);
80                    }
81            });
82        }).catch(function (err) {
83            return console.log(err);
84        })
85    }));
86
87});
88
89self.addEventListener('notificationclose', function (e) {
90    var notification = e.notification;
91    var primaryKey = notification.data.primaryKey;
92
93    console.log('Closed notification: ' + primaryKey);
94});
95
96self.addEventListener('install', function (event) {
97    event.waitUntil(
98      caches.open('QE-cache').then(function (cache) {
99          // Important to `return` the promise here to have `skipWaiting()`
100          // fire after the cache has been updated.
101          return cache.addAll([/* file1.jpg, file2.png, ... */]);
102      }).then(function () {
103          // `skipWaiting()` forces the waiting ServiceWorker to become the
104          // active ServiceWorker, triggering the `onactivate` event.
105          // Together with `Clients.claim()` this allows a worker to take effect
106          // immediately in the client(s).
107          return self.skipWaiting();
108      })
109    );
110});
111
112
113self.addEventListener('activate', function (event) {
114    console.log('On activate click: ');
115    // `claim()` sets this worker as the active worker for all clients that
116    // match the workers scope and triggers an `oncontrollerchange` event for
117    // the clients.
118    return self.clients.claim();
119});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.