Skip to content

Instantly share code, notes, and snippets.

@dy
dy / require.js
Last active April 26, 2024 23:19
require.js in browser
/**
* 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 = {};
@yocontra
yocontra / fucking-run-chrome.js
Created April 14, 2014 00:46
Testing WebRTC in Chrome
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 = [
@jeffgca
jeffgca / widget.js
Created September 20, 2013 21:26
chrome urls FTW!
require('sdk/widget').Widget({
id: 'mine-test',
label: 'Something',
contentURL: 'chrome://global/skin/icons/webapps-16.png',
onClick: function() {
console.log('foo');
}
});
@imbolc
imbolc / httpx_aiohttp.py
Created March 1, 2020 10:47
Httpx vs aiohttp benchmark
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}/"
@stoyan
stoyan / topx.js
Created September 14, 2022 20:30
top chrome extensions
// 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();
}
@monochromer
monochromer / headless-chrome-pdf-async.js
Last active April 26, 2024 23:19
Print pdf with headless chrome
/**
* 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');
@makeding
makeding / app.js
Created November 12, 2020 12:03
check latest chrome version
# 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]
@joey-g
joey-g / headless-wd-example.es6
Last active April 26, 2024 23:17
Headless Chrome - WebDriver Example
// 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
@svkrclg
svkrclg / custom_binary_test.js
Created September 29, 2020 14:19
Run specific chrome binary
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
@VerteDinde
VerteDinde / index.html
Created September 28, 2023 14:19
Message Port Chrome Repro
<!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>