mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-12 06:27:14 +03:00
Merge branch 'master' into settings
This commit is contained in:
@@ -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 "";
|
||||
}
|
||||
}
|
||||
@@ -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 {};
|
||||
}
|
||||
Reference in New Issue
Block a user