PageSourceSearch

https://www.famepark.com.au/wp-content/plugins/wp-simple-firewall/…/notbot.js?ver=17.0.19&mtime=1722999829

js famepark.com.au collected 2026-10-07 03:25:06 UTC 5,324 bytes, 175 lines download raw bytes

1/**
2 * @var shield_vars_notbotjs object
3 */
4if ( typeof Shield_Antibot === typeof undefined && typeof shield_vars_notbotjs !== typeof undefined ) {
5
6	let shield_ajaxurl = shield_vars_notbotjs.vars.ajaxurl;
7	delete shield_vars_notbotjs.vars.ajaxurl;
8
9	let Shield_Antibot = new function () {
10
11		let request_count = 0;
12		let can_send_request = true;
13		let nonce_cook = '';
14		let use_fetch = typeof fetch !== typeof undefined;
15
16		this.initialise = function () {
17			/**
18			 * @since 11.2 we no longer wait until DOM is ready.
19			 * @since 12.0.10 we return to using cookies to optimise whether the AJAX request is sent.
20			 * This is AJAX, so it's asynchronous and won't hold up any other part of the page load.
21			 * Early execution also helps mitigate the case where login requests are
22			 * sent quickly, before browser has fired NotBot request.
23			 */
24			if ( shield_vars_notbotjs.flags.run ) {
25				readNotBotNonceFromCookie();
26				fire();
27			}
28		};
29
30		/**
31		 * @since 12.0.10 - rather than auto send each page load, check for cookie repeatedly and send if absent.
32		 */
33		let fire = function () {
34			if ( request_count < 10 ) {
35				if ( can_send_request ) {
36					let current = getCookie( 'icwp-wpsf-notbot' );
37					if ( typeof current === typeof undefined || current === undefined || current === '' ) {
38						request_count++;
39						use_fetch ? notBotViaGetNonce() : legacyReq();
40					}
41				}
42				window.setTimeout( fire, 60000 );
43			}
44		};
45
46		/** Overcome limitations of page caching by passing latest nonce via cookie **/
47		let readNotBotNonceFromCookie = function () {
48			nonce_cook = getCookie( 'shield-notbot-nonce' );
49			if ( typeof nonce_cook !== typeof undefined && nonce_cook.length > 0 ) {
50				shield_vars_notbotjs.ajax.not_bot.exnonce = nonce_cook;
51			}
52			return nonce_cook;
53		};
54
55		async function notBotViaGetNonce() {
56			readNotBotNonceFromCookie();
57
58			/** If we don't have a nonce i.e. it's been cleared by a failed attempt **/
59			if ( shield_vars_notbotjs.ajax.not_bot.exnonce === '' ) {
60				try {
61					fetch( shield_ajaxurl, constructFetchRequestData( shield_vars_notbotjs.ajax.not_bot_nonce ) )
62					.then( response => {
63						let newNonceCookie = readNotBotNonceFromCookie();
64						if ( newNonceCookie === '' ) {
65							throw new Error( "Can't read new notbot nonce cookie." )
66						}
67						return response;
68					} )
69					.then( response => response.json() )
70					.then( response_data => {
71						if ( response_data ) {
72							can_send_request = response_data && response_data.success;
73							notBotSendReqWithFetch();
74						}
75						else {
76							use_fetch = false;
77						}
78						return response_data;
79					} )
80					.catch( error => {
81						console.log( error );
82						use_fetch = false;
83					} );
84				}
85				catch ( error ) {
86					use_fetch = false;
87					console.log( error );
88				}
89			}
90			else {
91				await notBotSendReqWithFetch();
92			}
93		}
94
95		async function notBotSendReqWithFetch() {
96			readNotBotNonceFromCookie();
97			try {
98				fetch( shield_ajaxurl, constructFetchRequestData( shield_vars_notbotjs.ajax.not_bot ) )
99				.then( response => {
100					if ( response.status === 401 ) {
101						shield_vars_notbotjs.ajax.not_bot.exnonce = '';
102						notBotViaGetNonce();
103						throw new Error( 'notBotSendReqWithFetch() chain cancelled with failed nonce' );
104					}
105					return response;
106				} )
107				.then( response => response.json() )
108				.then( response_data => {
109					if ( response_data ) {
110						can_send_request = response_data && response_data.success;
111					}
112					else {
113						use_fetch = false;
114					}
115					return response_data;
116				} )
117				.catch( error => {
118					console.log( 'notBotSendReqWithFetch() error:' );
119					console.log( error );
120					use_fetch = false;
121				} );
122			}
123			catch ( error ) {
124				use_fetch = false;
125				console.log( error );
126			}
127		}
128
129		let getCookie = function ( name ) {
130			let parts = ("; " + document.cookie).split( "; " + name + "=" );
131			return parts.length === 2 ? parts.pop().split( ";" ).shift() : '';
132		};
133
134		let constructFetchRequestData = function ( core ) {
135			return {
136				method: 'POST',
137				body: (new URLSearchParams( core )).toString(),
138				headers: {
139					'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
140					'X-Requested-With': 'XMLHttpRequest',
141				},
142			};
143		};
144	}();
145
146	let legacyReq = function () {
147		let xhr = new XMLHttpRequest();
148		xhr.open( "POST", shield_ajaxurl, true );
149		xhr.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8' );
150		xhr.setRequestHeader( 'X-Requested-With', 'XMLHttpRequest' );
151
152		/**
153		 * Ensures that if there's an error with the AJAX, we don't keep retrying the requests.
154		 */
155		xhr.onreadystatechange = function () {
156			if ( xhr.readyState === 4 ) {
157				let rawResp = xhr.response;
158				if ( rawResp != null && rawResp !== '' && rawResp.charAt( 0 ) === '{' ) {
159					let resp = JSON.parse( rawResp )
160					can_send_request = resp && resp.success;
161					if ( !can_send_request ) {
162						console.log( xhr.response );
163					}
164				}
165			}
166			else {
167				can_send_request = false;
168			}
169		}
170
171		xhr.send( (new URLSearchParams( shield_vars_notbotjs.ajax.not_bot )).toString() );
172	};
173
174	Shield_Antibot.initialise();
175}

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.