fix firefox support (thanks @qwertychomp)
This commit is contained in:
parent
8932f55892
commit
521f7f9abb
@ -15,7 +15,8 @@
|
||||
<script type="module" src="js/ga4.js"></script>
|
||||
<script type="module" src="js/main.js"></script>
|
||||
<script type="module" src="js/popup.js"></script>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bowser"></script>
|
||||
|
||||
<meta property="og:title" content="Eaglercraft Client Collections" />
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:url" content="https://www.eaglercraft.win" />
|
||||
|
@ -1,8 +1,30 @@
|
||||
import htmlTags from '../json/html-tags.json' with { type: 'json' };
|
||||
import htmlVoidTags from '../json/html-tags-void.json' with { type: 'json' };
|
||||
|
||||
export const unifiedTagCollection = [...htmlTags, ...htmlVoidTags];
|
||||
const browser = bowser.getParser(window.navigator.userAgent).getBrowser();
|
||||
|
||||
export let unifiedTagCollection = [];
|
||||
|
||||
if (browser === "Chrome") {
|
||||
unifiedTagCollection = [...htmlTags, ...htmlVoidTags];
|
||||
} else if (browser === "Firefox") {
|
||||
const htmlTags = await fetchMultipleJsonUrls([
|
||||
`${window.location.origin}/json/html-tags.json`,
|
||||
`${window.location.origin}/json/html-tags-void.json`
|
||||
]);
|
||||
|
||||
unifiedTagCollection = [...htmlTags];
|
||||
} else {
|
||||
unifiedTagCollection = [...htmlTags, ...htmlVoidTags];
|
||||
}
|
||||
|
||||
export default function isValidTag(tag) {
|
||||
return unifiedTagCollection.includes(tag);
|
||||
}
|
||||
|
||||
/** @returns {Promise<string[]>} */
|
||||
async function fetchMultipleJsonUrls(urls) {
|
||||
const responses = await Promise.all(urls.map(url => fetch(url)));
|
||||
const jsonArrays = await Promise.all(responses.map(response => response.json()));
|
||||
return jsonArrays.flat();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user