From 7049b92225e710fef0f1d0284a0f3e9205b3ea12 Mon Sep 17 00:00:00 2001 From: Todor Kirilov Date: Sat, 10 Oct 2026 07:13:53 +0300 Subject: [PATCH] refactor: replace inline pinger script with external widget Remove the `pinger.js` file in favor of the hosted external widget. Update MkDocs configuration to use a custom overrides directory for injecting the widget script. --- docs/javascripts/pinger.js | 28 ---------------------------- docs/overrides/main.html | 10 ++++++++++ mkdocs.yml | 3 +-- 3 files changed, 11 insertions(+), 30 deletions(-) delete mode 100644 docs/javascripts/pinger.js create mode 100644 docs/overrides/main.html diff --git a/docs/javascripts/pinger.js b/docs/javascripts/pinger.js deleted file mode 100644 index 974c6f5..0000000 --- a/docs/javascripts/pinger.js +++ /dev/null @@ -1,28 +0,0 @@ -(() => { - const projectKey = 'pk_FBOt2HGSSqzXP8J1OL95ctgo_rw2wbThwygdOl-fWvE'; - const storageKey = 'pinger:' + projectKey + ':visitor-id'; - - try { - if (!window.crypto?.randomUUID || !window.fetch) { - return; - } - - let visitorId = window.localStorage.getItem(storageKey); - - if (!visitorId) { - visitorId = window.crypto.randomUUID(); - window.localStorage.setItem(storageKey, visitorId); - } - - window.fetch('https://ping.kirilov.dev/api/v1/ping', { - method: 'POST', - headers: {'Content-Type': 'application/json'}, - body: JSON.stringify({projectKey, visitorId}), - keepalive: true, - }).catch(() => { - // Presence measurement must never interrupt the documentation site. - }); - } catch { - // Storage or browser privacy settings must never interrupt the site. - } -})(); diff --git a/docs/overrides/main.html b/docs/overrides/main.html new file mode 100644 index 0000000..9525f3f --- /dev/null +++ b/docs/overrides/main.html @@ -0,0 +1,10 @@ +{% extends "base.html" %} + +{% block scripts %} + {{ super() }} + +{% endblock %} diff --git a/mkdocs.yml b/mkdocs.yml index b98c251..805648e 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -7,8 +7,7 @@ theme: name: material logo: assets/icon128.png favicon: assets/icon128.png -extra_javascript: - - javascripts/pinger.js + custom_dir: docs/overrides plugins: - search - macros