Discover gists
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Require stub for browser. | |
* Prepend this script in head. | |
* Set `data-module="name"` attribute on script tag to define module name to register (or it will be parsed as src file name). | |
* Works only in browsers supporting Object.observe (Chrome with flags) | |
*/ | |
//module/exports changing observer to expose global variables | |
var module = {}; | |
var exports = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var os = require('os'); | |
var path = require('path'); | |
var randomDir = function() { | |
return path.join(os.tmpdir(), String(Math.floor(Math.random()*1000))); | |
}; | |
var openit = function(url) { | |
var chromeLocation = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'; | |
var args = [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('sdk/widget').Widget({ | |
id: 'mine-test', | |
label: 'Something', | |
contentURL: 'chrome://global/skin/icons/webapps-16.png', | |
onClick: function() { | |
console.log('foo'); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from starlette.applications import Starlette | |
from starlette.routing import Route | |
from starlette.responses import PlainTextResponse | |
import httpx | |
import aiohttp | |
HOST, PORT = "localhost", 8000 | |
URL = f"http://{HOST}:{PORT}/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// data from https://github.com/DebugBear/chrome-extension-list | |
const data = require('./extensions-2021.json'); | |
const topx = {}; | |
data.forEach(x => { | |
if (x.installs !== "10,000,000+") { | |
Object.keys(topx).sort().forEach(key => { | |
console.log(topx[key]); | |
}) | |
process.exit(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* chrome-remote-interface: JavaScript API, обеспечивающее простую абстракцию для команд и уведомлений | |
* | |
* chrome-launcher: позволяет нам запускать Chrome из Node.js кроссплаторменно | |
*/ | |
const chromeLauncher = require('chrome-launcher'); | |
const CDP = require('chrome-remote-interface'); | |
const file = require('fs'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# yarn add axios | |
# npm -i axios | |
let fs = require('fs') | |
let axios = require('axios') | |
let config = require('./config.json') | |
async function checkchromeversion() { | |
let system = ['Windows NT 10.0; Win64; x64', 'Windows NT 6.1; Win64; x64'] | |
let data = await axios.get('https://dl.google.com/linux/chrome/deb/dists/stable/main/binary-amd64/Packages') | |
if (data.data) { | |
let v = data.data.split('\n')[1].split(' ')[1].split('-')[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://developers.google.com/web/updates/2017/04/headless-chrome | |
const fs = require('fs'); | |
const {Builder, By, Capabilities, Key, until} = require('selenium-webdriver'); | |
const chromedriver = require('chromedriver'); | |
const chromeCapabilities = Capabilities.chrome(); | |
chromeCapabilities.set('chromeOptions', {args: ['--headless']}); | |
async function test() { | |
// Note: On macOS, you'll likely see a new Chrome process flash on your 'Dock' | |
// when this new driver object is built. As it's launched headlessly, it's |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const lighthouse = require('lighthouse'); | |
const chromeLauncher = require('chrome-launcher'); | |
(async () => { | |
const chrome = await chromeLauncher.launch({chromePath: "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"}); //Specify chrome binary path to run lighthouse. | |
const options = {logLevel: 'info', output: 'html', onlyCategories: ['performance'], port: chrome.port}; | |
const runnerResult = await lighthouse('https://example.com', options); | |
// `.report` is the HTML report as a string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP --> | |
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'"> | |
<title>Hello World!</title> | |
</head> | |
<body> | |
<h1>Hello World!</h1> |
NewerOlder