File size: 2,773 Bytes
7929f62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<div id="bottomAd" style="font-size: 2px;">&nbsp;</div>
<script type="text/javascript">
    window.addEventListener('DOMContentLoaded', function () {
        if ('undefined' === (typeof hasBlockedContent) || hasBlockedContent !== false) {
            {# if hasBlockedContent was "false" most likely nothing was blocked #}
            (function () {
                {# most likely jQuery is not available, have to use vanilla JS here #}
                var body = document.getElementsByTagName('body');

                if (!body || !body[0]) {
                    return;
                }

                var bottomAd = document.getElementById('bottomAd');
                var wasMostLikelyCausedByAdblock = false;

                if (!bottomAd) {
                    wasMostLikelyCausedByAdblock = true;
                } else if (bottomAd.style && bottomAd.style.display === 'none') {
                    wasMostLikelyCausedByAdblock = true;
                } else if ('undefined' !== (typeof bottomAd.clientHeight) && bottomAd.clientHeight === 0) {
                    wasMostLikelyCausedByAdblock = true;
                }

                if (wasMostLikelyCausedByAdblock) {
                    var shouldGetHiddenElement = document.getElementById("should-get-hidden");
                    var warning = document.createElement('p');
                    warning.innerText = '{{ 'CoreHome_AdblockIsMaybeUsed'|translate|e('js') }}';

                    var warningBox = document.createElement('div');
                    warningBox.style.border = '3px solid red';
                    warningBox.style.padding = '10px';
                    warningBox.style.margin = '10px 20px'; 
                    warningBox.style.textAlign = 'center';
                    warningBox.style.display = 'flex';
                    warningBox.style.justifyContent = 'center';
                    warningBox.style.alignItems = 'center';
                    warningBox.style.position = 'fixed';
                    warningBox.style.top = '0';
                    warningBox.style.left = '0';
                    warningBox.style.right = '0'; 
                    warningBox.style.backgroundColor = 'white';
                    warningBox.style.zIndex = '1000';

                    warning.style.color = 'red';
                    warning.style.fontWeight = 'bold';
                    warning.style.fontSize = '20px';

                    warningBox.appendChild(warning);

                    if (shouldGetHiddenElement) {
                        shouldGetHiddenElement.appendChild(warningBox);
                    } else {
                        body[0].insertBefore(warningBox, body[0].firstChild);
                    }
                }
            })();
        }
    });
</script>