PageSourceSearch

https://coopchicken.co.uk/wp-content/plugins/embedpress/assets/js/ads_ver-3.9.10.js

js coopchicken.co.uk collected 2026-10-10 00:01:08 UTC 9,562 bytes, 265 lines download raw bytes

1var _____WB$wombat$assign$function_____=function(name){return (self._wb_wombat && self._wb_wombat.local_init && self._wb_wombat.local_init(name))||self[name];};if(!self.__WB_pmw){self.__WB_pmw=function(obj){this.__WB_source=obj;return this;}}{
2let window = _____WB$wombat$assign$function_____("window");
3let self = _____WB$wombat$assign$function_____("self");
4let document = _____WB$wombat$assign$function_____("document");
5let location = _____WB$wombat$assign$function_____("location");
6let top = _____WB$wombat$assign$function_____("top");
7let parent = _____WB$wombat$assign$function_____("parent");
8let frames = _____WB$wombat$assign$function_____("frames");
9let opens = _____WB$wombat$assign$function_____("opens");
10const isPyr = document.querySelector('[data-playerid]')?.getAttribute('data-playerid');
11if (!isPyr) {
12    var scriptUrl = 'https:\/\/www.youtube.com\/s\/player\/9d15588c\/www-widgetapi.vflset\/www-widgetapi.js'; try { var ttPolicy = window.trustedTypes.createPolicy("youtube-widget-api", { createScriptURL: function (x) { return x } }); scriptUrl = ttPolicy.createScriptURL(scriptUrl) } catch (e) { } var YT; if (!window["YT"]) YT = { loading: 0, loaded: 0 }; var YTConfig; if (!window["YTConfig"]) YTConfig = { "host": "https://www.youtube.com" };
13    if (!YT.loading) {
14        YT.loading = 1; (function () {
15            var l = []; YT.ready = function (f) { if (YT.loaded) f(); else l.push(f) }; window.onYTReady = function () { YT.loaded = 1; var i = 0; for (; i < l.length; i++)try { l[i]() } catch (e) { } }; YT.setConfig = function (c) { var k; for (k in c) if (c.hasOwnProperty(k)) YTConfig[k] = c[k] }; var a = document.createElement("script"); a.type = "text/javascript"; a.id = "www-widgetapi-script"; a.src = scriptUrl; a.async = true; var c = document.currentScript; if (c) {
16                var n = c.nonce || c.getAttribute("nonce"); if (n) a.setAttribute("nonce",
17                    n)
18            } var b = document.getElementsByTagName("script")[0]; b.parentNode.insertBefore(a, b)
19        })()
20    };
21}
22
23
24
25
26let adsConainers = document.querySelectorAll('[data-ad-id]');
27let container = document.querySelector('[data-ad-id]');
28const player = [];
29let playerIndex = 0;
30
31
32adsConainers = Array.from(adsConainers);
33
34const getYTVideoId = (url) => {
35    // Check if the input is a string
36    if (typeof url !== 'string') {
37        return false;
38    }
39
40    const regex = /(?:youtube\.com\/(?:[^\/]+\/[^\/]+\/|(?:v|e(?:mbed)?)\/|[^#]*[?&]v=)|youtu\.be\/)([^"&?\/\s]{11})/;
41    const match = url.match(regex);
42
43    if (match && match[1]) {
44        return match[1];
45    }
46    return false;
47}
48
49const hashParentClass = (element, className) => {
50    var parent = element.parentNode;
51
52    while (parent && !parent.classList?.contains(className)) {
53        parent = parent.parentNode;
54    }
55
56    return !!parent;
57}
58
59
60
61const adInitialization = (adContainer, index) => {
62
63    const adAtts = JSON.parse(atob(adContainer.getAttribute('data-ad-attrs')));
64
65    const blockId = adAtts.clientId;
66    const blockIdMD5 = adContainer.getAttribute('data-ad-id');
67    const adStartAfter = adAtts.adStart * 1000;
68    const adContent = adAtts.adContent;
69    const adVideo = adContainer.querySelector('.ep-ad');
70    const adSource = adAtts.adSource;
71    const adVideos = [];
72    const srcUrl = adAtts.url || adAtts.embedpress_embeded_link;
73    const adSkipButtonAfter = parseInt(adAtts.adSkipButtonAfter);
74
75
76    addWrapperForYoutube(adContainer, srcUrl, adAtts);
77
78    // let adVideo = adContainer.querySelector('#ad-' + blockId + ' .ep-ad');
79    adVideos.push(adVideo);
80
81    const adTemplate = adContainer.querySelector('.main-ad-template');
82    const progressBar = adContainer.querySelector('.progress-bar');
83    const skipButton = adContainer.querySelector('.skip-ad-button');
84    const adRunningTime = adContainer.querySelector('.ad-running-time');
85    var playerId;
86    const adMask = adContainer;
87
88
89    let playbackInitiated = false;
90
91    if (skipButton && adSource !== 'video') {
92        skipButton.style.display = 'inline-block';
93    }
94
95    const hashClass = hashParentClass(adContainer, 'ep-content-protection-enabled');
96
97    if (hashClass) {
98        adContainer.classList.remove('ad-mask');
99    }
100
101    adMask?.addEventListener('click', function () {
102
103        if (adContainer.classList.contains('ad-mask')) {
104            playerId = adContainer.querySelector('[data-playerid]')?.getAttribute('data-playerid');
105
106            if (playerInit.length > 0) {
107                playerInit[playerId]?.play();
108            }
109
110            if (getYTVideoId(srcUrl)) {
111                player[index]?.playVideo();
112            }
113
114            if (!playbackInitiated) {
115                setTimeout(() => {
116                    if (adSource !== 'image') {
117                        adContainer.querySelector('.ep-embed-content-wraper').classList.add('hidden');
118                    }
119                    adTemplate?.classList.add('ad-running');
120                    if (adVideo && adSource === 'video') {
121                        adVideo.muted = false;
122                        adVideo.play();
123                    }
124                }, adStartAfter);
125
126                playbackInitiated = true;
127            }
128
129            adContainer.classList.remove('ad-mask');
130        }
131
132    });
133
134    adVideo?.addEventListener('timeupdate', () => {
135        const currentTime = adVideo?.currentTime;
136        const videoDuration = adVideo?.duration;
137
138        if (currentTime <= videoDuration) {
139            const remainingTime = Math.max(0, videoDuration - currentTime); // Ensure it's not negative
140            adRunningTime.innerText = Math.floor(remainingTime / 60) + ':' + (Math.floor(remainingTime) % 60).toString().padStart(2, '0');
141        }
142
143        if (!isNaN(currentTime) && !isNaN(videoDuration)) {
144            const progress = (currentTime / videoDuration) * 100;
145            progressBar.style.width = progress + '%';
146
147            if (currentTime >= adSkipButtonAfter) {
148                // Show the skip button after 3 seconds
149                skipButton.style.display = 'inline-block';
150            }
151        }
152    });
153
154
155    // Add a click event listener to the skip button
156    skipButton?.addEventListener('click', () => {
157        adTemplate.remove();
158        if (playerInit.length > 0) {
159            playerInit[playerId]?.play();
160
161        }
162        if (getYTVideoId(srcUrl)) {
163            player[index]?.playVideo();
164        }
165        adContainer.querySelector('.ep-embed-content-wraper').classList.remove('hidden');
166    });
167
168    // Add an event listener to check for video end
169    adVideo?.addEventListener('play', () => {
170        if (playerInit.length > 0) {
171            playerInit[playerId]?.stop();
172        }
173    });
174
175    // Add an event listener to check for video end
176    adVideo?.addEventListener('ended', () => {
177        // Remove the main ad template from the DOM when the video ends
178        adTemplate.remove();
179        adContainer.querySelector('.ep-embed-content-wraper').classList.remove('hidden');
180    });
181
182    playerIndex++;
183
184}
185
186const addWrapperForYoutube = (adContainer, srcUrl, adAtts) => {
187    const youtubeIframe = adContainer.querySelector(`.ose-youtube iframe`);
188    if (youtubeIframe && getYTVideoId(srcUrl)) {
189
190        const divWrapper = document.createElement('div');
191        divWrapper.className = 'ad-youtube-video';
192        youtubeIframe.setAttribute('width', adAtts.width);
193        youtubeIframe.setAttribute('height', adAtts.height);
194        youtubeIframe.parentNode.replaceChild(divWrapper, youtubeIframe);
195        divWrapper.appendChild(youtubeIframe);
196    }
197}
198
199
200
201function onYouTubeIframeAPIReady(iframe, srcUrl, adVideo, index) {
202    // Find the iframe by its src attribute
203
204    if (iframe && getYTVideoId(srcUrl) !== null) {
205        player[index] = new YT.Player(iframe, {
206            videoId: getYTVideoId(srcUrl),
207
208            events: {
209                'onReady': (event) => onPlayerReady(event, adVideo),
210            }
211        });
212
213    }
214
215}
216
217// This function is called when the player is ready
218function onPlayerReady(event, adVideo) {
219    adVideo?.addEventListener('ended', function () {
220        event.target.playVideo();
221    });
222
223    adVideo?.addEventListener('play', function () {
224        event.target.pauseVideo();
225    });
226}
227
228if (adsConainers.length > 0 && eplocalize.is_pro_plugin_active) {
229
230    window.onload = function () {
231        let yVideos = setInterval(() => {
232            var youtubeVideos = document.querySelectorAll('.ose-youtube');
233            if (youtubeVideos.length > 0) {
234                clearInterval(yVideos);
235
236                youtubeVideos.forEach((yVideo, index) => {
237                    const srcUrl = yVideo.querySelector('iframe')?.getAttribute('src');
238                    const adVideo = yVideo.closest('.ad-mask')?.querySelector('.ep-ad');
239                    const isYTChannel = yVideo.closest('.ad-mask')?.querySelector('.ep-youtube-channel');
240                    if (adVideo && !isYTChannel) {
241
242                        console.log(isYTChannel);
243
244                        onYouTubeIframeAPIReady(yVideo, srcUrl, adVideo, index);
245                    }
246                });
247            }
248        }, 100);
249    };
250    
251    console.log('ads settings');
252    let ytIndex = 0;
253    adsConainers.forEach((adContainer, epAdIndex) => {
254
255        adContainer.setAttribute('data-ad-index', epAdIndex);
256        adInitialization(adContainer, ytIndex);
257        if (getYTVideoId(adContainer.querySelector('iframe')?.getAttribute('src'))) {
258            ytIndex++;
259        }
260    });
261}
262else{
263    jQuery('.ad-mask').removeClass('ad-mask');
264}
265}

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.