PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more / 4.2.7
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more v4.2.7
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 1 year ago ads.js 1 year ago carousel.js 1 year ago carousel.min.js 2 years ago documents-viewer-script.js 3 years ago embed-ui.min.js 1 year ago front.js 1 year ago gallery-justify.js 1 year ago glider.js 1 year ago glider.min.js 2 years ago gutneberg-script.js 1 year 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.js 1 year ago plyr.js 1 year 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
264 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
55 if(!adContainer){
56 return;
57 }
58
59 const adAtts = JSON.parse(atob(adContainer?.getAttribute('data-sponsored-attrs')));
60
61 const blockId = adAtts.clientId;
62 const blockIdMD5 = adContainer.getAttribute('data-sponsored-id');
63 const adStartAfter = adAtts.adStart * 1000;
64 const adContent = adAtts.adContent;
65 const adVideo = adContainer.querySelector('.ep-ad');
66 const adSource = adAtts.adSource;
67 const adVideos = [];
68 const srcUrl = adAtts.url || adAtts.embedpress_embeded_link;
69 const adSkipButtonAfter = parseInt(adAtts.adSkipButtonAfter);
70
71
72 addWrapperForYoutube(adContainer, srcUrl, adAtts);
73
74 // let adVideo = adContainer.querySelector('#ad-' + blockId + ' .ep-ad');
75 adVideos.push(adVideo);
76
77 const adTemplate = adContainer.querySelector('.main-ad-template');
78 const progressBar = adContainer.querySelector('.progress-bar');
79 const skipButton = adContainer.querySelector('.skip-ad-button');
80 const adRunningTime = adContainer.querySelector('.sponsored-running-time');
81 var playerId;
82 const adMask = adContainer;
83
84
85 let playbackInitiated = false;
86
87 if (skipButton && adSource !== 'video') {
88 skipButton.style.display = 'inline-block';
89 }
90
91 const hashClass = hashParentClass(adContainer, 'ep-content-protection-enabled');
92
93 if (hashClass) {
94 adContainer.classList.remove('sponsored-mask');
95 }
96
97 adMask?.addEventListener('click', function () {
98
99 if (adContainer.classList.contains('sponsored-mask')) {
100 playerId = adContainer.querySelector('[data-playerid]')?.getAttribute('data-playerid');
101
102 if (typeof playerInit !== 'undefined' && playerInit.length > 0) {
103 playerInit[playerId]?.play();
104 }
105
106 if (getYTVideoId(srcUrl)) {
107 player[index]?.playVideo();
108 }
109
110 if (!playbackInitiated) {
111 setTimeout(() => {
112 if (adSource !== 'image') {
113 adContainer.querySelector('.ep-embed-content-wraper').classList.add('hidden');
114 }
115 adTemplate?.classList.add('sponsored-running');
116 if (adVideo && adSource === 'video') {
117 adVideo.muted = false;
118 adVideo.play();
119 }
120 }, adStartAfter);
121
122 playbackInitiated = true;
123 }
124
125 adContainer.classList.remove('sponsored-mask');
126 }
127
128 });
129
130 adVideo?.addEventListener('timeupdate', () => {
131 const currentTime = adVideo?.currentTime;
132 const videoDuration = adVideo?.duration;
133
134 if (currentTime <= videoDuration) {
135 const remainingTime = Math.max(0, videoDuration - currentTime); // Ensure it's not negative
136 adRunningTime.innerText = Math.floor(remainingTime / 60) + ':' + (Math.floor(remainingTime) % 60).toString().padStart(2, '0');
137 }
138
139 if (!isNaN(currentTime) && !isNaN(videoDuration)) {
140 const progress = (currentTime / videoDuration) * 100;
141 progressBar.style.width = progress + '%';
142
143 if (currentTime >= adSkipButtonAfter) {
144 // Show the skip button after 3 seconds
145 skipButton.style.display = 'inline-block';
146 }
147 }
148 });
149
150
151 // Add a click event listener to the skip button
152 skipButton?.addEventListener('click', () => {
153 adTemplate.remove();
154 if (typeof playerInit !== 'undefined' && playerInit.length > 0) {
155 playerInit[playerId]?.play();
156
157 }
158 if (getYTVideoId(srcUrl)) {
159 player[index]?.playVideo();
160 }
161 adContainer.querySelector('.ep-embed-content-wraper').classList.remove('hidden');
162 });
163
164 // Add an event listener to check for video end
165 adVideo?.addEventListener('play', () => {
166 if (playerInit && playerInit?.length > 0) {
167 playerInit[playerId]?.stop();
168 }
169 });
170
171 // Add an event listener to check for video end
172 adVideo?.addEventListener('ended', () => {
173 // Remove the main ad template from the DOM when the video ends
174 adTemplate.remove();
175 adContainer.querySelector('.ep-embed-content-wraper').classList.remove('hidden');
176 });
177
178 playerIndex++;
179
180 }
181
182 const isYoutubeChannel = (srcUrl) => {
183 const youtubeChannelRegex = /^(https?:\/\/)?(www\.)?youtube\.com\/(channel|user)\/[A-Za-z0-9_-]+\/?$/;
184 return youtubeChannelRegex.test(srcUrl);
185 };
186
187 const addWrapperForYoutube = (adContainer, srcUrl, adAtts) => {
188
189 const youtubeIframe = adContainer.querySelector(`.ose-youtube iframe`);
190
191 if (youtubeIframe && getYTVideoId(srcUrl)) {
192
193 const divWrapper = document.createElement('div');
194 divWrapper.className = 'ad-youtube-video';
195 youtubeIframe.setAttribute('width', adAtts.width);
196 youtubeIframe.setAttribute('height', adAtts.height);
197 youtubeIframe.parentNode.replaceChild(divWrapper, youtubeIframe);
198 divWrapper.appendChild(youtubeIframe);
199 }
200 }
201
202
203
204 function onYouTubeIframeAPIReady(iframe, srcUrl, adVideo, index) {
205 // Find the iframe by its src attribute
206
207 if (iframe && getYTVideoId(srcUrl) !== null) {
208 player[index] = new YT.Player(iframe, {
209 videoId: getYTVideoId(srcUrl),
210
211 events: {
212 'onReady': (event) => onPlayerReady(event, adVideo),
213 }
214 });
215
216 }
217
218 }
219
220 // This function is called when the player is ready
221 function onPlayerReady(event, adVideo) {
222 adVideo?.addEventListener('ended', function () {
223 event.target.playVideo();
224 });
225
226 adVideo?.addEventListener('play', function () {
227 event.target.pauseVideo();
228 });
229 }
230
231 if (adsConainers.length > 0 && eplocalize.is_pro_plugin_active) {
232
233 window.onload = function () {
234 let yVideos = setInterval(() => {
235 var youtubeVideos = document.querySelectorAll('.ose-youtube');
236 if (youtubeVideos.length > 0) {
237 clearInterval(yVideos);
238
239 youtubeVideos.forEach((yVideo, index) => {
240 const srcUrl = yVideo.querySelector('iframe')?.getAttribute('src');
241 const adVideo = yVideo.closest('.sponsored-mask')?.querySelector('.ep-ad');
242 const isYTChannel = yVideo.closest('.sponsored-mask')?.querySelector('.ep-youtube-channel');
243 if (adVideo && !isYTChannel) {
244
245 onYouTubeIframeAPIReady(yVideo, srcUrl, adVideo, index);
246 }
247 });
248 }
249 }, 100);
250 };
251
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 }
262 else{
263 jQuery('.sponsored-mask').removeClass('sponsored-mask');
264 }