PageSourceSearch

https://sf.rtbrasil.com/static/js/pushes/notification.js?v=14

js rtbrasil.com collected 2026-10-02 11:25:43 UTC 3,680 bytes, 103 lines download raw bytes

1var messaging = null;
2var config = {
3    apiKey: "AIzaSyCkepPdql5iVAaluJ3PpdjsOqW_DRd065M",
4    authDomain: "webnotify-b7130.firebaseapp.com",
5    projectId: "webnotify-b7130",
6    storageBucket: "webnotify-b7130.appspot.com",
7    messagingSenderId: "744810671619",
8    appId: "1:744810671619:web:ef082721b8802e30b86836"
9};
10
11if (window.location.protocol === 'https:' &&
12    'Notification' in window &&
13    'serviceWorker' in navigator &&
14    'localStorage' in window &&
15    'fetch' in window &&
16    'postMessage' in window
17) {
18    notificationInit();
19} else {
20    var err = '[fcm] not supported:'
21    if (window.location.protocol !== 'https:') {
22        console.warn(err, 'No HTTPS');
23    } else if (!('Notification' in window)) {
24        console.warn(err, 'Notification not supported');
25    } else if (!('serviceWorker' in navigator)) {
26        console.warn(err, 'ServiceWorker not supported');
27    } else if (!('localStorage' in window)) {
28        console.warn(err, 'LocalStorage not supported');
29    } else if (!('fetch' in window)) {
30        console.warn(err, 'fetch not supported');
31    } else if (!('postMessage' in window)) {
32        console.warn(err, 'postMessage not supported');
33    }
34}
35
36function notificationInit() {
37    console.log('[fcm] permission', Notification.permission);
38    if (Notification.permission == 'denied') {
39        return;
40    }
41    var s = document.getElementsByTagName('script')[0]
42    , p1 = document.createElement('script');
43    p1.async = 'async';
44    p1.src = 'https://www.gstatic.com/firebasejs/11.0.1/firebase-app-compat.js';
45    p1.onload = function() {
46        console.log(`[fcm] app loaded`);
47
48        var p2 = document.createElement('script');
49        p2.async = 'async';
50        p2.src = 'https://www.gstatic.com/firebasejs/11.0.1/firebase-messaging-compat.js';
51        p2.onload = function () {
52            console.debug(`[fcm] messaging loaded`);
53
54            firebase.initializeApp(config);
55            messaging = firebase.messaging();
56            subscribe();
57        };
58        s.parentNode.insertBefore(p2, s);
59    };
60    s.parentNode.insertBefore(p1, s);
61}
62
63function subscribe() {
64    if (!!messaging) {
65        // permission request in firebase new version by default
66        messaging.getToken({vapidKey: 'BKONF7f5GjEiMPyIgcU5lhb-9NIidV62IFpn9Z1sqhnNoPXEmYZnPnHjhyfIHNlT0JQQOxwqBGDvJ8eujhDyzJ4'}).then((token) => {
67            if (token) {
68                // sent?
69                if (localStorage.getItem('fcmToken') === token) {
70                    console.log('[fcm] token already subscribed');
71                    return;
72                }
73                console.log('[fcm]', token);
74                fetch('/fcm/register/' + token, {
75                    'method': 'POST',
76                    'Content-Type': 'application/json'
77                }).then((res) => {
78                    if (res.status == 200) {
79                        console.log('[fcm] token subscribed');
80                        localStorage.setItem('fcmToken', token);
81                    }
82                    // post error auto-log
83                }).catch((error) => {
84                    console.error('[fcm] failed to subscribe token', error);
85                });
86            } else {
87                console.warn('[fcm] token is empty');
88            }
89        }).catch((error) => {
90            console.error('[fcm] failed to get token', error);
91        });
92    } else {
93        console.error('[fcm] failed to init app');
94        window.RTPushBanner && window.RTPushBanner.unsubscribed();
95        window.RTPushBanner && window.RTPushBanner.handleClick(openInfo);
96    }
97}
98
99function openInfo(link) {
100    if (!!link) {
101        window.open(link);
102    }
103}

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.