|
293 | 293 | rewriteFeedbackLink(); |
294 | 294 | } |
295 | 295 |
|
296 | | - /* Re-set the mkdocs-material consent cookie at path=/ so it is shared across |
297 | | - all versioned subdirectories. Without this the browser scopes it to the |
298 | | - current version path (e.g. /v3.1.14/) and the banner reappears on every |
299 | | - other version. Runs immediately so it beats Material's consent check. */ |
300 | | - /* Propagate mkdocs-material consent across versioned subdirectories. |
301 | | - Each version stores consent in localStorage under its own base-path key |
302 | | - (e.g. /utPLSQL/develop/.__consent). Copy a non-empty consent from any |
303 | | - other version into the current version's key before Material checks it. */ |
304 | | - var CONSENT_SUFFIX = '.__consent'; |
305 | | - var currentConsentKey = location.pathname + CONSENT_SUFFIX; |
306 | | - if (!localStorage.getItem(currentConsentKey)) { |
307 | | - for (var i = 0; i < localStorage.length; i++) { |
308 | | - var k = localStorage.key(i); |
309 | | - if (k && k !== currentConsentKey && k.endsWith(CONSENT_SUFFIX)) { |
310 | | - var val = localStorage.getItem(k); |
311 | | - if (val && val !== '{}') { |
312 | | - localStorage.setItem(currentConsentKey, val); |
313 | | - break; |
314 | | - } |
315 | | - } |
316 | | - } |
317 | | - } |
| 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 | + }; |
318 | 311 |
|
319 | 312 | /* Hide Material's built-in header controls immediately to prevent a flash |
320 | 313 | where logo/palette appear before the topbar is painted. */ |
|
0 commit comments