Browse Source

use store instead of localStorage to disable GoatCounter

Son NK 5 years ago
parent
commit
b40278f4dc
2 changed files with 5 additions and 2 deletions
  1. 3 1
      server.py
  2. 2 1
      templates/base.html

+ 3 - 1
server.py

@@ -412,10 +412,12 @@ def setup_do_not_track(app):
     @app.route("/dnt")
     def do_not_track():
         return """
+        <script src="/static/local-storage-polyfill.js"></script>
+        
         <script>
 // Disable GoatCounter if this script is called
 
-window.localStorage.setItem('goatcounter-ignore', 't');
+store.set('goatcounter-ignore', 't');
 
 alert("GoatCounter disabled");
 

+ 2 - 1
templates/base.html

@@ -174,6 +174,7 @@
 {% block script %}
 {% endblock %}
 
+<script src="/static/local-storage-polyfill.js"></script>
 <script>
   (function () {
     // only enable on prod
@@ -182,7 +183,7 @@
       return;
     }
 
-    if (localStorage.getItem('goatcounter-ignore') === 't') {
+    if (store.get('goatcounter-ignore') === 't') {
       console.log("GoatCounter is disabled");
       return;
     }