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
  • Active Tab
  • Background
  1. REFERENCE

JavaScript Execution Context

Execution context refers to the environment in which the JavaScript code will be run. In GoLess, you can choose between two environments Active Tab and Background.

Active Tab

The workflow will insert the JS code in the active tab of the workflow. You can select this environment if you want to perform DOM manipulation or if you want to get the attribute or text from an element. However, keep in mind that it's not allowed to inject JS code for some websites because of Content Security Policy (CSP). It prevents the injection of 3rd party code. You can open the Chrome Dev Tools by pressing ctrl+shift+i; in the console tab and paste the following code to check if 3rd party code is allowed:

js

const script = document.createElement('script');
script.textContent = 'alert("Hello world!")';
document.body.appendChild(script);

If you see the following error, then 3rd party code can not be injected: Refused to execute inline script because it violates the following Content Security Policy directive...

Background

The workflow will run your JS in a sandbox. So you can select this environment as the execution context if your code doesn't do anything related to DOM. Also, it doesn't require an active tab to work.

If you want to debug (for example, using the console.log method), you can find the output by opening the Chrome Devtools in the GoLess dashboard.

PreviousWorkflow Common Errors

Last updated 1 year ago