🇻🇳
GPM Automate VI
  • NO-CODE AUTOMATION
    • Một số biến mặc định
    • Các block
      • Normal block
      • For
      • While
      • If
      • Else if
      • Else
    • Variables
      • Set variable
      • Increase variable
      • Decrease variable
      • Count
    • Workflow
      • Exit loop
      • Next loop
      • Delay
    • Text & number
      • Random text
      • Split text
      • Read json
      • Random number
      • Math execute
      • 2FA code
  • File & Folder
    • File exists
    • Copy file
    • Move/rename file
    • Delete file
    • File read all text
    • File read all lines
    • File write all text
    • File append line
    • Read excel file
    • Write excel file
    • Append excel file
    • Folder exists
    • Create folder
    • Move / rename folder
    • Delete folder
    • Folder get file list
  • Clipboard
    • Get clipboard text
    • Set clipboard text
  • HTTP
    • HTTP Request
    • HTTP Download
  • Image Search
    • Wait to image
    • Image exists
    • Image search
    • Ví dụ kết hợp
  • AI
    • ChatGPT
  • Mail
    • Read mail code
    • Read outlook (Oauth2)
  • Navigation
    • New tab
    • Active tab
    • Close tab
    • Go to URL
    • Back URL
    • Reload
    • Get URL
    • Wait URL Changed
  • Element
    • Wait element
    • Get element attribute
    • Get element text
    • Count element
  • Mouse
    • Mouse click
    • Mouse try to click
    • Mouse move
    • Mouse press and hold
    • Mouse release
    • Mouse scroll
  • Keyboard
    • Key press
    • File upload
    • Select dropdown
  • Scroll
    • Random scroll
    • Scroll to top
    • Scroll to bottom
    • Scroll to element
  • Switch
    • Switch to default
    • Switch to frame
    • Switch to popup
  • Cookie
    • Import cookie
    • Export cookie
  • Alert
    • Accept alert
    • Cancel alert
  • Javascript
    • Execute JS code
    • Get extension id
  • References
    • Call function
  • Google service
    • Read google sheet
    • Write google sheet
Powered by GitBook
On this page
  1. Javascript

Execute JS code

Chạy code Javascript.

PreviousJavascriptNextGet extension id

Last updated 24 days ago

Giải thích thêm về các action Execute JS code

Chạy code Javascript trong trình duyệt. Bạn có thể paste code trực tiếp vào action này hoặc paste đường dẫn tới file .js Chú ý: Để đoạn JS code xử lý và trả về 1 giá trị, bạn cần thêm lệnh return ở cuối đoạn code JS.

Chú ý: Bạn hoàn toàn có thể nhúng biến từ Automate vào trong đoạn code js và trả kết quả về 1 biến Automate sau khi chạy code js. Chú ý với biến dạng string phải có dấu backtick (hoặc dấu double quotes, single quotes bao bọc nhé).

Ví dụ: Bạn có 1 biến str trong Automate như sau: str = Hello, world! 1 biến index = 7. Bạn muốn dùng action Execute JS code để viết 1 đoạn js lấy ra ký tự có index là 7 trong chuỗi str "Hello, world!" (kết quả là ký tự w). Bạn có thể viết như sau:

const str = `$str`; const index = $index; const char = index >= 0 && index < str.length ? str[index] : "Invalid index";

return char;

Set variable
Set variable