PageSourceSearch

https://lifelinesblog.com/_static/??-eJxdy00KgCAQQOELZdMfWIvoKKGmM…MWKwevI2rKCGUnlYM53Xh47+bHmfBj6vms6dwMySTA8

js lifelinesblog.com collected 2026-10-06 21:21:43 UTC 17,367 bytes, 517 lines download raw bytes

1// NOTICE! This file exists in WPCOM & WPCOMSH. Updates need to be synced to both repos.
2
3(function () {
4  document.addEventListener("DOMContentLoaded", function () {
5    const hostnames = ['wordpress.com', 'w.link', 'automattic.com'];
6    // Make sure we never show the banner on these hostnames.
7    if (hostnames.includes(window.location.hostname)) {
8      return;
9    }
10
11    var bumpStat = function (statName) {
12      new Image().src =
13        document.location.protocol +
14        "//pixel.wp.com/b.gif" +
15        "?v=wpcom-no-pv" +
16        "&x_simple_gifting_banner=" +
17        statName +
18        "&rand=" +
19        Math.random();
20    };
21
22    if (!document.cookie.includes("wpcom_gifting_banner_gifter=true")) {
23      giftingBanner();
24      bumpStat("viewed_total");
25
26      document.getElementById("wpcom-gifting-banner-button").onclick =
27        function () {
28          bumpStat("clicked");
29          window.location.href = gifting_banner.checkout_link;
30        };
31      document.getElementById("wpcom-gifting-banner-more-info-button").onclick =
32        function () {
33          bumpStat("moreinfo");
34          window.open(gifting_banner.more_info_link, "_blank");
35        };
36    }
37  });
38
39  function giftingBanner() {
40    // Check for hash in URL to see if we should dismiss the banner
41    var hash = location.hash;
42    if ("#gift-thank-you" === hash) {
43      var expiration = new Date();
44      expiration.setTime(
45        expiration.getTime() +
46          1000 * 60 * 60 * 24 * gifting_banner.dismiss_days_count
47      );
48      var expires = "expires=" + expiration.toUTCString();
49      document.cookie =
50        "wpcom_gifting_banner_gifter=true;" + expires + ";path=/";
51      location.hash = "";
52      return;
53    }
54    var notice = document.createElement("div");
55    notice.setAttribute("id", "wpcom-gifting-banner");
56    notice.classList.add("wpcom-gifting-banner");
57    document.documentElement.classList.add("has-wpcom-gifting-banner");
58    notice.innerHTML =
59      '<div class="wpcom-gifting-banner__inner">' +
60      '<svg class="wpcom-gifting-banner__logo" xmlns="http://www.w3.org/2000/svg">\
61				<path d="M12.158,12.786L9.46,20.625c0.806,0.237,1.657,0.366,2.54,0.366c1.047,0,2.051-0.181,2.986-0.51 \
62					c-0.024-0.038-0.046-0.079-0.065-0.124L12.158,12.786z M3.009,12c0,3.559,2.068,6.634,5.067,8.092L3.788,8.341\
63					C3.289,9.459,3.009,10.696,3.009,12z M18.069,11.546c0-1.112-0.399-1.881-0.741-2.48c-0.456-0.741-0.883-1.368-0.883-2.109\
64					c0-0.826,0.627-1.596,1.51-1.596c0.04,0,0.078,0.005,0.116,0.007C16.472,3.904,14.34,3.009,12,3.009\
65					c-3.141,0-5.904,1.612-7.512,4.052c0.211,0.007,0.41,0.011,0.579,0.011c0.94,0,2.396-0.114,2.396-0.114\
66					C7.947,6.93,8.004,7.642,7.52,7.699c0,0-0.487,0.057-1.029,0.085l3.274,9.739l1.968-5.901l-1.401-3.838\
67					C9.848,7.756,9.389,7.699,9.389,7.699C8.904,7.67,8.961,6.93,9.446,6.958c0,0,1.484,0.114,2.368,0.114\
68					c0.94,0,2.397-0.114,2.397-0.114c0.485-0.028,0.542,0.684,0.057,0.741c0,0-0.488,0.057-1.029,0.085l3.249,9.665l0.897-2.996\
69					C17.841,13.284,18.069,12.316,18.069,11.546z M19.889,7.686c0.039,0.286,0.06,0.593,0.06,0.924c0,0.912-0.171,1.938-0.684,3.22\
70					l-2.746,7.94c2.673-1.558,4.47-4.454,4.47-7.771C20.991,10.436,20.591,8.967,19.889,7.686z M12,22C6.486,22,2,17.514,2,12\
71					C2,6.486,6.486,2,12,2c5.514,0,10,4.486,10,10C22,17.514,17.514,22,12,22z" transform="scale(1.2)"/>\
72			</svg>' +
73      '<div class="wpcom-gifting-banner__wrapper">' +
74      '<span class="wpcom-gifting-banner__title"></span>' +
75      '<img class="wpcom-gifting-banner__img" alt="🎁" src="https://s.w.org/images/core/emoji/14.0.0/svg/1f381.svg"/>' +
76      '<span class="wpcom-gifting-banner__subtitle"></span>' +
77      "</div>" +
78      '<button id="wpcom-gifting-banner-button" class="wpcom-gifting-banner__button"></button>' +
79      "</div>";
80
81    const title = document.createTextNode(gifting_banner.i18n.title);
82    const subtitle = document.createTextNode(gifting_banner.i18n.subtitle);
83    const more_info_button = document.createElement("BUTTON");
84    more_info_button.setAttribute(
85      "id",
86      "wpcom-gifting-banner-more-info-button"
87    );
88    more_info_button.setAttribute(
89      "class",
90      "wpcom-gifting-banner__more-info-button"
91    );
92    const button_text = document.createTextNode(
93      gifting_banner.i18n.button_text
94    );
95
96    notice
97      .getElementsByClassName("wpcom-gifting-banner__title")[0]
98      .appendChild(title);
99    notice
100      .getElementsByClassName("wpcom-gifting-banner__subtitle")[0]
101      .appendChild(subtitle);
102    notice
103      .getElementsByClassName("wpcom-gifting-banner__subtitle")[0]
104      .appendChild(more_info_button);
105    notice
106      .getElementsByClassName("wpcom-gifting-banner__button")[0]
107      .appendChild(button_text);
108
109    document.body.prepend(notice);
110  }
111})();
112;
113/**
114 * Observe how the user enters content into the comment form in order to determine whether it's a bot or not.
115 *
116 * Note that no actual input is being saved here, only counts and timings between events.
117 */
118
119( function() {
120	// Passive event listeners are guaranteed to never call e.preventDefault(),
121	// but they're not supported in all browsers.  Use this feature detection
122	// to determine whether they're available for use.
123	var supportsPassive = false;
124
125	try {
126		var opts = Object.defineProperty( {}, 'passive', {
127			get : function() {
128				supportsPassive = true;
129			}
130		} );
131
132		window.addEventListener( 'testPassive', null, opts );
133		window.removeEventListener( 'testPassive', null, opts );
134	} catch ( e ) {}
135
136	function init() {
137		var input_begin = '';
138
139		var keydowns = {};
140		var lastKeyup = null;
141		var lastKeydown = null;
142		var keypresses = [];
143
144		var modifierKeys = [];
145		var correctionKeys = [];
146
147		var lastMouseup = null;
148		var lastMousedown = null;
149		var mouseclicks = [];
150		var mouseclickCoordinates = [];
151
152		var mousemoveTimer = null;
153		var lastMousemoveX = null;
154		var lastMousemoveY = null;
155		var lastMousemoveTime = null;
156		var mousemoveStart = null;
157		var mousemoves = [];
158		var intervalsBetweenMousemovesAndClicks = [];
159
160		var touchmoveCountTimer = null;
161		var touchmoveCount = 0;
162
163		var lastTouchEnd = null;
164		var lastTouchStart = null;
165		var touchEvents = [];
166
167		var scrollCountTimer = null;
168		var scrollCount = 0;
169
170		var correctionKeyCodes = [ 'Backspace', 'Delete', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'Home', 'End', 'PageUp', 'PageDown' ];
171		var modifierKeyCodes = [ 'Shift', 'CapsLock' ];
172
173		var forms = document.querySelectorAll( 'form[method=post]' );
174
175		for ( var i = 0; i < forms.length; i++ ) {
176			var form = forms[i];
177
178			var formAction = form.getAttribute( 'action' );
179
180			// Ignore forms that POST directly to other domains; these could be things like payment forms.
181			if ( formAction ) {
182				// Check that the form is posting to an external URL, not a path.
183				if ( formAction.indexOf( 'http://' ) == 0 || formAction.indexOf( 'https://' ) == 0 ) {
184					if ( formAction.indexOf( 'http://' + window.location.hostname + '/' ) != 0 && formAction.indexOf( 'https://' + window.location.hostname + '/' ) != 0 ) {
185						continue;
186					}
187				}
188			}
189
190			form.addEventListener( 'submit', function () {
191				var ak_bkp = prepare_array_for_request( keypresses );
192				var ak_bmc = prepare_array_for_request( mouseclicks );
193				var ak_bte = prepare_array_for_request( touchEvents );
194				var ak_bmm = prepare_array_for_request( mousemoves );
195				var ak_bcc = prepare_array_for_request( mouseclickCoordinates );
196				var ak_bibmac = intervalsBetweenMousemovesAndClicks.slice( 0, 100 ).join( ';' );
197
198				var input_fields = {
199					// When did the user begin entering any input?
200					'bib': input_begin,
201
202					// When was the form submitted?
203					'bfs': Date.now(),
204
205					// How many keypresses did they make?
206					'bkpc': keypresses.length,
207
208					// How quickly did they press a sample of keys, and how long between them?
209					'bkp': ak_bkp,
210
211					// How quickly did they click the mouse, and how long between clicks?
212					'bmc': ak_bmc,
213
214					// How many mouseclicks did they make?
215					'bmcc': mouseclicks.length,
216
217					// When did they press modifier keys (like Shift or Capslock)?
218					'bmk': modifierKeys.join( ';' ),
219
220					// When did they correct themselves? e.g., press Backspace, or use the arrow keys to move the cursor back
221					'bck': correctionKeys.join( ';' ),
222
223					// How many times did they move the mouse?
224					'bmmc': mousemoves.length,
225
226					// How many times did they move around using a touchscreen?
227					'btmc': touchmoveCount,
228
229					// How many times did they scroll?
230					'bsc': scrollCount,
231
232					// How quickly did they perform touch events, and how long between them?
233					'bte': ak_bte,
234
235					// How many touch events were there?
236					'btec' : touchEvents.length,
237
238					// How quickly did they move the mouse, and how long between moves?
239					'bmm' : ak_bmm,
240
241					// Click coordinates
242					'bcc' : ak_bcc,
243
244					// Milliseconds between last mouse movement and each click
245					'bibmac' : ak_bibmac
246				};
247
248				var akismet_field_prefix = 'ak_';
249
250				if ( this.getElementsByClassName ) {
251					// Check to see if we've used an alternate field name prefix. We store this as an attribute of the container around some of the Akismet fields.
252					var possible_akismet_containers = this.getElementsByClassName( 'akismet-fields-container' );
253
254					for ( var containerIndex = 0; containerIndex < possible_akismet_containers.length; containerIndex++ ) {
255						var container = possible_akismet_containers.item( containerIndex );
256
257						if ( container.getAttribute( 'data-prefix' ) ) {
258							akismet_field_prefix = container.getAttribute( 'data-prefix' );
259							break;
260						}
261					}
262				}
263
264				for ( var field_name in input_fields ) {
265					var field = document.createElement( 'input' );
266					field.setAttribute( 'type', 'hidden' );
267					field.setAttribute( 'name', akismet_field_prefix + field_name );
268					field.setAttribute( 'value', input_fields[ field_name ] );
269					this.appendChild( field );
270				}
271			}, supportsPassive ? { passive: true } : false  );
272
273			form.addEventListener( 'keydown', function ( e ) {
274				// If you hold a key down, some browsers send multiple keydown events in a row.
275				// Ignore any keydown events for a key that hasn't come back up yet.
276				if ( e.key in keydowns ) {
277					return;
278				}
279
280				var keydownTime = ( new Date() ).getTime();
281				keydowns[ e.key ] = [ keydownTime ];
282
283				if ( ! input_begin ) {
284					input_begin = keydownTime;
285				}
286
287				// In some situations, we don't want to record an interval since the last keypress -- for example,
288				// on the first keypress, or on a keypress after focus has changed to another element. Normally,
289				// we want to record the time between the last keyup and this keydown. But if they press a
290				// key while already pressing a key, we want to record the time between the two keydowns.
291
292				var lastKeyEvent = Math.max( lastKeydown, lastKeyup );
293
294				if ( lastKeyEvent ) {
295					keydowns[ e.key ].push( keydownTime - lastKeyEvent );
296				}
297
298				lastKeydown = keydownTime;
299			}, supportsPassive ? { passive: true } : false  );
300
301			form.addEventListener( 'keyup', function ( e ) {
302				if ( ! ( e.key in keydowns ) ) {
303					// This key was pressed before this script was loaded, or a mouseclick happened during the keypress, or...
304					return;
305				}
306
307				var keyupTime = ( new Date() ).getTime();
308
309				if ( 'TEXTAREA' === e.target.nodeName || 'INPUT' === e.target.nodeName ) {
310					if ( -1 !== modifierKeyCodes.indexOf( e.key ) ) {
311						modifierKeys.push( keypresses.length - 1 );
312					} else if ( -1 !== correctionKeyCodes.indexOf( e.key ) ) {
313						correctionKeys.push( keypresses.length - 1 );
314					} else {
315						// ^ Don't record timings for keys like Shift or backspace, since they
316						// typically get held down for longer than regular typing.
317
318						var keydownTime = keydowns[ e.key ][0];
319
320						var keypress = [];
321
322						// Keypress duration.
323						keypress.push( keyupTime - keydownTime );
324
325						// Amount of time between this keypress and the previous keypress.
326						if ( keydowns[ e.key ].length > 1 ) {
327							keypress.push( keydowns[ e.key ][1] );
328						}
329
330						keypresses.push( keypress );
331					}
332				}
333
334				delete keydowns[ e.key ];
335
336				lastKeyup = keyupTime;
337			}, supportsPassive ? { passive: true } : false  );
338
339			form.addEventListener( "focusin", function ( e ) {
340				lastKeydown = null;
341				lastKeyup = null;
342				keydowns = {};
343			}, supportsPassive ? { passive: true } : false  );
344
345			form.addEventListener( "focusout", function ( e ) {
346				lastKeydown = null;
347				lastKeyup = null;
348				keydowns = {};
349			}, supportsPassive ? { passive: true } : false  );
350		}
351
352		document.addEventListener( 'mousedown', function ( e ) {
353			lastMousedown = ( new Date() ).getTime();
354
355			if ( lastMousemoveTime ) {
356				intervalsBetweenMousemovesAndClicks.push( lastMousedown - lastMousemoveTime );
357			}
358
359			var mouseclickCoordinate = [];
360
361			var rect = e.target.getBoundingClientRect();
362			var relativeX = e.clientX - rect.left;
363			var relativeY = e.clientY - rect.top;
364
365			// Pixel offset of the click within the target element.
366			mouseclickCoordinate.push( Math.round( relativeX ) );
367			mouseclickCoordinate.push( Math.round( relativeY ) );
368
369			// Percentage offset of the click within the target element.
370			mouseclickCoordinate.push( rect.width > 0 ? Math.round( relativeX / rect.width * 100 ) : 0 );
371			mouseclickCoordinate.push( rect.height > 0 ? Math.round( relativeY / rect.height * 100 ) : 0 );
372
373			mouseclickCoordinates.push( mouseclickCoordinate );
374		}, supportsPassive ? { passive: true } : false  );
375
376		document.addEventListener( 'mouseup', function ( e ) {
377			if ( ! lastMousedown ) {
378				// If the mousedown happened before this script was loaded, but the mouseup happened after...
379				return;
380			}
381
382			var now = ( new Date() ).getTime();
383
384			var mouseclick = [];
385			mouseclick.push( now - lastMousedown );
386
387			if ( lastMouseup ) {
388				mouseclick.push( lastMousedown - lastMouseup );
389			}
390
391			mouseclicks.push( mouseclick );
392
393			lastMouseup = now;
394
395			// If the mouse has been clicked, don't record this time as an interval between keypresses.
396			lastKeydown = null;
397			lastKeyup = null;
398			keydowns = {};
399		}, supportsPassive ? { passive: true } : false  );
400
401		document.addEventListener( 'mousemove', function ( e ) {
402			lastMousemoveTime = ( new Date() ).getTime();
403
404			if ( mousemoveTimer ) {
405				clearTimeout( mousemoveTimer );
406				mousemoveTimer = null;
407			}
408			else {
409				mousemoveStart = lastMousemoveTime;
410				lastMousemoveX = e.offsetX;
411				lastMousemoveY = e.offsetY;
412			}
413
414			mousemoveTimer = setTimeout( function ( theEvent, originalMousemoveStart ) {
415				var now = ( new Date() ).getTime() - 500; // To account for the timer delay.
416
417				var mousemove = [];
418				mousemove.push( now - originalMousemoveStart );
419				mousemove.push(
420					Math.round(
421						Math.sqrt(
422							Math.pow( theEvent.offsetX - lastMousemoveX, 2 ) +
423							Math.pow( theEvent.offsetY - lastMousemoveY, 2 )
424						)
425					)
426				);
427
428				if ( mousemove[1] > 0 ) {
429					// If there was no measurable distance, then it wasn't really a move.
430					mousemoves.push( mousemove );
431				}
432
433				mousemoveStart = null;
434				mousemoveTimer = null;
435			}, 500, e, mousemoveStart );
436		}, supportsPassive ? { passive: true } : false  );
437
438		document.addEventListener( 'touchmove', function ( e ) {
439			if ( touchmoveCountTimer ) {
440				clearTimeout( touchmoveCountTimer );
441			}
442
443			touchmoveCountTimer = setTimeout( function () {
444				touchmoveCount++;
445			}, 500 );
446		}, supportsPassive ? { passive: true } : false );
447
448		document.addEventListener( 'touchstart', function ( e ) {
449			lastTouchStart = ( new Date() ).getTime();
450		}, supportsPassive ? { passive: true } : false );
451
452		document.addEventListener( 'touchend', function ( e ) {
453			if ( ! lastTouchStart ) {
454				// If the touchstart happened before this script was loaded, but the touchend happened after...
455				return;
456			}
457
458			var now = ( new Date() ).getTime();
459
460			var touchEvent = [];
461			touchEvent.push( now - lastTouchStart );
462
463			if ( lastTouchEnd ) {
464				touchEvent.push( lastTouchStart - lastTouchEnd );
465			}
466
467			touchEvents.push( touchEvent );
468
469			lastTouchEnd = now;
470
471			// Don't record this time as an interval between keypresses.
472			lastKeydown = null;
473			lastKeyup = null;
474			keydowns = {};
475		}, supportsPassive ? { passive: true } : false );
476
477		document.addEventListener( 'scroll', function ( e ) {
478			if ( scrollCountTimer ) {
479				clearTimeout( scrollCountTimer );
480			}
481
482			scrollCountTimer = setTimeout( function () {
483				scrollCount++;
484			}, 500 );
485		}, supportsPassive ? { passive: true } : false );
486	}
487
488	/**
489	 * For the timing/coordinate data that is collected, don't send more than `limit` data points in the request.
490	 * Choose a random slice and send those, with each batch separated by semicolons and the items in each batch
491	 * separated by commas.
492	 */
493	function prepare_array_for_request( a, limit ) {
494		if ( ! limit ) {
495			limit = 100;
496		}
497
498		var rv = '';
499
500		if ( a.length > 0 ) {
501			var random_starting_point = Math.max( 0, Math.floor( Math.random() * a.length - limit ) );
502
503			for ( var i = 0; i < limit && i < a.length; i++ ) {
504				var entry = a[ random_starting_point + i ];
505				rv += entry.join( ',' ) + ';';
506			}
507		}
508
509		return rv;
510	}
511
512	if ( document.readyState !== 'loading' ) {
513		init();
514	} else {
515		document.addEventListener( 'DOMContentLoaded', init );
516	}
517})();;

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.