From 32e65cf3e8e90453412d5f7ecf884aeacc3d9014 Mon Sep 17 00:00:00 2001 From: Jonah Aragon Date: Sun, 26 May 2024 08:06:42 +0000 Subject: [PATCH] fix: Remove device detection JS (#2576) Signed-off-by: Daniel Gray --- docs/about/statistics.md | 13 +++-- includes/strings.en.env | 5 -- mkdocs.yml | 20 ------- theme/assets/javascripts/resolution.js | 78 ------------------------- theme/partials/copyright.html | 3 - theme/partials/javascripts/consent.html | 1 - 6 files changed, 7 insertions(+), 113 deletions(-) delete mode 100644 theme/assets/javascripts/resolution.js delete mode 100644 theme/partials/javascripts/consent.html diff --git a/docs/about/statistics.md b/docs/about/statistics.md index 9ddb79b3..1dc31186 100644 --- a/docs/about/statistics.md +++ b/docs/about/statistics.md @@ -2,13 +2,14 @@ title: Traffic Statistics --- -We self-host [Umami](https://umami.is) to create a nice visualization of our traffic statistics, which are public at the link below. With this process: +We self-host [Umami](https://umami.is) to create a nice visualization of our traffic statistics, which are public at the link below. + +[View Statistics](https://stats.privacyguides.net/share/nVWjyd2QfgOPBhMF/www.privacyguides.org){ .md-button .md-button--primary } + +With this process: - Your information is never shared with a third-party, it stays on servers we control - Your personal data is never saved, we only collect data in aggregate -- No client-side JavaScript is required +- No client-side JavaScript is used -Because of these facts, keep in mind our statistics may be inaccurate. It is a useful tool to compare different dates with each other and analyze overall trends, but the actual numbers may be far off from reality. They're *precise* statistics, but not *accurate* statistics. - -[View Statistics](https://stats.privacyguides.net/share/nVWjyd2QfgOPBhMF/www.privacyguides.org){ .md-button .md-button--primary } -[Opt-Out](#__consent){ .md-button } +Because of these facts, keep in mind our statistics may be inaccurate. It is a useful tool to compare different dates with each other and analyze overall trends, but the actual numbers may be far off from reality. In other words they're *precise* statistics, but not *accurate* statistics. diff --git a/includes/strings.en.env b/includes/strings.en.env index 4e4e6730..1181544a 100644 --- a/includes/strings.en.env +++ b/includes/strings.en.env @@ -1,14 +1,9 @@ -ANALYTICS_CONSENT_BODY="We collect anonymous statistics about your visits to help us improve the site. We do not track you across other websites. If you disable this, we will not know when you have visited our site. We will save a single cookie in your browser to remember your preference." -ANALYTICS_CONSENT_TITLE="Contribute anonymous statistics" -ANALYTICS_COOKIE_GITHUB="GitHub API" -ANALYTICS_COOKIE_UMAMI="Self-Hosted Analytics" ANALYTICS_FEEDBACK_NEGATIVE_NAME="This page could be improved" ANALYTICS_FEEDBACK_NEGATIVE_NOTE='Thanks for your feedback! If you want to let us know more, please leave a post on our forum.' ANALYTICS_FEEDBACK_POSITIVE_NAME="This page was helpful" ANALYTICS_FEEDBACK_POSITIVE_NOTE="Thanks for your feedback!" ANALYTICS_FEEDBACK_TITLE="Was this page helpful?" DESCRIPTION_HOMEPAGE="A socially motivated website which provides information about protecting your online data privacy and security." -FOOTER_ANALYTICS="Anonymous statistics preferences." FOOTER_COPYRIGHT_AUTHOR="Privacy Guides and contributors." FOOTER_INTRO="Privacy Guides is a non-profit, socially motivated website that provides information for protecting your data security and privacy." FOOTER_NOTE="We do not make money from recommending certain products, and we do not use affiliate links." diff --git a/mkdocs.yml b/mkdocs.yml index 4f73daca..82184bd8 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -56,7 +56,6 @@ extra: - fontawesome/brands/creative-commons - fontawesome/brands/creative-commons-by - fontawesome/brands/creative-commons-sa - analytics: !ENV [FOOTER_ANALYTICS, "Anonymous statistics preferences."] homepage: description: !ENV [ @@ -235,24 +234,6 @@ extra: data: 0 note: !ENV [ANALYTICS_FEEDBACK_NEGATIVE_NOTE, "Thanks for your feedback!"] - consent: - title: !ENV [ANALYTICS_CONSENT_TITLE, "Contribute anonymous statistics"] - description: - !ENV [ - ANALYTICS_CONSENT_BODY, - "We use cookies to collect anonymous usage statistics. You can opt out if you wish.", - ] - cookies: - analytics: - name: !ENV [ANALYTICS_COOKIE_UMAMI, "Self-Hosted Analytics"] - checked: true - github: - name: !ENV [ANALYTICS_COOKIE_GITHUB, "GitHub API"] - checked: true - actions: - - reject - - accept - - manage repo_url: !ENV [BUILD_REPO_URL, "https://github.com/privacyguides/privacyguides.org"] @@ -303,7 +284,6 @@ extra_css: - assets/stylesheets/extra.css?v=2 extra_javascript: - assets/javascripts/randomize-element.js?v=1 - - assets/javascripts/resolution.js?v=1 - assets/javascripts/feedback.js?v=1 watch: diff --git a/theme/assets/javascripts/resolution.js b/theme/assets/javascripts/resolution.js deleted file mode 100644 index 478184ac..00000000 --- a/theme/assets/javascripts/resolution.js +++ /dev/null @@ -1,78 +0,0 @@ -function setCookie(cname, cvalue, exdays) { - const d = new Date(); - d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); - let expires = "expires="+d.toUTCString(); - document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; -} - -function getCookie(cname) { - let name = cname + "="; - let ca = document.cookie.split(';'); - for(let i = 0; i < ca.length; i++) { - let c = ca[i]; - while (c.charAt(0) == ' ') { - c = c.substring(1); - } - if (c.indexOf(name) == 0) { - return c.substring(name.length, c.length); - } - } - return ""; -} - -var consent = __md_get("__consent") -if (!consent) { - __md_set("__consent", {"analytics":true,"github":true}); - if (getCookie('resolution') == '') { - const resolution = `${window.screen.width}x${window.screen.height}`; - setCookie('resolution', resolution, 30); - } -} - -if (consent && consent.analytics) { - if (getCookie('resolution') == '') { - const resolution = `${window.screen.width}x${window.screen.height}`; - setCookie('resolution', resolution, 30); - } - setCookie('umami', 'true', 0); -} else { - setCookie('umami', 'false', 365); - setCookie('resolution', "0x0", 0); -} - -var consent = __md_get("__consent") -if (consent) { - for (var input of document.forms.consent.elements) - if (input.name) - input.checked = consent[input.name] || false - -/* Show consent with a small delay, but not if browsing locally */ -} else if (location.protocol !== "file:") { -setTimeout(function() { - var el = document.querySelector("[data-md-component=consent]") - el.hidden = false -}, 250) -} - -/* Intercept submission of consent form */ -var form = document.forms.consent -for (var action of ["submit", "reset"]) -form.addEventListener(action, function(ev) { - ev.preventDefault() - - /* Reject all cookies */ - if (ev.type === "reset") - for (var input of document.forms.consent.elements) - if (input.name) - input.checked = false - - /* Grab and serialize form data */ - __md_set("__consent", Object.fromEntries( - Array.from(new FormData(form).keys()) - .map(function(key) { return [key, true] }) - )) - - /* Remove anchor to omit consent from reappearing and reload */ - location.hash = ''; - location.reload() -}) diff --git a/theme/partials/copyright.html b/theme/partials/copyright.html index 10ce13ac..0e57b407 100644 --- a/theme/partials/copyright.html +++ b/theme/partials/copyright.html @@ -35,9 +35,6 @@ {% endfor %} {{ copyright.copyright.date }} {{ copyright.copyright.author }} - - {{ copyright.analytics }} - {% endif %} diff --git a/theme/partials/javascripts/consent.html b/theme/partials/javascripts/consent.html deleted file mode 100644 index 106c22c2..00000000 --- a/theme/partials/javascripts/consent.html +++ /dev/null @@ -1 +0,0 @@ -