Skip to content

Commit e51ee7e

Browse files
author
Jacek Gębal
committed
Update cookie settings to use a shared cookie across pages.
1 parent f834de1 commit e51ee7e

3 files changed

Lines changed: 28 additions & 16 deletions

File tree

docs/assets/topbar.js

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -293,22 +293,6 @@
293293
rewriteFeedbackLink();
294294
}
295295

296-
/*This intercepts every localStorage.getItem/setItem call — no matter which version path Material constructs as the key,
297-
it always reads and writes /__consent. One consent covers all versions. */
298-
var _get = Storage.prototype.getItem;
299-
var _set = Storage.prototype.setItem;
300-
var SHARED_KEY = '/__consent';
301-
302-
Storage.prototype.getItem = function (key) {
303-
if (key && key.endsWith('.__consent')) return _get.call(this, SHARED_KEY);
304-
return _get.call(this, key);
305-
};
306-
307-
Storage.prototype.setItem = function (key, value) {
308-
if (key && key.endsWith('.__consent')) { _set.call(this, SHARED_KEY, value); return; }
309-
_set.call(this, key, value);
310-
};
311-
312296
/* Hide Material's built-in header controls immediately to prevent a flash
313297
where logo/palette appear before the topbar is painted. */
314298
ensureStyle();

docs/overrides/main.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,19 @@
77
{% block extrahead %}
88
{{ super() }}
99
<script>
10+
(function () {
11+
var _get = Storage.prototype.getItem;
12+
var _set = Storage.prototype.setItem;
13+
var SHARED_KEY = '/__consent';
14+
Storage.prototype.getItem = function (key) {
15+
if (key && key.endsWith('.__consent')) return _get.call(this, SHARED_KEY);
16+
return _get.call(this, key);
17+
};
18+
Storage.prototype.setItem = function (key, value) {
19+
if (key && key.endsWith('.__consent')) { _set.call(this, SHARED_KEY, value); return; }
20+
_set.call(this, key, value);
21+
};
22+
})();
1023
window.utplsqlBaseUrl = "{{ config.site_url }}";
1124
document.documentElement.setAttribute('data-utplsql-site', 'org');
1225
</script>

site-template/overrides/main.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,21 @@
77

88
{% block extrahead %}
99
{{ super() }}
10+
<script>
11+
(function () {
12+
var _get = Storage.prototype.getItem;
13+
var _set = Storage.prototype.setItem;
14+
var SHARED_KEY = '/__consent';
15+
Storage.prototype.getItem = function (key) {
16+
if (key && key.endsWith('.__consent')) return _get.call(this, SHARED_KEY);
17+
return _get.call(this, key);
18+
};
19+
Storage.prototype.setItem = function (key, value) {
20+
if (key && key.endsWith('.__consent')) { _set.call(this, SHARED_KEY, value); return; }
21+
_set.call(this, key, value);
22+
};
23+
})();
24+
</script>
1025
<link rel="stylesheet" href="https://www.utplsql.org/assets/topbar.css">
1126
<script src="https://www.utplsql.org/assets/topbar.js" defer></script>
1227
{% endblock %}

0 commit comments

Comments
 (0)