1
0
mirror of https://github.com/XFox111/my-website.git synced 2026-04-22 07:28:01 +03:00
Files
my-website/public/clarity.js
T

52 lines
1.7 KiB
JavaScript

// Microsoft Clarity tracking code
// Learn more: https://clarity.microsoft.com
// Privacy FAQ: https://learn.microsoft.com/clarity/faq#privacy
/*
* This is a modified version of the original script provided by Microsoft.
* It was reverse-engineered for better readability and transparency.
*
* Original code snippet:
*
* <script type="text/javascript">
* (function(c,l,a,r,i,t,y){
* c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
* t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
* y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
* })(window, document, "clarity", "script", "[redacted_clarity_id]");
* </script>
*
* All Clarity tracking code is available on https://github.com/microsoft/clarity
*/
// If you want to setup Clarity analytics as well, you'll need to specify the ID in .env file,
// which can be found in the snippet above (see "[redacted_clarity_id]").
// Snippet can be obtained from the Clarity dashboard.
// @ts-check
(function ()
{
/** @type {string | undefined} */
const id = document.getElementById("ms-clarity")?.dataset.id;
// If "Do Not Track" is enabled, or there's no CLARITY_ID set up, we don't load any analytics
if (!id || navigator.doNotTrack === "1")
return;
window["clarity"] ??= function ()
{
window["clarity"].q ??= [];
window["clarity"].q.push(arguments);
};
/** @type {HTMLScriptElement} */
const scriptTag = document.createElement("script");
scriptTag.async = true;
scriptTag.src = "https://www.clarity.ms/tag/" + id;
/** @type {HTMLScriptElement} */
const firstScript = document.getElementsByTagName("script")[0];
firstScript.parentNode?.insertBefore(scriptTag, firstScript);
})();