PageSourceSearch

https://radiolot.cat/wp-content/plugins/advanced-ads-pro/assets/advanced-ads-pro.js

js radiolot.cat collected 2026-10-02 12:47:17 UTC 9,000 bytes, 309 lines download raw bytes

1;(function($){
2	
3	// CFP cookies prefix
4	var cname = 'advads_procfp';
5	var cname_vc = 'advanced_ads_ad_clicks'; // visitor conditions
6	
7	// CFP cookies parameter ( domain/path )
8	var PATH = null;
9	var DOMAIN = null;
10	
11	/**
12	 * wrapper for JSON.parse 
13	 */
14	function jsonDecode( str ) {
15		try {
16			var res = JSON.parse( str );
17			return res;
18		} catch( Ex ) {
19			return null;
20		}
21	}
22	
23	// Max ad click conditions/ passive Cache busting.
24	
25	$( document ).on( 'advads-passive-cb-conditions', function( e, cbs ) {
26		cbs.conditions['ad_clicks'] = 'check_ad_clicks';
27		cbs['check_ad_clicks'] = function ( options, ad ) {
28			if ( advads.cookie_exists( cname_vc + '_' + ad.id ) ) {
29				var C_vc = advads.get_cookie( cname_vc + '_' + ad.id );
30				C_vc = jsonDecode( C_vc );
31			}
32			
33			if ( C_vc ) {
34				var now = parseInt( new Date().getTime() / 1000 );
35				for ( var i in C_vc ) {
36					
37					if ( '_' + options.expiration == i ) {
38						
39						// if still valid counter and click limit reached
40						if ( C_vc[i]['ttl'] >= now && C_vc[i]['count'] >= parseInt( options.limit ) ) {
41							return false;
42						}
43						
44					}
45					
46				}
47			}
48			
49			return true;
50		};
51	});
52	
53	var cfpTracker = function() {
54		this.$elements = {};
55		this.currentIFrame = false;
56		this.focusLost = false;
57		this.init();
58	}
59	
60	cfpTracker.prototype = {
61		
62		constructor: cfpTracker,
63		
64		init: function() {
65			var that = this;
66
67			// increment counter on click on link
68			$( document ).on( 'click', 'a[data-cfpa]', function(){
69				that.onClick( parseInt( $( this ).attr( 'data-cfpa' ) ) );
70			} );
71			
72			// increment counter on blur only if an iframe has recently bern hovered
73			$( window ).on( 'blur', function() {
74				if ( false !== that.currentIFrame ) {
75					that.onClick( that.currentIFrame );
76					that.currentIFrame = false;
77					that.focusLost = true;
78				}
79			} );
80			
81			// mouse passes over an ad that has not yet been initialized (adsense and other distant ads - OR just an ad that contains no link nor iframes)
82			$( document ).on( 'mouseenter', 'div[data-cfpa]', function(){
83				var id = parseInt( $( this ).attr( 'data-cfpa' ) );
84				that.addElement( id );
85			} );
86		},
87		
88		addElement: function( $el ) {
89			if ( false === $el instanceof jQuery ) {
90				// Select the first ad since there may be multiple copies of the same ad on the page.
91				$el = $( 'div[data-cfpa="' + $el + '"]' ).first();
92			}
93			
94			var hasIframe = $el.find( 'iframe' ).length ? true : false;
95			if ( !hasIframe ) {
96				if ( !$el.find( 'a' ).length ) {
97					// no an anchor and no iframe -- likely and ad that is not yet loaded (adsense or other ad network)
98					return;
99				}
100			}
101			
102			var adID = parseInt( $el.attr( 'data-cfpa' ) );
103			
104			this.$elements[adID] = $el;
105			
106			// remove attribute from the wrapper
107			$el.removeAttr( 'data-cfpa' );
108			
109			// And then move it to the first anchor or iframe found
110			if ( hasIframe ) {
111				$el.find( 'iframe' ).first().attr({
112					'data-cfpa': adID,
113				})
114				if ( $el.attr( 'data-cfph' ) ) {
115					$el.find( 'iframe' ).first().attr({
116						'data-cfph': $el.attr( 'data-cfph' ),
117					})
118				}
119			} else {
120				$el.find( 'a' ).not( '.advads-edit-button' ).first().attr({
121					'data-cfpa': adID,
122				})
123				if ( $el.attr( 'data-cfph' ) ) {
124					$el.find( 'a' ).not( '.advads-edit-button' ).first().attr({
125						'data-cfph': $el.attr( 'data-cfph' ),
126					})
127				}
128			}
129			// remove Hours attribute from the wrapper
130			$el.removeAttr( 'data-cfph' );
131			
132			// update TTL field for all outdated counter (visitor conditions)
133			if ( advads.cookie_exists( cname_vc + '_' + adID ) ) {
134				
135				var C_vc = advads.get_cookie( cname_vc + '_' + adID );
136				C_vc = jsonDecode( C_vc );
137				
138				if ( C_vc ) {
139					var now = parseInt( new Date().getTime() / 1000 ), cookie_modified = false;
140					for ( var i in C_vc ) {
141						if ( !C_vc.hasOwnProperty( i ) ) continue;
142						if ( 'exp' == i ) continue;
143						if ( C_vc[i]['ttl'] < now ) {
144							var period = parseFloat( i.substr( 1 ) );
145							var newTTL = C_vc[i]['ttl'];
146							while ( newTTL < now ) {
147								newTTL += period * 60 * 60;
148							}
149							C_vc[i]['ttl'] = newTTL;
150							C_vc[i]['count'] = 0;
151							cookie_modified = true;
152						}
153					}
154					if ( cookie_modified ) {
155						var expTime = new Date( C_vc['exp'] );
156						advads.set_cookie_sec( cname_vc + '_' + adID, JSON.stringify( C_vc, 'false', false ), parseInt( expTime.getTime() / 1000 ), PATH, DOMAIN );
157					}
158				}
159				
160			}
161		},
162
163		/**
164		 * Ban the visitor
165		 */
166		_banVisitor: function() {
167			var now = new Date();
168			var d = new Date();
169			d.setTime( d.getTime() + ( advadsCfpBan*24*60*60*1000 ) );
170			var ban = ( d.getTime() - now.getTime() ) / 1000;
171			advads.set_cookie_sec( 'advads_pro_cfp_ban', 1, ban, PATH, DOMAIN );
172
173			// Select all top level ad wrappers and delete them.
174			jQuery( '[data-cfptl]' ).remove();
175		},
176		
177		onClick: function( ID ){
178			var C = false, C_vc = false, that = this;
179			
180			if ( $( '[data-cfpa="' + ID + '"]' ).attr( 'data-cfph' ) ) {
181				// if there are some visitor conditions, use the vc cookie
182				
183				if ( advads.cookie_exists( cname_vc + '_' + ID ) ) {
184					C_vc = advads.get_cookie( cname_vc + '_' + ID );
185					C_vc = jsonDecode( C_vc );
186				}
187				
188				if ( C_vc ) {
189					// Cookie already exists, increment each counter (keep expiration time)
190					for ( var h in C_vc ) {
191						if ( !C_vc.hasOwnProperty( h ) ) continue;
192						if ( 'exp' == h ) continue;
193						var count = parseInt( C_vc[h]['count'] );
194						C_vc[h]['count'] = count + 1;
195					}
196					var now = new Date();
197					var expiry = new Date( C_vc.exp );
198					var expirySecs = parseInt( ( expiry.getTime() - now.getTime() ) / 1000 );
199					advads.set_cookie_sec( cname_vc + '_' + ID, JSON.stringify( C_vc, 'false', false ), expirySecs, PATH, DOMAIN );
200				} else {
201					// create a new cookie
202					var H = $( '[data-cfpa="' + ID + '"]' ).attr( 'data-cfph' ).split( '_' );
203					var cval = {}, maxHValue = 0;
204					
205					var d = new Date();
206					var now = new Date();
207					
208					for ( var h in H ) {
209						if ( parseFloat( H[h] ) > maxHValue ) {
210							maxHValue = parseFloat( H[h] );
211						}
212						cval['_' + H[h]] = {
213							count: 1,
214							ttl: parseInt( ( ( now.getTime() / 1000 ) + ( parseFloat( H[h] ) * 3600 ) ) ),
215						};
216					}
217					
218					// use the longest hour value for the expiry time
219					d.setTime( d.getTime() + ( maxHValue * 60 * 60 * 1000 ) );
220					var expires = "expires="+ d.toUTCString();
221					var expirySecs = parseInt( ( d.getTime() - now.getTime() ) / 1000 );
222					
223					cval['exp'] = expires;
224					advads.set_cookie_sec( cname_vc + '_' + ID, JSON.stringify( cval, 'false', false ), expirySecs, PATH, DOMAIN );
225				}
226				
227			}
228
229			// use the module wide CFP cookie
230			if ( advads.cookie_exists( cname + '_' + ID ) ) {
231				C = advads.get_cookie( cname + '_' + ID );
232				C = jsonDecode( C );
233			}
234			if ( C ) {
235				// Cookie already exists, increment the counter (keep expiration time)
236				
237				var count = parseInt( C.count );
238				C.count = count +1;
239				var now = new Date();
240				var expiry = new Date( C.exp );
241				var expirySecs = ( expiry.getTime() - now.getTime() ) / 1000;
242				advads.set_cookie_sec( cname + '_' + ID, JSON.stringify( C, 'false', false ), expirySecs, PATH, DOMAIN );
243				if ( advadsCfpClickLimit <= C.count && 'undefined' != typeof advadsCfpBan ) {
244					// CFP module enabled - ban this visitor
245					that._banVisitor();
246				}
247			} else {
248				// create a new cookie
249				
250				var d = new Date();
251				var now = new Date();
252				d.setTime( d.getTime() + ( advadsCfpExpHours*60*60*1000 ) );
253				var expires = "expires="+ d.toUTCString();
254				var expirySecs = ( d.getTime() - now.getTime() ) / 1000;
255				advads.set_cookie_sec( cname + '_' + ID, '{"count":1,"exp":"' + expires + '"}', expirySecs, PATH, DOMAIN );
256				if ( advadsCfpClickLimit === 1 && 'undefined' != typeof advadsCfpBan ) {
257					// CFP module enabled - ban this visitor
258					that._banVisitor();
259				}
260			}
261		},
262	}
263	
264	$( function(){
265
266		/**
267		 * Max ad click ( visitor conditions )
268		 */
269		window.advadsProCfp = new cfpTracker();
270
271		// IFRAME click tracking
272		$( document ).on( 'mouseenter', 'iframe[data-cfpa]', function(){
273			var ID = parseInt( $( this ).attr( 'data-cfpa' ) );
274			advadsProCfp.currentIFrame = ID;
275		} ).on( 'mouseleave', '[data-cfpa]', function(){
276			advadsProCfp.currentIFrame = false;
277			if ( advadsProCfp.focusLost ) {
278				advadsProCfp.focusLost = false;
279				$( window ).trigger( 'focus' );
280			}
281		} );
282		
283		// construct all elements already present in the queue
284		for( var i in advadsCfpQueue ) {
285			if ( advadsCfpQueue.hasOwnProperty( i ) ) {
286				advadsProCfp.addElement( advadsCfpQueue[i] );
287			}
288		}
289		
290		advadsCfpQueue = [];
291		
292		/**
293		 * Click fraud protection module.
294		 */
295		if ( 'undefined' == typeof window.advadsCfpPath ) return;
296		
297		// get the path/domain parameter to use in cookies
298		if ( '' != advadsCfpPath ) {
299			PATH = advadsCfpPath;
300		}
301		
302		if ( '' != advadsCfpDomain ) {
303			DOMAIN = advadsCfpDomain;
304		}
305		
306		
307	} );
308	
309})(window.jQuery);

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.