Skip to content

Commit

Permalink
fix: Fixed script injection (close #1322)
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed Sep 2, 2023
1 parent 37b8354 commit c412158
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/webpack/index.ts
Expand Up @@ -89,21 +89,23 @@ export function injectLoader(): void {
debug('injected');
await internalEv.emitAsync('webpack.injected').catch(() => null);

await new Promise((resolve) => setTimeout(resolve, 1000));

const allRuntimes = new Array(10000)
.fill(1)
.map((v, k) => v + k)
.filter((v) => {
const filename = webpackRequire.u(v);
if (filename.includes('locales')) {
return navigator.languages.some((lang) =>
filename.includes(`locales/${lang}`)
);
}
return !filename.includes('undefined');
});

const mainRuntimes = allRuntimes.filter((v) => {
const filename = webpackRequire.u(v);
if (filename.includes('locales')) {
return navigator.languages.some((lang) =>
filename.includes(`locales/${lang}`)
);
}
return filename.includes('main');
});

Expand Down

2 comments on commit c412158

@jchiavellibr
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

obrigado Edgar!

@dhulke
Copy link

@dhulke dhulke commented on c412158 Sep 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sensacional

Please sign in to comment.