PageSourceSearch

https://dominionstrategy.com/_static/??/wp-includes/js/comment-rep…/_inc/akismet-frontend.js?m=1785939596j

js dominionstrategy.com collected 2026-09-24 09:36:07 UTC 15,528 bytes, 407 lines download raw bytes

1/*! This file is auto-generated */
2window.addComment=function(v){var I,C,h,E=v.document,b={commentReplyClass:"comment-reply-link",commentReplyTitleId:"reply-title",cancelReplyId:"cancel-comment-reply-link",commentFormId:"commentform",temporaryFormId:"wp-temp-form-div",parentIdFieldId:"comment_parent",postIdFieldId:"comment_post_ID"},e=v.MutationObserver||v.WebKitMutationObserver||v.MozMutationObserver,i="querySelector"in E&&"addEventListener"in v,n=!!E.documentElement.dataset;function t(){o(),e&&new e(d).observe(E.body,{childList:!0,subtree:!0})}function o(e){if(i&&(I=g(b.cancelReplyId),C=g(b.commentFormId),I)){I.addEventListener("click",l);function t(e){if((e.metaKey||e.ctrlKey)&&13===e.keyCode&&"a"!==E.activeElement.tagName.toLowerCase())return C.removeEventListener("keydown",t),e.preventDefault(),C.submit.click(),!1}C&&C.addEventListener("keydown",t);for(var n=function(e){var t=b.commentReplyClass;e&&e.childNodes||(e=E);e=E.getElementsByClassName?e.getElementsByClassName(t):e.querySelectorAll("."+t);return e}(e),o=0,d=n.length;o<d;o++)n[o].addEventListener("click",r)}}function l(e){var t,n,o=g(b.temporaryFormId);o&&h&&(g(b.parentIdFieldId).value="0",t=o.textContent,o.parentNode.replaceChild(h,o),this.style.display="none",n=(o=(o=g(b.commentReplyTitleId))&&o.firstChild)&&o.nextSibling,o&&o.nodeType===Node.TEXT_NODE&&t&&(n&&"A"===n.nodeName&&n.id!==b.cancelReplyId&&(n.style.display=""),o.textContent=t),e.preventDefault())}function r(e){var t=g(b.commentReplyTitleId),t=t&&t.firstChild.textContent,n=this,o=a(n,"belowelement"),d=a(n,"commentid"),i=a(n,"respondelement"),l=a(n,"postid"),n=a(n,"replyto")||t;o&&d&&i&&l&&!1===v.addComment.moveForm(o,d,i,l,n)&&e.preventDefault()}function d(e){for(var t=e.length;t--;)if(e[t].addedNodes.length)return void o()}function a(e,t){return n?e.dataset[t]:e.getAttribute("data-"+t)}function g(e){return E.getElementById(e)}return i&&"loading"!==E.readyState?t():i&&v.addEventListener("DOMContentLoaded",t,!1),{init:o,moveForm:function(e,t,n,o,d){var i,l,r,a,m,c,s,e=g(e),n=(h=g(n),g(b.parentIdFieldId)),y=g(b.postIdFieldId),p=g(b.commentReplyTitleId),u=(p=p&&p.firstChild)&&p.nextSibling;if(e&&h&&n){void 0===d&&(d=p&&p.textContent),a=h,m=b.temporaryFormId,c=g(m),s=(s=g(b.commentReplyTitleId))?s.firstChild.textContent:"",c||((c=E.createElement("div")).id=m,c.style.display="none",c.textContent=s,a.parentNode.insertBefore(c,a)),o&&y&&(y.value=o),n.value=t,I.style.display="",e.parentNode.insertBefore(h,e.nextSibling),p&&p.nodeType===Node.TEXT_NODE&&(u&&"A"===u.nodeName&&u.id!==b.cancelReplyId&&(u.style.display="none"),p.textContent=d),I.onclick=function(){return!1};try{for(var f=0;f<C.elements.length;f++)if(i=C.elements[f],l=!1,"getComputedStyle"in v?r=v.getComputedStyle(i):E.documentElement.currentStyle&&(r=i.currentStyle),(i.offsetWidth<=0&&i.offsetHeight<=0||"hidden"===r.visibility)&&(l=!0),"hidden"!==i.type&&!i.disabled&&!l){i.focus();break}}catch(e){}return!1}}}}(window);;
3/**
4 * Observe how the user enters content into the comment form in order to determine whether it's a bot or not.
5 *
6 * Note that no actual input is being saved here, only counts and timings between events.
7 */
8
9( function() {
10	// Passive event listeners are guaranteed to never call e.preventDefault(),
11	// but they're not supported in all browsers.  Use this feature detection
12	// to determine whether they're available for use.
13	var supportsPassive = false;
14
15	try {
16		var opts = Object.defineProperty( {}, 'passive', {
17			get : function() {
18				supportsPassive = true;
19			}
20		} );
21
22		window.addEventListener( 'testPassive', null, opts );
23		window.removeEventListener( 'testPassive', null, opts );
24	} catch ( e ) {}
25
26	function init() {
27		var input_begin = '';
28
29		var keydowns = {};
30		var lastKeyup = null;
31		var lastKeydown = null;
32		var keypresses = [];
33
34		var modifierKeys = [];
35		var correctionKeys = [];
36
37		var lastMouseup = null;
38		var lastMousedown = null;
39		var mouseclicks = [];
40		var mouseclickCoordinates = [];
41
42		var mousemoveTimer = null;
43		var lastMousemoveX = null;
44		var lastMousemoveY = null;
45		var lastMousemoveTime = null;
46		var mousemoveStart = null;
47		var mousemoves = [];
48		var intervalsBetweenMousemovesAndClicks = [];
49
50		var touchmoveCountTimer = null;
51		var touchmoveCount = 0;
52
53		var lastTouchEnd = null;
54		var lastTouchStart = null;
55		var touchEvents = [];
56
57		var scrollCountTimer = null;
58		var scrollCount = 0;
59
60		var correctionKeyCodes = [ 'Backspace', 'Delete', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'Home', 'End', 'PageUp', 'PageDown' ];
61		var modifierKeyCodes = [ 'Shift', 'CapsLock' ];
62
63		var forms = document.querySelectorAll( 'form[method=post]' );
64
65		for ( var i = 0; i < forms.length; i++ ) {
66			var form = forms[i];
67
68			var formAction = form.getAttribute( 'action' );
69
70			// Ignore forms that POST directly to other domains; these could be things like payment forms.
71			if ( formAction ) {
72				// Check that the form is posting to an external URL, not a path.
73				if ( formAction.indexOf( 'http://' ) == 0 || formAction.indexOf( 'https://' ) == 0 ) {
74					if ( formAction.indexOf( 'http://' + window.location.hostname + '/' ) != 0 && formAction.indexOf( 'https://' + window.location.hostname + '/' ) != 0 ) {
75						continue;
76					}
77				}
78			}
79
80			form.addEventListener( 'submit', function () {
81				var ak_bkp = prepare_array_for_request( keypresses );
82				var ak_bmc = prepare_array_for_request( mouseclicks );
83				var ak_bte = prepare_array_for_request( touchEvents );
84				var ak_bmm = prepare_array_for_request( mousemoves );
85				var ak_bcc = prepare_array_for_request( mouseclickCoordinates );
86				var ak_bibmac = intervalsBetweenMousemovesAndClicks.slice( 0, 100 ).join( ';' );
87
88				var input_fields = {
89					// When did the user begin entering any input?
90					'bib': input_begin,
91
92					// When was the form submitted?
93					'bfs': Date.now(),
94
95					// How many keypresses did they make?
96					'bkpc': keypresses.length,
97
98					// How quickly did they press a sample of keys, and how long between them?
99					'bkp': ak_bkp,
100
101					// How quickly did they click the mouse, and how long between clicks?
102					'bmc': ak_bmc,
103
104					// How many mouseclicks did they make?
105					'bmcc': mouseclicks.length,
106
107					// When did they press modifier keys (like Shift or Capslock)?
108					'bmk': modifierKeys.join( ';' ),
109
110					// When did they correct themselves? e.g., press Backspace, or use the arrow keys to move the cursor back
111					'bck': correctionKeys.join( ';' ),
112
113					// How many times did they move the mouse?
114					'bmmc': mousemoves.length,
115
116					// How many times did they move around using a touchscreen?
117					'btmc': touchmoveCount,
118
119					// How many times did they scroll?
120					'bsc': scrollCount,
121
122					// How quickly did they perform touch events, and how long between them?
123					'bte': ak_bte,
124
125					// How many touch events were there?
126					'btec' : touchEvents.length,
127
128					// How quickly did they move the mouse, and how long between moves?
129					'bmm' : ak_bmm,
130
131					// Click coordinates
132					'bcc' : ak_bcc,
133
134					// Milliseconds between last mouse movement and each click
135					'bibmac' : ak_bibmac
136				};
137
138				var akismet_field_prefix = 'ak_';
139
140				if ( this.getElementsByClassName ) {
141					// 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.
142					var possible_akismet_containers = this.getElementsByClassName( 'akismet-fields-container' );
143
144					for ( var containerIndex = 0; containerIndex < possible_akismet_containers.length; containerIndex++ ) {
145						var container = possible_akismet_containers.item( containerIndex );
146
147						if ( container.getAttribute( 'data-prefix' ) ) {
148							akismet_field_prefix = container.getAttribute( 'data-prefix' );
149							break;
150						}
151					}
152				}
153
154				for ( var field_name in input_fields ) {
155					var field = document.createElement( 'input' );
156					field.setAttribute( 'type', 'hidden' );
157					field.setAttribute( 'name', akismet_field_prefix + field_name );
158					field.setAttribute( 'value', input_fields[ field_name ] );
159					this.appendChild( field );
160				}
161			}, supportsPassive ? { passive: true } : false  );
162
163			form.addEventListener( 'keydown', function ( e ) {
164				// If you hold a key down, some browsers send multiple keydown events in a row.
165				// Ignore any keydown events for a key that hasn't come back up yet.
166				if ( e.key in keydowns ) {
167					return;
168				}
169
170				var keydownTime = ( new Date() ).getTime();
171				keydowns[ e.key ] = [ keydownTime ];
172
173				if ( ! input_begin ) {
174					input_begin = keydownTime;
175				}
176
177				// In some situations, we don't want to record an interval since the last keypress -- for example,
178				// on the first keypress, or on a keypress after focus has changed to another element. Normally,
179				// we want to record the time between the last keyup and this keydown. But if they press a
180				// key while already pressing a key, we want to record the time between the two keydowns.
181
182				var lastKeyEvent = Math.max( lastKeydown, lastKeyup );
183
184				if ( lastKeyEvent ) {
185					keydowns[ e.key ].push( keydownTime - lastKeyEvent );
186				}
187
188				lastKeydown = keydownTime;
189			}, supportsPassive ? { passive: true } : false  );
190
191			form.addEventListener( 'keyup', function ( e ) {
192				if ( ! ( e.key in keydowns ) ) {
193					// This key was pressed before this script was loaded, or a mouseclick happened during the keypress, or...
194					return;
195				}
196
197				var keyupTime = ( new Date() ).getTime();
198
199				if ( 'TEXTAREA' === e.target.nodeName || 'INPUT' === e.target.nodeName ) {
200					if ( -1 !== modifierKeyCodes.indexOf( e.key ) ) {
201						modifierKeys.push( keypresses.length - 1 );
202					} else if ( -1 !== correctionKeyCodes.indexOf( e.key ) ) {
203						correctionKeys.push( keypresses.length - 1 );
204					} else {
205						// ^ Don't record timings for keys like Shift or backspace, since they
206						// typically get held down for longer than regular typing.
207
208						var keydownTime = keydowns[ e.key ][0];
209
210						var keypress = [];
211
212						// Keypress duration.
213						keypress.push( keyupTime - keydownTime );
214
215						// Amount of time between this keypress and the previous keypress.
216						if ( keydowns[ e.key ].length > 1 ) {
217							keypress.push( keydowns[ e.key ][1] );
218						}
219
220						keypresses.push( keypress );
221					}
222				}
223
224				delete keydowns[ e.key ];
225
226				lastKeyup = keyupTime;
227			}, supportsPassive ? { passive: true } : false  );
228
229			form.addEventListener( "focusin", function ( e ) {
230				lastKeydown = null;
231				lastKeyup = null;
232				keydowns = {};
233			}, supportsPassive ? { passive: true } : false  );
234
235			form.addEventListener( "focusout", function ( e ) {
236				lastKeydown = null;
237				lastKeyup = null;
238				keydowns = {};
239			}, supportsPassive ? { passive: true } : false  );
240		}
241
242		document.addEventListener( 'mousedown', function ( e ) {
243			lastMousedown = ( new Date() ).getTime();
244
245			if ( lastMousemoveTime ) {
246				intervalsBetweenMousemovesAndClicks.push( lastMousedown - lastMousemoveTime );
247			}
248
249			var mouseclickCoordinate = [];
250
251			var rect = e.target.getBoundingClientRect();
252			var relativeX = e.clientX - rect.left;
253			var relativeY = e.clientY - rect.top;
254
255			// Pixel offset of the click within the target element.
256			mouseclickCoordinate.push( Math.round( relativeX ) );
257			mouseclickCoordinate.push( Math.round( relativeY ) );
258
259			// Percentage offset of the click within the target element.
260			mouseclickCoordinate.push( rect.width > 0 ? Math.round( relativeX / rect.width * 100 ) : 0 );
261			mouseclickCoordinate.push( rect.height > 0 ? Math.round( relativeY / rect.height * 100 ) : 0 );
262
263			mouseclickCoordinates.push( mouseclickCoordinate );
264		}, supportsPassive ? { passive: true } : false  );
265
266		document.addEventListener( 'mouseup', function ( e ) {
267			if ( ! lastMousedown ) {
268				// If the mousedown happened before this script was loaded, but the mouseup happened after...
269				return;
270			}
271
272			var now = ( new Date() ).getTime();
273
274			var mouseclick = [];
275			mouseclick.push( now - lastMousedown );
276
277			if ( lastMouseup ) {
278				mouseclick.push( lastMousedown - lastMouseup );
279			}
280
281			mouseclicks.push( mouseclick );
282
283			lastMouseup = now;
284
285			// If the mouse has been clicked, don't record this time as an interval between keypresses.
286			lastKeydown = null;
287			lastKeyup = null;
288			keydowns = {};
289		}, supportsPassive ? { passive: true } : false  );
290
291		document.addEventListener( 'mousemove', function ( e ) {
292			lastMousemoveTime = ( new Date() ).getTime();
293
294			if ( mousemoveTimer ) {
295				clearTimeout( mousemoveTimer );
296				mousemoveTimer = null;
297			}
298			else {
299				mousemoveStart = lastMousemoveTime;
300				lastMousemoveX = e.offsetX;
301				lastMousemoveY = e.offsetY;
302			}
303
304			mousemoveTimer = setTimeout( function ( theEvent, originalMousemoveStart ) {
305				var now = ( new Date() ).getTime() - 500; // To account for the timer delay.
306
307				var mousemove = [];
308				mousemove.push( now - originalMousemoveStart );
309				mousemove.push(
310					Math.round(
311						Math.sqrt(
312							Math.pow( theEvent.offsetX - lastMousemoveX, 2 ) +
313							Math.pow( theEvent.offsetY - lastMousemoveY, 2 )
314						)
315					)
316				);
317
318				if ( mousemove[1] > 0 ) {
319					// If there was no measurable distance, then it wasn't really a move.
320					mousemoves.push( mousemove );
321				}
322
323				mousemoveStart = null;
324				mousemoveTimer = null;
325			}, 500, e, mousemoveStart );
326		}, supportsPassive ? { passive: true } : false  );
327
328		document.addEventListener( 'touchmove', function ( e ) {
329			if ( touchmoveCountTimer ) {
330				clearTimeout( touchmoveCountTimer );
331			}
332
333			touchmoveCountTimer = setTimeout( function () {
334				touchmoveCount++;
335			}, 500 );
336		}, supportsPassive ? { passive: true } : false );
337
338		document.addEventListener( 'touchstart', function ( e ) {
339			lastTouchStart = ( new Date() ).getTime();
340		}, supportsPassive ? { passive: true } : false );
341
342		document.addEventListener( 'touchend', function ( e ) {
343			if ( ! lastTouchStart ) {
344				// If the touchstart happened before this script was loaded, but the touchend happened after...
345				return;
346			}
347
348			var now = ( new Date() ).getTime();
349
350			var touchEvent = [];
351			touchEvent.push( now - lastTouchStart );
352
353			if ( lastTouchEnd ) {
354				touchEvent.push( lastTouchStart - lastTouchEnd );
355			}
356
357			touchEvents.push( touchEvent );
358
359			lastTouchEnd = now;
360
361			// Don't record this time as an interval between keypresses.
362			lastKeydown = null;
363			lastKeyup = null;
364			keydowns = {};
365		}, supportsPassive ? { passive: true } : false );
366
367		document.addEventListener( 'scroll', function ( e ) {
368			if ( scrollCountTimer ) {
369				clearTimeout( scrollCountTimer );
370			}
371
372			scrollCountTimer = setTimeout( function () {
373				scrollCount++;
374			}, 500 );
375		}, supportsPassive ? { passive: true } : false );
376	}
377
378	/**
379	 * For the timing/coordinate data that is collected, don't send more than `limit` data points in the request.
380	 * Choose a random slice and send those, with each batch separated by semicolons and the items in each batch
381	 * separated by commas.
382	 */
383	function prepare_array_for_request( a, limit ) {
384		if ( ! limit ) {
385			limit = 100;
386		}
387
388		var rv = '';
389
390		if ( a.length > 0 ) {
391			var random_starting_point = Math.max( 0, Math.floor( Math.random() * a.length - limit ) );
392
393			for ( var i = 0; i < limit && i < a.length; i++ ) {
394				var entry = a[ random_starting_point + i ];
395				rv += entry.join( ',' ) + ';';
396			}
397		}
398
399		return rv;
400	}
401
402	if ( document.readyState !== 'loading' ) {
403		init();
404	} else {
405		document.addEventListener( 'DOMContentLoaded', init );
406	}
407})();;

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.