Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cheshirecaat/bas-remote-node
NodeJS library, which allows you to automate Google Chrome browser.
https://github.com/cheshirecaat/bas-remote-node
automation bas bas-client bas-remote bas-remote-client bas-remote-control bot bot-framework browser browserautomationstudio cef chromium desktop grabber ide imacros macros poster visual-programming-language windows
Last synced: about 10 hours ago
JSON representation
NodeJS library, which allows you to automate Google Chrome browser.
- Host: GitHub
- URL: https://github.com/cheshirecaat/bas-remote-node
- Owner: CheshireCaat
- License: mit
- Created: 2020-02-16T18:37:09.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-10-01T18:22:37.000Z (3 months ago)
- Last Synced: 2025-01-03T13:16:22.367Z (7 days ago)
- Topics: automation, bas, bas-client, bas-remote, bas-remote-client, bas-remote-control, bot, bot-framework, browser, browserautomationstudio, cef, chromium, desktop, grabber, ide, imacros, macros, poster, visual-programming-language, windows
- Language: JavaScript
- Homepage:
- Size: 274 KB
- Stars: 28
- Watchers: 3
- Forks: 7
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# bas-remote-node
[![npm version](https://badge.fury.io/js/bas-remote-node.svg)](https://badge.fury.io/js/bas-remote-node)
[![GitHub issues](https://img.shields.io/github/issues/CheshireCaat/bas-remote-node)](https://github.com/CheshireCaat/bas-remote-node/issues)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)**bas-remote-node** - NodeJS library, which allows you to **automate Google Chrome browser**.
In order to make it possible, BrowserAutomationStudio application is used. **bas-remote-node** allows you to call and control execution of functions created in BAS. Consider following example, you have a BAS function, which executes specified Google search query and returns result as a list of urls. Using this library, you can call that function in any NodeJS application and obtain result. You can distribute applications written with **bas-remote-node** library as well.
# BrowserAutomationStudio
**BAS** - is application that allows you to automate any activities in Google Chrome browser with a help of visual programming and without knowing of any programming language. You can think of it as IDE created especially for browser automation:
![](https://bablosoft.com/landing2/screen-bas.png)
Check following link for more info:
[https://bablosoft.com/shop/BrowserAutomationStudio](https://bablosoft.com/shop/BrowserAutomationStudio)
# Installation
```
npm install --save bas-remote-node
```# Quick start
Following code will search for _cats_ query in Google and output result into console. You can just copy paste this code and run it.
```js
const BasRemoteClient = require('bas-remote-node');async function main() {
//Set script name, and optionally auth details (login, password)
const options = {
scriptName: 'TestRemoteControl' /* or 'YourScriptName' */,
};//Create client
const scriptClient = new BasRemoteClient(options);//Start application, this may take some time
await scriptClient.start();//Set parameters for function
const scriptParams = {
Query: 'cats',
};//Run function and wait for result
//Following function will return list of strings
const result = await scriptClient.runFunction('GoogleSearch' /* or 'YourFunctionName' */, scriptParams);//Iterate and output results
result.forEach(link => {
console.log(link);
});await scriptClient.close();
}main();
```Checkout [wiki](https://github.com/CheshireCaat/bas-remote-node/wiki) for more examples.
# Running custom code
Previous example used _TestRemoteControl_ project and _GoogleSearch_ function defined in it. In most cases you want to use your own projects and functions. In order to do it:
- Install BAS. Download using following [link](https://bablosoft.com/shop/BrowserAutomationStudio#download). **IMPORTANT** You need to be a premium user in order to create project with custom functions.
- Start [record mode](https://i.imgur.com/JrV7ua5.png) and create new function by using [function manager](https://i.imgur.com/yAjLu8v.png). BAS functions works like functions in any other languages. They can be called with parameters and can return value as a result. Functions help to incapsulate and reuse your code.
- Implement it. On following step you need to implement required functionality. Place code into the function that you have created on previous step. They will be called from NodeJS code later. Function parameters will be sent from NodeJS to BAS, while return value will be sent from BAS to NodeJS. Working with BAS is out of scope of this article, check [BAS wiki](https://wiki.bablosoft.com/doku.php) for more info.
- Compile it and give it a name. Check this [article](https://wiki.bablosoft.com/doku.php?id=how_to_protect_your_script) more more instruction for compilation.
- Finally, **allow remote function execution** flag for script must be set. You can do that on following [page](https://bablosoft.com/bas/scripts). See [screenshot](https://i.imgur.com/BrkefIT.png) for more details.After project with function is prepared, you can use it from NodeJS. In order to do that, change script and function name in example above.
# How it works
Following diagram will explain project architecture:
![](https://i.imgur.com/9lfF3EJ.png)
**Running custom code** section explains how to prepare your project and upload it into the cloud. Portable BAS instance is downloaded and started automatically, it is also closed automatically when `BasRemoteClient` gets closed. Folder, where portable BAS instance is located by default is _data_ folder relative to executable. It can be customized by using `options.workingDir` setting.
# Project example
You can use _TestRemoteControl_ project in order to test **bas-remote-node** library. It is already uploaded into the cloud and can be used without authentication. List of available functions:
- `Add(X,Y)` - adds two numbers and return their sum.
- `SetProxy(Proxy,IsSocks5)` - sets proxy for current thread. _Proxy_ param is proxy string, _IsSocks5_ is string("true", "false") value indicates if proxy type is socks5. No return value.
- `CheckIp()` - returns remote IP of current thread. Uses ip.bablosoft.com service to test. Can be combined with _SetProxy_ function.
- `GoogleSearch(Query)` - performs Google query, returns result as a list of urls.Project source code can be downloaded [here](https://drive.google.com/uc?id=1WQYzm-XaZhXUBWQYMM5T-sZ_tdcSfAwS&export=download)
# License
**bas-remote-node** has MIT license.
You can distribute applications using **bas-remote-node** library, including commercial, to user, who don't have BAS premium subscription without any fees.
In order to create project with custom functions you need to have a BAS premium subscription.
In other words, only developers must have BAS premium subscription, not users.