Skip to content

Instantly share code, notes, and snippets.

@mahemoff
mahemoff / background.js
Created February 22, 2013 04:23
add/remove context menu (requires tabs permission)
chrome.tabs.onUpdated.addListener(function(tabId,changeInfo,tab){ //onUpdated should fire when the selected tab is changed or a link is clicked.
chrome.tabs.getSelected(null,function(tab){
if (tab.url=='http://techmeme.com/')
chrome.contextMenus.create(contextMenuSpec);
else
chrome.contextMenus.removeAll();
});
});
var contextMenuSpec = {
@dexit
dexit / google-chrome-extension-download.js
Last active April 26, 2024 23:20
Chrome Extension download link
const fetch = require('node-fetch');
const fs = require('fs');
const path = require('path');
// Function to download and rename the file
async function downloadAndRenameFile(url, filename) {
const response = await fetch(url);
const fileStream = fs.createWriteStream(filename);
return new Promise((resolve, reject) => {
@chrisjlee
chrisjlee / chrome-location.js
Created October 25, 2015 03:18
get chrome location with nodejs - from chrome-location: https://github.com/hughsk/chrome-location/blob/master/index.js
var osx = process.platform === 'darwin'
var win = process.platform === 'win32'
var other = !osx && !win
var fs = require('fs')
if (other) {
try {
module.exports = require('which').sync('google-chrome')
} catch(e) {
module.exports = null
@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]