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

nodejs-chrome

v1.5.2

Published

[![Version](https://img.shields.io/npm/v/nodejs-chrome.svg)](https://www.npmjs.org/package/nodejs-chrome)

Downloads

2

Readme

nodejs-chrome

Version

Пример

Example

var chrome = require('nodejs-chrome');
var browser = await chrome({
	headless: false,
	device: {
		name: 'Tablet | Nexus 10',
		userAgent: 'Mozilla/5.0 (Linux; Android 6.0.1; Nexus 10 Build/MOB31T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3765.0 Safari/537.36',
		touchPoints: 5,
		viewport: {
			width: 1280, height: 800, deviceScaleFactor: 2, isMobile: true, hasTouch: true, isLandscape: true
		}
	},
	proxy: '80.78.75.59:38253'
});
try {
	var page = await browser.tabnew();
	if (!(await browser.isHeadless()))
		await page.pointer();
	await page.setUrl('https://api.qwedl.com/ip.php');
	await page.tapClick('#menu->#menu a');
	await page.mouse.move(135, 173);
	await page.touchscreen.tap(173, 135);
	await page.type('input[type="text"]', 'Погода');
	var res = [await page.json()];
	await page.tapClick('input[type="text"]', {
		input: 'Погода', send: true, wait: true
	});
	res.push(await page.json());
	console.log({
		get: res[1].data.get,
		post: res[1].data.post,
		pointer: res[0].user.pointer,
		key: res[0].user.key,
		device: res[0].user.device,
		location: res[0].location,
		headless: await browser.isHeadless()
	});
} catch (e) {}
if (await browser.isHeadless())
	browser.exit();

Список устройств

Device list

chrome().then(browser => browser.exit().then(() => console.log(browser.parent.module.devices)));

Подмена гео положения

Replacement of geo position

var browser = await chrome();
try {
	var page = await browser.tabnew();
	await page.setGeoPosition({
		latitude: 51.507351, longitude: -0.127758, accuracy: 90
	});
	await page.setUrl('https://api.qwedl.com/ip.php');
	console.log((await page.json()).user.coords);
} catch (e) {}
browser.exit();

Запуск браузера через ssh

Launching a browser through ssh

var browser = await chrome({
	ssh: 'login:password@host',
	userDataDir: './user',
	timeZone: 'Europe/Berlin'
});
try {
	var page = await browser.tabnew();
	await page.setUrl('https://api.qwedl.com/ip.php?headless&noalert');
	console.log(await page.json());
} catch (e) {}
await browser.exit();

Быстрый результат без запуска браузера

Fast result without launching the browser

console.log(
	await chrome({
		eval: `
			var page = await browser.tabnew();
			await page.setUrl('https://api.qwedl.com/ip.php?headless&noalert');
			console.log(await page.json());
			await page.screenshot({path: 'screenshot.png'});
			await browser.exit();
		`
	})
);

Installation

npm install nodejs-chrome