PageSourceSearch

https://www.perfectdraft.com/static/version0.0.0.1228/frontend/Bee…/perfectdraft/nl_BE/js/webview-common.js

js perfectdraft.com collected 2026-10-09 22:39:00 UTC 3,270 bytes, 113 lines download raw bytes

1window.isWebview = /PerfectDraftApp/i.test(navigator.userAgent);
2
3const devIsWebview = document.cookie.split('; ').find(row => row.startsWith('isWebview=')) || null;
4if (devIsWebview && devIsWebview.split('=')[1] === 'true') {
5    console.log('wv: ', isWebview)
6    isWebview = true;
7    console.log('dev wv: ', isWebview)
8}
9
10function removeElement(selector) {
11    el = document.querySelectorAll(selector);
12    if (el.length > 0) {
13        console.log('found: ' + selector + '(' + el.length + ')');
14        el[0].remove();
15    } else {
16        console.log('NOT found: ' + selector);
17    }
18}
19
20function waitForElm(selector) {
21    return new Promise(resolve => {
22        const resolveElement = () => {
23            const element = document.querySelector(selector);
24
25            if (element) {
26                resolve(element);
27                return true;
28            }
29
30            return false;
31        };
32
33        if (resolveElement()) {
34            return;
35        }
36
37        const observer = new MutationObserver(() => {
38            if (resolveElement()) {
39                observer.disconnect();
40            }
41        });
42
43        const observe = () => {
44            if (resolveElement()) {
45                return;
46            }
47
48            const observerTarget = document.body || document.documentElement;
49
50            if (!observerTarget || !(observerTarget instanceof window.Node)) {
51                if (document.readyState === 'loading') {
52                    document.addEventListener('DOMContentLoaded', observe, { once: true });
53                }
54
55                return;
56            }
57
58            observer.observe(observerTarget, {
59                childList: true,
60                subtree: true
61            });
62        };
63
64        observe();
65    });
66}
67
68function checkLocales(array) {
69    return new Promise(resolve => {
70        if (Array.isArray(array)) {
71            return resolve(array.some(value => value === window.LOCALE));
72        } 
73    });
74}
75
76function css(element, style) {
77    for (const property in style)
78        element.style[property] = style[property];
79}
80
81window.require(
82    [
83        'jquery',
84    ],
85    function ($) {
86        $(document).ready(function () {
87            var forceAuth = window.localStorage.getItem('forcedAuth');
88            if (window.isWebview && forceAuth) {
89                $.ajax({
90                    cache: false,
91                    type: 'POST',
92                    url: window.BASE_URL + 'customer/app/login',
93                    data: forceAuth,
94                    contentType: "application/json",
95                    success: function(data) {
96                        if (data?.errors) {
97                            console.error('Error happened during authorization: '  + data.message);
98                            openAccountPopup('login');
99                            return;
100                        }
101
102                        if (data?.message !== 'already_login') {
103                            window.location.reload();
104                        }
105                    },
106                    error: function(XMLHttpRequest, textStatus, errorThrown) {
107                        openAccountPopup('login');
108                        return;
109                    }
110                });
111            }
112        });
113    });

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.