PageSourceSearch

https://sf.esrt.site/static/js/pushes/notification.js?v=15

js esrt.site collected 2026-09-24 21:35:34 UTC 5,395 bytes, 128 lines download raw bytes

1var script_ctx = document.currentScript;
2var cdn_path = script_ctx ? script_ctx.getAttribute('data-cnd-path') : '';
3
4function homescreenServiceWorker() {
5    navigator.serviceWorker.register('/homescreen-sw.js?v=0013').then(function(registration) {
6        console.log('ServiceWorker registration successful with scope: ', registration.scope);
7    }, function(err) {
8        console.log('ServiceWorker registration failed: ', err);
9    });
10}
11
12function classNotification(options) {
13    var createClass = {
14        constructor: function (props) {
15            var self = this;
16            self.props = props;
17            self.init();
18            return self;
19        },
20
21        init: function () {
22            var self = this;
23            if (
24                window.location.protocol === 'https:' &&
25                'Notification' in window &&
26                'serviceWorker' in navigator &&
27                'localStorage' in window &&
28                'fetch' in window &&
29                'postMessage' in window
30            ) {
31                setTimeout(function(){
32                    console.log('[fcm] permission', Notification.permission);
33                    if (Notification.permission == 'denied') {
34                        return;
35                    }
36                    var s = document.getElementsByTagName('script')[0]
37                    , p1 = document.createElement('script');
38                    p1.async = 'async';
39                    p1.src = 'https://www.gstatic.com/firebasejs/11.0.1/firebase-app-compat.js';
40                    p1.onload = function() {
41                        console.log(`[fcm] app loaded`);
42
43                        var p2 = document.createElement('script');
44                        p2.async = 'async';
45                        p2.src = 'https://www.gstatic.com/firebasejs/11.0.1/firebase-messaging-compat.js';
46                        p2.onload = function () {
47                            console.debug(`[fcm] messaging loaded`);
48
49                            firebase.initializeApp(options.config);
50                            self.messaging = firebase.messaging();
51                            self.getToken();
52                        };
53                        s.parentNode.insertBefore(p2, s);
54                    };
55                    s.parentNode.insertBefore(p1, s);
56                }, 2500);
57            } else {
58                var err = '[fcm] not supported:'
59                if (window.location.protocol !== 'https:') {
60                    console.warn(err, 'No HTTPS');
61                } else if (!('Notification' in window)) {
62                    console.warn(err, 'Notification not supported');
63                } else if (!('serviceWorker' in navigator)) {
64                    console.warn(err, 'ServiceWorker not supported');
65                } else if (!('localStorage' in window)) {
66                    console.warn(err, 'LocalStorage not supported');
67                } else if (!('fetch' in window)) {
68                    console.warn(err, 'fetch not supported');
69                } else if (!('postMessage' in window)) {
70                    console.warn(err, 'postMessage not supported');
71                }
72            }
73        },
74        getToken: function() {
75            var self = this;
76            if (!!self.messaging) {
77                // permission request in firebase new version by default
78                self.messaging.getToken({vapidKey: 'BKONF7f5GjEiMPyIgcU5lhb-9NIidV62IFpn9Z1sqhnNoPXEmYZnPnHjhyfIHNlT0JQQOxwqBGDvJ8eujhDyzJ4'}).then((token) => {
79                    if (token) {
80                        // sent?
81                        if (localStorage.getItem('fcmToken') === token) {
82                            console.log('[fcm] token already subscribed');
83                            return;
84                        }
85                        console.log('[fcm]', token);
86                        fetch('/fcm/register/' + token, {
87                            'method': 'POST',
88                            'Content-Type': 'application/json'
89                        }).then((res) => {
90                            if (res.status == 200) {
91                                console.log('[fcm] token subscribed');
92                                localStorage.setItem('fcmToken', token);
93                            }
94                            // post error auto-log
95                        }).catch((error) => {
96                            console.error('[fcm] failed to subscribe token', error);
97                        });
98                    } else {
99                        console.warn('[fcm] token is empty');
100                    }
101                }).catch((error) => {
102                    console.error('[fcm] failed to get token', error);
103                });
104            } else {
105                console.error('[fcm] failed to init app');
106            }
107        }
108    };
109
110    return createClass.constructor(options);
111}
112
113function InitNotification() {
114    homescreenServiceWorker();
115
116    var Notification = classNotification({
117        config: {
118            apiKey: "AIzaSyCkepPdql5iVAaluJ3PpdjsOqW_DRd065M",
119            authDomain: "webnotify-b7130.firebaseapp.com",
120            projectId: "webnotify-b7130",
121            storageBucket: "webnotify-b7130.appspot.com",
122            messagingSenderId: "744810671619",
123            appId: "1:744810671619:web:ef082721b8802e30b86836"
124        }
125    });
126}
127
128InitNotification() ;

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.