use store instead of localStorage to disable GoatCounter

This commit is contained in:
Son NK 2020-02-05 14:30:27 +07:00
parent 54e4f5e721
commit b40278f4dc
2 changed files with 5 additions and 2 deletions

View File

@ -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");

View File

@ -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;
}