Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Fix WontFix

guest271314

💭
Fix WontFix
View GitHub Profile
@guest271314
guest271314 / background.js
Created Nov 4, 2022
Stream same data to all non-chrome tabs
View background.js
const start = new Date();
let streams = [];
let data = [...Array(1000)].map((_, i) => i);
let encoder = new TextEncoder();
let resolve;
let promise = new Promise((_) => (resolve = _));
let readable = new ReadableStream({
start: async (_) => {
// console.log('Original stream');
return promise;
View background.js
// https://www.reddit.com/r/learnjavascript/comments/yeodfh/chrome_extension_error_extensionsjs2897_uncaught/
// Use a Port for multiple messages
chrome.runtime.onConnect.addListener((port) => {
console.log(port);
port.onMessage.addListener(async (message) => {
if (message.name === 'stream' && message.streamId) {
console.log(message.streamId);
try {
const stream = await navigator.mediaDevices.getUserMedia({
video: {
@guest271314
guest271314 / native_messaging_javascript_runtime_tests.md
Last active Oct 11, 2022
Native Messaging JavaScript runtime tests
View native_messaging_javascript_runtime_tests.md

Native Messaging JavaScript runtime hosts tested:

  • QuickJS
  • Node.js
  • Deno

Test: Pass new Array(10000) from client to host, pass message back to client, 100 times, measure time with performance.now().

(async()=>{
View fetch-node-nightly-executable.js
let fileSystemHandle = await showSaveFilePicker({ suggestedName: 'node' }),
writable,
writer,
file;
let status = await fileSystemHandle.requestPermission({ mode: 'readwrite' });
let osArch = 'linux-x64';
// https://github.com/InvokIT/js-untar/
class PaxHeader {
constructor(fields) {
this._fields = fields;
View The_insanity_of_censorship.txt
"Sun, Jul 3, 3:22 PM
Hi guest271314, Your account, @guest271314 has been locked for violating the Twitter Rules.
Specifically for: Violating our rules against hateful conduct.
You may not promote violence against, threaten, or harass other people on the basis of race,
ethnicity, national origin, sexual orientation, gender, gender identity, religious affiliation,
age, disability, or serious disease.
avatar guest271314 @guest271314
@guest271314
guest271314 / background.js
Created Jul 2, 2022
Node.js Native Messaging Host Memory Usage
View background.js
/*
port = chrome.runtime.connectNative('node_native_messaging_host_memory_usage');
port.onMessage.addListener((message)=>{
console.log(message);
});
port.onDisconnect.addListener(()=>{
if (chrome.runtime.lastError) {
console.log(chrome.runtime.lastError.message)
}
@guest271314
guest271314 / ctrl_v_google_image_search.js
Created May 7, 2022
Google Images Search with Ctrl+V
View ctrl_v_google_image_search.js
// https://twitter.com/ericlaw/status/1521939256574423044
document.onpaste = async (e) => {
async function handlePaste(file) {
const url = 'https://www.google.com/searchbyimage/upload';
const fd = new FormData();
fd.append('hl', navigator.languages[navigator.languages.length - 1]);
fd.append('filename', file.name);
// fd.append('image_content', file, file.name);
fd.append('encoded_image', file, file.name);
const request = await fetch(url, {
@guest271314
guest271314 / native_messaging_bash_string_echo.sh
Created Apr 25, 2022
Bash Native Messaging host. Echo JSON string that does not include (escaped) double quotes.
View native_messaging_bash_string_echo.sh
#!/bin/bash
# Bash Native Messaging host, guest271314 2022
# Echo JSON string that does not include (escaped) double quotes
# https://stackoverflow.com/a/24777120
sendMessage() {
message=\"$1\"
# Calculate the byte size of the string.
# NOTE: This assumes that byte length is identical to the string length!
# Do not use multibyte (unicode) characters, escape them instead, e.g.
@guest271314
guest271314 / UntarFileStream.js
Created Apr 10, 2022
js-untar as Ecmascript Module
View UntarFileStream.js
// UntarFileStream.js
// Based on https://github.com/InvokIT/js-untar/blob/master/src/untar-worker.js
// guest271314 4-9-2022
/*
// Usage
let response = (
await fetch('https://nodejs.org/dist/v17.9.0/node-v17.9.0-linux-x64.tar.gz')
).body;
let decompressedBuffer = await new Response(
await response.pipeThrough(new DecompressionStream('gzip'))