Skip to content

Commit

Permalink
clarityy
Browse files Browse the repository at this point in the history
  • Loading branch information
vickkie committed Feb 28, 2024
1 parent 863404d commit b4191ee
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 28 deletions.
33 changes: 16 additions & 17 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<meta name="keywords" content="Welcome ,portfolio,uzitrake" />
<meta name="author" content="uzitrake" />
<meta name="theme-color" content="#dbc6f7" />
<meta http-equiv="Cache-Control" content="max-age=31536000" />
<link id="browser_favicon" rel="icon" href="img/masks/uzitrake-logo.png" />
<link rel="stylesheet" type="text/css" href="css/preloader.css" />

Expand Down Expand Up @@ -43,6 +42,21 @@

<!-- //microsoft crarity -->

<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", "l8ldwajz4e");
</script>

<link rel="manifest" href="manifest.json" />
</head>

Expand Down Expand Up @@ -1516,7 +1530,7 @@ <h2 class="heading">

<script src="libs-js/split-text.js"></script>
<script src="libs-js/imagesloaded.pkgd.js"></script>
<script src="call-worker.js"></script>
<!-- <script src="call-worker.js"></script> -->
<script src="libs-js/lenis.js"></script>

<script defer type="module" src="js/index.js"></script>
Expand All @@ -1541,20 +1555,5 @@ <h2 class="heading">
gtag("config", "G-F0NF6J8B0H");
</script> -->

<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", "l8ldwajz4e");
</script>
</body>
</html>
68 changes: 57 additions & 11 deletions offline-uzitrake.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
const cacheName = "uzitrake-offline";
var cacheVersion = 2;
// var cacheName = {
// offline: 'uzitrake-offline' + cacheVersion,
// }

let offlineUrl = "offline.html";

Expand Down Expand Up @@ -46,14 +43,63 @@ self.addEventListener("activate", (e) => {
);
});

self.addEventListener("fetch", (e) => {
e.respondWith(
fetch(e.request)
.then((res) => {
// Check if the response status is OK (status code 200)
if (res.status === 200) {
// Check if the request is not from a chrome-extension
if (!e.request.url.startsWith("chrome-extension://")) {
// Make a clone of the response
const resClone = res.clone();
// Open the cache and add the response to it
caches.open(cacheName).then((cache) => {
cache.put(e.request, resClone);
});
}
}
// Return the original response
return res;
})
.catch((err) =>
caches
.match(e.request)
.then((res) => res)
.then(console.log("Error:", err))
)
);
});

// call fetch event
self.addEventListener("fetch", (e) => {
// Check if the request is for the Clarity script
if (e.request.url.includes("clarity.ms")) {
// If it is, try to fetch the resource from the network
e.respondWith(fetch(e.request));
} else {
// If it's not, serve the offline.html page from the cache
e.respondWith(fetch(e.request).catch(() => caches.match(offlineUrl)));
}
// console.log('Service worker: fetching');
e.respondWith(fetch(e.request).catch(() => caches.match(offlineUrl)));
});

// call fetch event
// self.addEventListener("fetch", (e) => {
// // Check if the request is for the Clarity script
// if (e.request.url.includes("clarity.ms")) {
// // If it is, try to fetch the resource from the network
// e.respondWith(fetch(e.request));
// } else {
// // If it's not, serve the offline.html page from the cache
// e.respondWith(fetch(e.request).catch(() => caches.match(offlineUrl)));
// }
// });

// self.addEventListener("fetch", (e) => {
// if (e.request.url.includes("clarity.ms")) {
// // Attempt to fetch the resource from the network
// e.respondWith(
// fetch(e.request).catch(() => {
// // If the network request fails, serve a fallback or offline page
// return caches.match("fallback.html");
// })
// );
// } else {
// // For other requests, serve from cache or network as before
// e.respondWith(fetch(e.request).catch(() => caches.match(offlineUrl)));
// }
// });

0 comments on commit b4191ee

Please sign in to comment.