npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bas-remote-node

v1.5.1

Published

NodeJS library, which allows you to automate Google Chrome browser.

Downloads

1,319

Readme

bas-remote-node

npm version GitHub issues License: 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:

Check following link for more info:

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.

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 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. IMPORTANT You need to be a premium user in order to create project with custom functions.
  • Start record mode and create new function by using function manager. 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 for more info.
  • Compile it and give it a name. Check this article more more instruction for compilation.
  • Finally, allow remote function execution flag for script must be set. You can do that on following page. See screenshot 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:

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

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.