2025-04-28 20:12:27 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								/ *  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									GoToSocial 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Copyright  ( C )  GoToSocial  Authors  admin @ gotosocial . org 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									SPDX - License - Identifier :  AGPL - 3.0 - or - later 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									This  program  is  free  software :  you  can  redistribute  it  and / or  modify 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									it  under  the  terms  of  the  GNU  Affero  General  Public  License  as  published  by 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									the  Free  Software  Foundation ,  either  version  3  of  the  License ,  or 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									( at  your  option )  any  later  version . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									This  program  is  distributed  in  the  hope  that  it  will  be  useful , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									but  WITHOUT  ANY  WARRANTY ;  without  even  the  implied  warranty  of 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									MERCHANTABILITY  or  FITNESS  FOR  A  PARTICULAR  PURPOSE .   See  the 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									GNU  Affero  General  Public  License  for  more  details . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									You  should  have  received  a  copy  of  the  GNU  Affero  General  Public  License 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									along  with  this  program .   If  not ,  see  < http : //www.gnu.org/licenses/>.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								* /  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 10:49:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								const  explanation  =  "Your browser is currently solving a proof-of-work challenge designed to deter \"ai\" scrapers. This should take no more than a few seconds..." ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-05-03 16:45:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								document . addEventListener ( "DOMContentLoaded" ,  function ( )  {  
						 
					
						
							
								
									
										
										
										
											2025-04-28 20:12:27 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									// Get the nollamas section container.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									const  nollamas  =  document . querySelector ( ".nollamas" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Add some "loading" text to show that
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// a proof-of-work captcha is being done.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									const  p  =  this . createElement ( "p" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									p . className  =  "nollamas-explanation" ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 10:49:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									p . appendChild ( document . createTextNode ( explanation ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-28 20:12:27 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									nollamas . appendChild ( p ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 10:49:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Add a loading spinner, but only
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// animate it if motion is allowed.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									const  spinner  =  document . createElement ( "i" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									spinner . className  =  "fa fa-spinner fa-2x fa-fw nollamas-status" ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-28 20:12:27 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  ( ! window . matchMedia ( '(prefers-reduced-motion: reduce)' ) . matches )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 10:49:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										spinner . className  +=  " fa-pulse" ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-28 20:12:27 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 10:49:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									spinner . setAttribute ( "title" , "Solving..." ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									spinner . setAttribute ( "aria-label" ,  "Solving" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									nollamas . appendChild ( spinner ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-28 20:12:27 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Read the challenge and difficulty from
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// data attributes on the nollamas section.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									const  challenge  =  nollamas . dataset . nollamasChallenge ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-05-03 16:45:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									const  difficulty  =  nollamas . dataset . nollamasDifficulty ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-28 20:12:27 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-05-03 16:45:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									console . log ( "challenge:" ,  challenge ) ;      // eslint-disable-line no-console
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									console . log ( "difficulty:" ,  difficulty ) ;  // eslint-disable-line no-console
 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-28 20:12:27 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Prepare the worker with task function.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									const  worker  =  new  Worker ( "/assets/dist/nollamasworker.js" ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 10:49:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									const  startTime  =  performance . now ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-28 20:12:27 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									worker . postMessage ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										challenge :  challenge , 
							 
						 
					
						
							
								
									
										
										
										
											2025-05-03 16:45:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										difficulty :  difficulty , 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-28 20:12:27 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Set the main worker function.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									worker . onmessage  =  function  ( e )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( e . data . done )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 10:49:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											const  endTime  =  performance . now ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											const  duration  =  endTime  -  startTime ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-05-03 16:45:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 10:49:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											// Remove spinner and replace it with a tick
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// and info about how long it took to solve.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											nollamas . removeChild ( spinner ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											const  solutionWrapper  =  document . createElement ( "div" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											solutionWrapper . className  =  "nollamas-status" ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-05-03 16:45:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 10:49:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											const  tick  =  document . createElement ( "i" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											tick . className  =  "fa fa-check fa-2x fa-fw" ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											tick . setAttribute ( "title" , "Solved!" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											tick . setAttribute ( "aria-label" ,  "Solved!" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											solutionWrapper . appendChild ( tick ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											const  took  =  document . createElement ( "span" ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-05-03 16:45:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											const  solvedText  =  ` Solved after  ${ e . data . nonce }  iterations, in  ${ duration . toString ( ) } ms! ` ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											took . appendChild ( document . createTextNode ( solvedText ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 10:49:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											solutionWrapper . appendChild ( took ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											nollamas . appendChild ( solutionWrapper ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-05-03 16:45:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 10:49:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											// Wait for 500ms before redirecting, to give
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// visitors a shot at reading the message, but
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// not so long that they have to wait unduly.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											setTimeout ( ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												let  url  =  new  URL ( window . location . href ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-05-03 16:45:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												url . searchParams . set ( "nollamas_solution" ,  e . data . nonce ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 10:49:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												window . location . replace ( url . toString ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} ,  500 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-28 20:12:27 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ) ;