aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils/pageUtils.ts
diff options
context:
space:
mode:
authorAjay <[email protected]>2022-01-14 19:34:54 -0500
committerAjay <[email protected]>2022-01-14 19:34:54 -0500
commitd50a69f1fd99f20a686e35b0cadcec02a62eec61 (patch)
tree1a8df83dcea1c1fa1afda886b1b977c54eac7337 /src/utils/pageUtils.ts
parent31014b78ac8b71c3384a40f42b6e35995b508dee (diff)
downloadSponsorBlock-d50a69f1fd99f20a686e35b0cadcec02a62eec61.tar.gz
SponsorBlock-d50a69f1fd99f20a686e35b0cadcec02a62eec61.zip
New hash format for previewing segments
Diffstat (limited to 'src/utils/pageUtils.ts')
-rw-r--r--src/utils/pageUtils.ts8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/utils/pageUtils.ts b/src/utils/pageUtils.ts
index 6db26e19..28ac37d8 100644
--- a/src/utils/pageUtils.ts
+++ b/src/utils/pageUtils.ts
@@ -47,7 +47,13 @@ export function getHashParams(): Record<string, unknown> {
if (windowHash) {
const params: Record<string, unknown> = windowHash.split('&').reduce((acc, param) => {
const [key, value] = param.split('=');
- acc[key] = value;
+ 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;
}, {});