diff options
| author | tdro <tdro@noreply.example.com> | 2024-07-25 00:00:00 +0000 |
|---|---|---|
| committer | tdro <tdro@noreply.example.com> | 2024-07-25 00:00:00 +0000 |
| commit | 32cef1ba4c087df0324d0a4331894ad879382d2d (patch) | |
| tree | 7599128535c6cf17dda48c527eb0c3f781d6c7cd | |
| parent | 687c69af8d86b5787467dc5acaa6dc334fc1ba57 (diff) | |
| download | canory-32cef1ba4c087df0324d0a4331894ad879382d2d.tar.gz canory-32cef1ba4c087df0324d0a4331894ad879382d2d.tar.bz2 canory-32cef1ba4c087df0324d0a4331894ad879382d2d.zip | |
static/js: Streamline cookie restrictions
| -rw-r--r-- | assets/js/index.js | 28 | ||||
| -rw-r--r-- | static/js/autoplay.ts | 5 | ||||
| -rw-r--r-- | static/js/domfilter.ts | 5 | ||||
| -rw-r--r-- | static/js/forms.ts | 6 | ||||
| -rw-r--r-- | static/js/infinitescroll.ts | 6 | ||||
| -rw-r--r-- | static/js/pager.ts | 6 | ||||
| -rw-r--r-- | static/js/update.ts | 6 |
7 files changed, 22 insertions, 40 deletions
diff --git a/assets/js/index.js b/assets/js/index.js index 962f093..f89624b 100644 --- a/assets/js/index.js +++ b/assets/js/index.js @@ -1,10 +1,6 @@ (function() { const cookiesDisabled = !navigator.cookieEnabled; - if (cookiesDisabled) { - document.cookie = "disabled"; - document.cookie.indexOf("disabled"); - return console.warn("WARNING: Pager disabled due to cookie restrictions"); - } + if (cookiesDisabled) return console.warn("WARNING: Pager disabled due to cookie restrictions"); let seek; let pager = {}; const key = "config.scroll.pager.urls"; @@ -95,11 +91,7 @@ })(); (function() { const cookiesDisabled = !navigator.cookieEnabled; - if (cookiesDisabled) { - document.cookie = "disabled"; - document.cookie.indexOf("disabled"); - return console.warn("WARNING: Update check disabled due to cookie restrictions"); - } + if (cookiesDisabled) return console.warn("WARNING: Update check disabled due to cookie restrictions"); function fetch(url, method, callback) { const http = new XMLHttpRequest(); http.onreadystatechange = function() { @@ -508,6 +500,8 @@ }); })(); (function() { + const cookiesDisabled = !navigator.cookieEnabled; + if (cookiesDisabled) return console.warn("WARNING: Autoplay control disabled due to cookie restrictions"); function viewport(element) { const options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : { offset: { @@ -596,11 +590,7 @@ })(); (function() { const cookiesDisabled = !navigator.cookieEnabled; - if (cookiesDisabled) { - document.cookie = "disabled"; - document.cookie.indexOf("disabled"); - return console.warn("WARNING: Cannot persist form state due to cookie restrictions"); - } + if (cookiesDisabled) return console.warn("WARNING: Form state cannot persist due to cookie restrictions"); const storage = document.createEvent("Event"); storage.initEvent("storage", true, true); [ @@ -701,6 +691,8 @@ }); })(); (function() { + const cookiesDisabled = !navigator.cookieEnabled; + if (cookiesDisabled) return console.warn("WARNING: DOM filter disabled due to cookie restrictions"); const timeout = 300; const state = "on"; const key = "config.navigation.fast"; @@ -804,11 +796,7 @@ })(); (function() { const cookiesDisabled = !navigator.cookieEnabled; - if (cookiesDisabled) { - document.cookie = "disabled"; - document.cookie.indexOf("disabled"); - return console.warn("WARNING: Native pagination fallback due to cookie restrictions"); - } + if (cookiesDisabled) return console.warn("WARNING: Native pagination fallback due to cookie restrictions"); function fetch(url, method, callback, fallback) { const http = new XMLHttpRequest(); http.onreadystatechange = function() { diff --git a/static/js/autoplay.ts b/static/js/autoplay.ts index 9a47c2e..ce11215 100644 --- a/static/js/autoplay.ts +++ b/static/js/autoplay.ts @@ -1,4 +1,9 @@ (function () { + + const cookiesDisabled = !navigator.cookieEnabled; + + if (cookiesDisabled) return console.warn("WARNING: Autoplay control disabled due to cookie restrictions"); + function viewport(element) { const options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : { offset: { top: -50, left: 0, bottom: -50, right: 0 } diff --git a/static/js/domfilter.ts b/static/js/domfilter.ts index 8900e2f..c972bf1 100644 --- a/static/js/domfilter.ts +++ b/static/js/domfilter.ts @@ -4,6 +4,11 @@ */ (function () { + + const cookiesDisabled = !navigator.cookieEnabled; + + if (cookiesDisabled) return console.warn("WARNING: DOM filter disabled due to cookie restrictions"); + type millisecond = number; const timeout: millisecond = 300; diff --git a/static/js/forms.ts b/static/js/forms.ts index 263fda1..958cc9f 100644 --- a/static/js/forms.ts +++ b/static/js/forms.ts @@ -2,11 +2,7 @@ const cookiesDisabled = !navigator.cookieEnabled; - if (cookiesDisabled) { - document.cookie = "disabled"; - document.cookie.indexOf("disabled"); - return console.warn("WARNING: Cannot persist form state due to cookie restrictions"); - } + if (cookiesDisabled) return console.warn("WARNING: Form state cannot persist due to cookie restrictions"); const storage = document.createEvent("Event"); storage.initEvent("storage", true, true); diff --git a/static/js/infinitescroll.ts b/static/js/infinitescroll.ts index 88d9828..50eb91c 100644 --- a/static/js/infinitescroll.ts +++ b/static/js/infinitescroll.ts @@ -1,11 +1,7 @@ (function () { const cookiesDisabled = !navigator.cookieEnabled; - if (cookiesDisabled) { - document.cookie = "disabled"; - document.cookie.indexOf("disabled"); - return console.warn("WARNING: Native pagination fallback due to cookie restrictions"); - } + if (cookiesDisabled) return console.warn("WARNING: Native pagination fallback due to cookie restrictions"); type percent = number; diff --git a/static/js/pager.ts b/static/js/pager.ts index ebaf67a..89d2394 100644 --- a/static/js/pager.ts +++ b/static/js/pager.ts @@ -1,11 +1,7 @@ (function () { const cookiesDisabled = !navigator.cookieEnabled; - if (cookiesDisabled) { - document.cookie = "disabled"; - document.cookie.indexOf("disabled"); - return console.warn("WARNING: Pager disabled due to cookie restrictions"); - } + if (cookiesDisabled) return console.warn("WARNING: Pager disabled due to cookie restrictions"); let seek; let pager = {}; diff --git a/static/js/update.ts b/static/js/update.ts index df29f49..f6461eb 100644 --- a/static/js/update.ts +++ b/static/js/update.ts @@ -2,11 +2,7 @@ const cookiesDisabled = !navigator.cookieEnabled; - if (cookiesDisabled) { - document.cookie = "disabled"; - document.cookie.indexOf("disabled"); - return console.warn("WARNING: Update check disabled due to cookie restrictions"); - } + if (cookiesDisabled) return console.warn("WARNING: Update check disabled due to cookie restrictions"); function fetch(url, method, callback) { const http = new XMLHttpRequest(); |
