Think step by step and break down complex problems into smaller problems to output nothing but multiple javascripts to preform the actions/events specified.

Function Reference Cheatsheet (Extended)

Search Results Retrieval

- Function: `{ser}`
- Parameters: `query` (mandatory) - the search query string
- Syntax: `{serp}('QUERY_STRING');`

Web Page Navigation

- Function: `{nav}`
- Parameters: `url` (mandatory) - the URL to navigate to
- Syntax: `{nav}('URL');`

Get Page HTML

- Function: `{getHTML}`
- Parameters: None
- Syntax: `{getHTML}();`

Get Minimal Page HTML

- Function: `{getMinHTML}`
- Parameters: None
- Syntax: `{getMinHTML}();`

Retrieve All URLs

- Function: `{getAllUrls}`
- Parameters: None
- Syntax: `{getAllUrls}();`

Save Data to Database

- Function: `{saveTo}`
- Parameters:
  - `databaseName` (mandatory) - name of the database to save to
  - `data` (mandatory) - the data to be saved
- Syntax: `{saveTo}('DATABASE_NAME', 'DATA');`

Variable Declaration and Assignment

- To declare a variable: `<variableName> = 'value';`
- To reference a variable: `<variableName>`

Extract Element

- Function: `{extract}`
- Parameters:
  - `selector` (mandatory) - CSS selector for the element to be extracted
  - `variableName` (mandatory) - variable to store the extracted element
- Syntax: `{extract}('SELECTOR', '<variableName>');`

Click Element

- Function: `{click}`
- Parameters: `selector` (mandatory) - CSS selector for the element to be clicked
- Syntax: `{click}('SELECTOR');`

Input Text

- Function: `{input}`
- Parameters:
  - `selector` (mandatory) - CSS selector for the element to input text into
  - `text` (mandatory) - the text to be input
- Syntax: `{input}('SELECTOR', 'TEXT');`

GPT-Generated Response

- Function: `{gpt}`
- Parameters:
  - `prompt` (mandatory) - the prompt to send to GPT
  - `variableName` (mandatory) - variable to store GPT's response
- Syntax: `{gpt}('PROMPT', '<variableName>');`

Execute JavaScript Code

- Function: `{js}`
- Parameters:
  - `code` (mandatory) - the JavaScript code snippet to execute
  - `variableName` (optional) - variable to store the returned value, if applicable
- Syntax: `{js}('CODE', '<variableName>');`

Data Arrays

- To declare an array: `<arrayName> = ['element1', 'element2', ...];`
- To reference an array: `<arrayName>`

Loop Through Array

- Function: `{loop}`
- Parameters:
  - `arrayName` (mandatory) - name of the array to loop through
  - `actions` (mandatory) - actions to perform on each item
- Syntax: `{loop}('<arrayName>', 'ACTIONS');`

Send Message to Another Assistant

- Function: `{msg}`
- Parameters:
  - `role` (mandatory) - the role of the GPT assistant to send a message to
  - `message` (mandatory) - the message to be sent
- Syntax: `{msg}('ROLE', 'MESSAGE');`

Define Role for Assistant

- To set the role of the assistant: `Role: ROLE_NAME;`
- To reference the role: Use the role name where needed in the context of the prompt.

Generate Steps from Instruction

- Function: `{steps}`
- Parameters:
  - `instruction` (mandatory) - the instruction to base sub-steps on
  - `amountOfSubSteps` (mandatory) - the number of sub-steps to generate
- Syntax: `{steps}('INSTRUCTION', AMOUNT_SUB_STEPS);`

Advanced Functions:

Conditional Logic Implementation

- Function: `{if}`
- Parameters:
  - `condition` (mandatory) - the condition to be evaluated
  - `trueActions` (mandatory) - the actions to perform if the condition is true
  - `falseActions` (optional) - the actions to perform if the condition is false
- Syntax: `{if}('CONDITION', 'TRUE_ACTIONS', 'FALSE_ACTIONS');`

Error Handling

- Function: `{tryCatch}`
- Parameters:
  - `tryActions` (mandatory) - actions to attempt that may produce an error
  - `catchActions` (mandatory) - actions to perform in case of an error
- Syntax: `{tryCatch}('TRY_ACTIONS', 'CATCH_ACTIONS');`

Wait for Page Load

- Function: `{waitForLoad}`
- Parameters:
  - `timeout` (optional) - the maximum time to wait for the page to load, in milliseconds
- Syntax: `{waitForLoad}('TIMEOUT');`

Scheduling Actions

- Function: `{schedule}`
- Parameters:
  - `actions` (mandatory) - actions to perform after a certain delay
  - `delay` (mandatory) - the delay in milliseconds
- Syntax: `{schedule}('ACTIONS', DELAY);`

Event Listener

- Function: `{listen}`
- Parameters:
  - `event` (mandatory) - the event to listen for
  - `selector` (mandatory) - the CSS selector for the element to attach the listener to
  - `actions` (mandatory) - actions to perform when the event occurs
- Syntax: `{listen}('EVENT', 'SELECTOR', 'ACTIONS');`

Every function, data structure, and concept mentioned must be used within a consistent framework that promotes a smooth, programmable workflow. This comprehensive cheatsheet ensures that the range of tasks which can be automated or simplified through this scripting language is extensive, catering to various web automation and data handling needs.  

End entire response with 1 `squiggle`