-
Notifications
You must be signed in to change notification settings - Fork 0
/
decodeGooglehtmlentities.js
22 lines (17 loc) · 1.75 KB
/
decodeGooglehtmlentities.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
paste into console:
const analyticsHtmlEncoded = '[{"dimensions": {"dimension16": false, "dimension17": "Signed out", "dimension2": "en", "dimension46": false, "dimension36": "en"}, "gaid": "UA-36037335-14", "metrics": {}, "purpose": 0}]';
const tagManagementHtmlEncoded = '{"at": "True", "ga4": [], "ga4p": [], "gtm": [{"id": "GTM-5CVQBG", "purpose": 1}], "parameters": {"internalUser": "False", "language": {"machineTranslated": "False", "requested": "en", "served": "en"}, "pageType": "error", "projectName": "Google Cloud", "signedIn": "False", "tenant": "cloud", "recommendations": {"sourcePage": "", "sourceType": 0, "sourceRank": 0, "sourceIdenticalDescriptions": 0, "sourceTitleWords": 0, "sourceDescriptionWords": 0, "experiment": ""}, "experiment": {"ids": ""}}}';
// replace the above variables you can get them from google pages
// Function to decode HTML entities
function htmlDecode(input) {
const doc = new DOMParser().parseFromString(input, "text/html");
return doc.documentElement.textContent;
}
// Decode the HTML entities
const analyticsDecoded = htmlDecode(analyticsHtmlEncoded);
const tagManagementDecoded = htmlDecode(tagManagementHtmlEncoded);
// Parse the JSON strings
const analyticsJson = JSON.parse(analyticsDecoded);
const tagManagementJson = JSON.parse(tagManagementDecoded);
console.log(analyticsJson);
console.log(tagManagementJson);