GoLess
  • Basics
    • Recording Actions
    • Adding workflow manually
    • Tutorial: Scraping data
  • Workflow
    • Customization
    • Blocks
    • Global Data
    • Variables
    • Element Selector
    • Expressions
    • Workflow Table
    • Looping
    • Google Drive
  • Blocks
    • General
      • Note Block
      • Trigger Block
      • Execute Workflow Block
      • Delay Block
      • Export Data Block
      • HTTP Request Block
      • Blocks Group
      • Clipboard Block
      • Wait Connections Block
      • Notification Block
      • Workflow State
      • Parameter Prompt Block
    • Browser
      • Active Tab Block
      • New Tab Block
      • Switch Tab Block
      • New Window Block
      • Proxy Block
      • Go Back Block
      • Go Forward Block
      • Close Tab/Window Block
      • Take Screenshot Block
      • Browser Event Block
      • Handle Download Block
      • Handle Dialog Block
      • Reload Tab Block
      • Get Tab URL Block
      • Cookie Block
    • Web Interaction
      • Click Element Block
      • Get Text Block
      • Scroll Element Block
      • Link Block
      • Attribute Value Block
      • Forms Block
      • Javascript Code Block
      • Trigger Event Block
      • Switch Frame Block
      • Upload File Block
      • Hover Element Block
      • Save Assets Block
      • Press Key Block
      • Create Element Block
    • Control Flow
      • Repeat Task Block
      • Conditions Block
      • Element Exists Block
      • While Loop Block
      • Loop Data Block
      • Loop Elements Block
      • Loop Breakpoint
    • Data
      • Insert Data Block
      • Delete Data Block
      • Get Log Data Block
      • Slice Variable Block
      • Increase Variable Block
      • RegEx Variable Block
      • Data Mapping Block
      • Sort Data Block
    • Оnline Services
      • Google Sheets Block
    • Premium
      • ChatGPT Block
      • Captcha Block
  • REFERENCE
    • Logs
    • Schedule
    • Storage
    • Packages
    • Condition Builder
    • Workflow Common Errors
    • JavaScript Execution Context
Powered by GitBook
On this page
  1. Blocks
  2. Web Interaction

Javascript Code Block

PreviousForms BlockNextTrigger Event Block

Last updated 1 year ago

This block executes javascript code on the site page.

Below is a screenshot of the block settings.

There are two modes of operation of the block: Active tab and Background. The first mode works after opening the active tab using the New Tab or Active Tab blocks. The second mode works in the context of the browser in which the Goless workflow is running, an active browser tab is not required.

Block Settings:

  • Timeout. Delay in executing javascript code, default value 20000ms (20 seconds). If the delay is exceeded, the workflow continues to run the next block.

  • Execute Every New Tab. This will run the JS code when GoLess creates or switches to a new tab. If you enable this option, the JS code block will no longer need an active tab and built-in functions such as golessRefData, golessNextBlock.

  • Run before page loaded. Executing the JS code before loading the page. This setting is only available in Active tab mode.

  • JavaScript code. This is the field for entering the js code that is executed by the workflow.

  • Preload Script. Load a javascript file before running the JS code.

JavaScript Code

There are several integrated fuctions that you can call inside the code.

golessNextBlock(data, insert?)

Instructs the workflow to keep running the next block.

To insert data into the table, use the data parameter. This parameter can take an object or an array of object data types. You can define the key of the object in the table.

The insert parameter controls whether to insert the data in the data parameter into the table. Set to true by default. It is also possible to pass an object that contains two optional properties:

  • insert: insert data into the table or not.

  • nextBlockId: a string specifying the following block's ID to move to.

golessSetVariable(name, value)

Defines the value of the workflow variables.

// Example of outputting a variable from the parameters of a Trigger block
const inputValues = golessRefData('variables', 'param');
console.log(inputValues);
golessNextBlock()

golessRefData(keyword, path)

Use it to access workflow data such as table, variables, etc.

golessFetch(type, resource)

  • type: type of the request answer. Possible values text & json;

  • resource: the resource that you wish to retrieve.

golessResetTimeout()

Use this function to reset the runtime.

Perform an HTTP request in the extension's background in order to prevent .

CORS