PageSourceSearch

https://hub.videodating.com/sw.js

js videodating.com collected 2026-09-26 07:51:22 UTC 4,584 bytes, 147 lines download raw bytes

1
2const CACHE_NAME = 'offline-affiliateid';
3const OFFLINE_URL = 'offline';
4
5self.addEventListener('install', function (event) {
6    event.waitUntil((async () => {
7        const cache = await caches.open(CACHE_NAME);
8        await cache.add(new Request(OFFLINE_URL, { cache: 'reload' }));
9    })());
10
11    self.skipWaiting();
12});
13
14self.addEventListener('activate', (event) => {
15    event.waitUntil((async () => {
16        if ('navigationPreload' in self.registration) {
17            await self.registration.navigationPreload.enable();
18        }
19    })());
20
21    // clear cache on each start
22    event.waitUntil(
23        caches.keys().then((cacheNames) => {
24            return Promise.all(
25                cacheNames.map((cacheName) => {
26                    return caches.delete(cacheName);
27                })
28            );
29        })
30    );
31
32    // Tell the active service worker to take control of the page immediately.
33    self.clients.claim();
34});
35
36self.addEventListener('fetch', function (event) {
37    // console.log('[Service Worker] Fetch', event.request.url);
38    if (event.request.mode === 'navigate') {
39        const responsePromise = event.preloadResponse
40            .then(function (preloadResponse) {
41                if (preloadResponse) return preloadResponse;
42                return fetch(event.request);
43            })
44            .catch(function () {
45                return fetch(event.request);
46            });
47        event.respondWith(
48            responsePromise.catch(function (error) {
49                if (event.request.url && event.request.url.includes("/Templates/")) {
50                    return caches.open(CACHE_NAME).then(function (cache) {
51                        return cache.match(OFFLINE_URL);
52                    });
53                }
54                throw error;
55            })
56        );
57    }
58});
59
60
61self.addEventListener('push', function (event) {
62    console.log('Received a push message');
63
64    var json = event.data.json();
65
66    var title = json.title;
67    var message = json.message;
68    var icon = json.icon;
69    var notificationTag = json.tag;
70    var actionId = json.actionId;
71    var bigPicture = json.bigPicture;
72    var badge = json.badge;
73
74
75    fetch("/api/profile/UpdatePushActionStatDate?actionId=" + actionId + "&state=1").then(function (response) {
76        if (response.status !== 200) {
77            console.log('Looks like there was a problem. Status Code: ' + response.status);
78            throw new Error();
79        }
80        return response.json().then(function (data) {
81            console.log(data);
82        });
83    }).catch(function (err) {
84        console.error('Unable to retrieve data', err);
85    })
86
87    var options = {
88        body: message,
89        tag: notificationTag
90    };
91
92    if (icon.length > 0) options['icon'] = icon;
93    if (bigPicture.length > 0) options['image'] = bigPicture;
94    if (badge.length > 0) options['badge'] = badge;
95
96    event.waitUntil(
97        self.registration.showNotification(title, options)
98    );
99});
100
101
102self.addEventListener('notificationclick', function (event) {
103
104    event.notification.close();
105
106    if (event.notification.tag == "user_visible_auto_notification")
107        return;
108
109    var obj = event.notification.tag.split("|");
110
111    var siteUrl = obj[0];
112    var actionId = "";
113
114    if (obj[1].indexOf("actionId=") >= 0) {
115        actionId = obj[1].replace("actionId=", "");
116    }
117
118    if (actionId != "") {
119        fetch("/api/profile/UpdatePushActionStatDate?actionId=" + actionId + "&state=2").then(function (response) {
120            if (response.status !== 200) {
121                console.log('Looks like there was a problem. Status Code: ' + response.status);
122                throw new Error();
123            }
124            return response.json().then(function (data) {
125                console.log(data);
126            });
127        }).catch(function (err) {
128            console.error('Unable to retrieve data', err);
129        })
130    }
131
132    event.waitUntil(
133        clients.matchAll({
134            type: "window"
135        })
136            .then(function (clientList) {
137                for (var i = 0; i < clientList.length; i++) {
138                    var client = clientList[i];
139                    if (client.url == '/' && 'focus' in client)
140                        return client.focus();
141                }
142                if (clients.openWindow) {
143                    return clients.openWindow(siteUrl);
144                }
145            })
146    );
147});

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.