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
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 = { |
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 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) => { |
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 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 |
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] |
NewerOlder