Merge branch 'master' into settings

This commit is contained in:
Ajay Ramachandran
2022-01-21 12:28:47 -05:00
committed by GitHub
41 changed files with 1281 additions and 360 deletions

View File

@@ -44,4 +44,14 @@ export function getCategoryActionType(category: Category): CategoryActionType {
} else {
return CategoryActionType.Skippable;
}
}
export function getCategorySuffix(category: Category): string {
if (category.startsWith("poi_")) {
return "_POI";
} else if (category === "exclusive_access") {
return "_full";
} else {
return "";
}
}

View File

@@ -40,4 +40,25 @@ function findValidElementFromGenerator<T>(objects: T[] | NodeListOf<HTMLElement>
}
return null;
}
export function getHashParams(): Record<string, unknown> {
const windowHash = window.location.hash.substr(1);
if (windowHash) {
const params: Record<string, unknown> = windowHash.split('&').reduce((acc, param) => {
const [key, value] = param.split('=');
const decoded = decodeURIComponent(value);
try {
acc[key] = decoded?.match(/{|\[/) ? JSON.parse(decoded) : value;
} catch (e) {
console.error(`Failed to parse hash parameter ${key}: ${value}`);
}
return acc;
}, {});
return params;
}
return {};
}