Chrome New Tab Page extension steal focus from the address bar

ManifestV3 update This answer is adapted from https://stackoverflow.com/a/11348302/1754517. This has been tested with both Manifest V2 and V3. Tested in Google Chrome 99.0.4844.51 64-bit (Windows 10). Replace the content of focus.js with: if (location.search !== “?x”) { location.search = “?x”; throw new Error; // load everything on the next page; // stop execution on this … Read more

Visual Studio Code syntax highlighting is not working for JavaScript and TypeScript

I think this was caused by the extension called JavaScript and TypeScript Nightly. This was causing the syntax highlighting for .js and .ts files (.jsx and .tsx too). This was more of a bug with the latest version (currently 1.73.1). You can disable the extension to enable the syntax highlighting. This extension has now been … Read more

Communication between tabs/windows with same origin [duplicate]

I’m sticking to the shared local data solution mentioned in the question using localStorage. It seems to be the best solution in terms of reliability, performance, and browser compatibility. localStorage is implemented in all modern browsers. The storage event fires when other tabs makes changes to localStorage. This is quite handy for communication purposes. References … Read more

Extract certain properties from all objects in array

Use object destructuring to get the properties, and generate a new object using shorthand property names: const dummyArray = [{ “att20”: “att20”, “att30”: “att30”, “att70”: “att70”, “att80”: “att80”}, { “att20”: “att20”, “att30”: “att30”, “att70”: “att70”, “att80”: “att80”}]; const result = dummyArray.map(({ att20, att30, att70, att80 }) => ({ att20, att30, att70, att80 })); console.log(result);

How to perform a “variable” ES6 import?

Not with the import statement. import and export are defined in such a way that they are statically analyzable, so they cannot depend on runtime information. You are looking for the loader API (polyfill), but I’m a bit unclear about the status of the specification: System.import(‘./utils/’ + variableName).then(function(m) { console.log(m); });