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
// This is a simple experiment to see how likely it is to get a collision when using Math.random() | |
(() => { | |
const numbersSet = new Set(); | |
while (true) { | |
const random = Math.random(); | |
// const random = crypto.randomUUID(); | |
if (numbersSet.has(random)) { | |
console.log(`Set size: ${numbersSet.size.toLocaleString()}, collision: ${random}`); | |
break; | |
} |
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
if (!browser.windows) browser.windows = {}; | |
if (!browser.windows.getCurrent) { | |
browser.windows.getCurrent = async (getInfo?: browser.windows.GetInfo): Promise<browser.windows.Window> => { | |
const tabs = await browser.tabs.query({}); | |
const activeTab = tabs.find(tab => tab.active); | |
return { | |
id: activeTab?.windowId ?? 1, | |
title: activeTab?.title ?? '', | |
focused: true, | |
alwaysOnTop: false, |