PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents / 4.0.5
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents v4.0.5
4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.2.0 2.2.1 2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.1.3 3.2.0 3.2.1 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.4.0 3.4.1 3.4.2 3.4.3 3.5.0 3.5.1 3.5.2 3.5.3 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.7.0 3.7.1 3.7.2 3.7.3 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.9.0 3.9.1 3.9.10 3.9.11 3.9.12 3.9.13 3.9.14 3.9.15 3.9.16 3.9.17 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9 4.0.0 4.0.1 4.0.10 4.0.11 4.0.12 4.0.13 4.0.14 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.0.9 4.1.0 4.1.1 4.1.10 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.2.7 4.2.8 4.2.9 4.3.0 4.3.1 4.4.0 4.4.1 4.4.10 4.4.11 4.4.2 4.4.3 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5.0 4.5.1
embedpress / assets / js / ads.js
embedpress / assets / js Last commit date
vendor 7 years ago admin.js 2 years ago ads.js 2 years ago carousel.min.js 2 years ago documents-viewer-script.js 3 years ago front.js 2 years ago glider.min.js 2 years ago gutneberg-script.js 2 years ago index.html 7 years ago initCarousel.js 2 years ago initplyr.js 2 years ago instafeed.js 2 years ago license.js 2 years ago pdfobject.min.js 3 years ago plyr.polyfilled.js 3 years ago preview.js 3 years ago settings.js 6 years ago vimeo-player.js 2 years ago ytiframeapi.js 2 years ago
ads.js
259 lines
1 const isPyr = document.querySelector('[data-playerid]')?.getAttribute('data-playerid');
2 if (!isPyr) {
3 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" };
4 if (!YT.loading) {
5 YT.loading = 1; (function () {
6 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) {
7 var n = c.nonce || c.getAttribute("nonce"); if (n) a.setAttribute("nonce",
8 n)
9 } var b = document.getElementsByTagName("script")[0]; b.parentNode.insertBefore(a, b)
10 })()
11 };
12 }
13
14
15
16
17 let adsConainers = document.querySelectorAll('[data-sponsored-id]');
18 let container = document.querySelector('[data-sponsored-id]');
19 const player = [];
20 let playerIndex = 0;
21
22
23 adsConainers = Array.from(adsConainers);
24
25 const getYTVideoId = (url) => {
26 // Check if the input is a string
27 if (typeof url !== 'string') {
28 return false;
29 }
30
31 const regex = /(?:youtube\.com\/(?:[^\/]+\/[^\/]+\/|(?:v|e(?:mbed)?)\/|[^#]*[?&]v=)|youtu\.be\/)([^"&?\/\s]{11})/;
32 const match = url.match(regex);
33
34 if (match && match[1]) {
35 return match[1];
36 }
37 return false;
38 }
39
40 const hashParentClass = (element, className) => {
41 var parent = element.parentNode;
42
43 while (parent && !parent.classList?.contains(className)) {
44 parent = parent.parentNode;
45 }
46
47 return !!parent;
48 }
49
50
51
52 const adInitialization = (adContainer, index) => {
53
54 if(!adContainer){
55 return;
56 }
57
58 const adAtts = JSON.parse(atob(adContainer?.getAttribute('data-sponsored-attrs')));
59
60 const blockId = adAtts.clientId;
61 const blockIdMD5 = adContainer.getAttribute('data-sponsored-id');
62 const adStartAfter = adAtts.adStart * 1000;
63 const adContent = adAtts.adContent;
64 const adVideo = adContainer.querySelector('.ep-ad');
65 const adSource = adAtts.adSource;
66 const adVideos = [];
67 const srcUrl = adAtts.url || adAtts.embedpress_embeded_link;
68 const adSkipButtonAfter = parseInt(adAtts.adSkipButtonAfter);
69
70
71 addWrapperForYoutube(adContainer, srcUrl, adAtts);
72
73 // let adVideo = adContainer.querySelector('#ad-' + blockId + ' .ep-ad');
74 adVideos.push(adVideo);
75
76 const adTemplate = adContainer.querySelector('.main-ad-template');
77 const progressBar = adContainer.querySelector('.progress-bar');
78 const skipButton = adContainer.querySelector('.skip-ad-button');
79 const adRunningTime = adContainer.querySelector('.ad-running-time');
80 var playerId;
81 const adMask = adContainer;
82
83
84 let playbackInitiated = false;
85
86 if (skipButton && adSource !== 'video') {
87 skipButton.style.display = 'inline-block';
88 }
89
90 const hashClass = hashParentClass(adContainer, 'ep-content-protection-enabled');
91
92 if (hashClass) {
93 adContainer.classList.remove('ad-mask');
94 }
95
96 adMask?.addEventListener('click', function () {
97
98 if (adContainer.classList.contains('ad-mask')) {
99 playerId = adContainer.querySelector('[data-playerid]')?.getAttribute('data-playerid');
100
101 if (typeof playerInit !== 'undefined' && playerInit.length > 0) {
102 playerInit[playerId]?.play();
103 }
104
105 if (getYTVideoId(srcUrl)) {
106 player[index]?.playVideo();
107 }
108
109 if (!playbackInitiated) {
110 setTimeout(() => {
111 if (adSource !== 'image') {
112 adContainer.querySelector('.ep-embed-content-wraper').classList.add('hidden');
113 }
114 adTemplate?.classList.add('ad-running');
115 if (adVideo && adSource === 'video') {
116 adVideo.muted = false;
117 adVideo.play();
118 }
119 }, adStartAfter);
120
121 playbackInitiated = true;
122 }
123
124 adContainer.classList.remove('ad-mask');
125 }
126
127 });
128
129 adVideo?.addEventListener('timeupdate', () => {
130 const currentTime = adVideo?.currentTime;
131 const videoDuration = adVideo?.duration;
132
133 if (currentTime <= videoDuration) {
134 const remainingTime = Math.max(0, videoDuration - currentTime); // Ensure it's not negative
135 adRunningTime.innerText = Math.floor(remainingTime / 60) + ':' + (Math.floor(remainingTime) % 60).toString().padStart(2, '0');
136 }
137
138 if (!isNaN(currentTime) && !isNaN(videoDuration)) {
139 const progress = (currentTime / videoDuration) * 100;
140 progressBar.style.width = progress + '%';
141
142 if (currentTime >= adSkipButtonAfter) {
143 // Show the skip button after 3 seconds
144 skipButton.style.display = 'inline-block';
145 }
146 }
147 });
148
149
150 // Add a click event listener to the skip button
151 skipButton?.addEventListener('click', () => {
152 adTemplate.remove();
153 if (typeof playerInit !== 'undefined' && playerInit.length > 0) {
154 playerInit[playerId]?.play();
155
156 }
157 if (getYTVideoId(srcUrl)) {
158 player[index]?.playVideo();
159 }
160 adContainer.querySelector('.ep-embed-content-wraper').classList.remove('hidden');
161 });
162
163 // Add an event listener to check for video end
164 adVideo?.addEventListener('play', () => {
165 if (playerInit && playerInit?.length > 0) {
166 playerInit[playerId]?.stop();
167 }
168 });
169
170 // Add an event listener to check for video end
171 adVideo?.addEventListener('ended', () => {
172 // Remove the main ad template from the DOM when the video ends
173 adTemplate.remove();
174 adContainer.querySelector('.ep-embed-content-wraper').classList.remove('hidden');
175 });
176
177 playerIndex++;
178
179 }
180
181 const addWrapperForYoutube = (adContainer, srcUrl, adAtts) => {
182 const youtubeIframe = adContainer.querySelector(`.ose-youtube iframe`);
183 if (youtubeIframe && getYTVideoId(srcUrl)) {
184
185 const divWrapper = document.createElement('div');
186 divWrapper.className = 'ad-youtube-video';
187 youtubeIframe.setAttribute('width', adAtts.width);
188 youtubeIframe.setAttribute('height', adAtts.height);
189 youtubeIframe.parentNode.replaceChild(divWrapper, youtubeIframe);
190 divWrapper.appendChild(youtubeIframe);
191 }
192 }
193
194
195
196 function onYouTubeIframeAPIReady(iframe, srcUrl, adVideo, index) {
197 // Find the iframe by its src attribute
198
199 if (iframe && getYTVideoId(srcUrl) !== null) {
200 player[index] = new YT.Player(iframe, {
201 videoId: getYTVideoId(srcUrl),
202
203 events: {
204 'onReady': (event) => onPlayerReady(event, adVideo),
205 }
206 });
207
208 }
209
210 }
211
212 // This function is called when the player is ready
213 function onPlayerReady(event, adVideo) {
214 adVideo?.addEventListener('ended', function () {
215 event.target.playVideo();
216 });
217
218 adVideo?.addEventListener('play', function () {
219 event.target.pauseVideo();
220 });
221 }
222
223 if (adsConainers.length > 0 && eplocalize.is_pro_plugin_active) {
224
225 window.onload = function () {
226 let yVideos = setInterval(() => {
227 var youtubeVideos = document.querySelectorAll('.ose-youtube');
228 if (youtubeVideos.length > 0) {
229 clearInterval(yVideos);
230
231 youtubeVideos.forEach((yVideo, index) => {
232 const srcUrl = yVideo.querySelector('iframe')?.getAttribute('src');
233 const adVideo = yVideo.closest('.ad-mask')?.querySelector('.ep-ad');
234 const isYTChannel = yVideo.closest('.ad-mask')?.querySelector('.ep-youtube-channel');
235 if (adVideo && !isYTChannel) {
236
237 console.log(isYTChannel);
238
239 onYouTubeIframeAPIReady(yVideo, srcUrl, adVideo, index);
240 }
241 });
242 }
243 }, 100);
244 };
245
246 console.log('ads settings');
247 let ytIndex = 0;
248 adsConainers.forEach((adContainer, epAdIndex) => {
249
250 adContainer.setAttribute('data-ad-index', epAdIndex);
251 adInitialization(adContainer, ytIndex);
252 if (getYTVideoId(adContainer.querySelector('iframe')?.getAttribute('src'))) {
253 ytIndex++;
254 }
255 });
256 }
257 else{
258 jQuery('.ad-mask').removeClass('ad-mask');
259 }