This commit is contained in:
parent
489701a936
commit
b6e844aa4e
|
@ -15,34 +15,32 @@
|
||||||
enable a manual dark mode toggle. When dark mode support improves I
|
enable a manual dark mode toggle. When dark mode support improves I
|
||||||
can probably remove this again. -->
|
can probably remove this again. -->
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var params = new URLSearchParams(window.location.search)
|
function setMode(mode, val) {
|
||||||
|
if (val) document.body.classList.add(mode)
|
||||||
function setMode(mode, val) {
|
else document.body.classList.remove(mode)
|
||||||
if (val) document.body.classList.add(mode)
|
Array.from(document.querySelectorAll('a'))
|
||||||
else document.body.classList.remove(mode)
|
.filter( el => el.href.indexOf('cosmic.voyage') !== -1)
|
||||||
|
.map( el => {
|
||||||
Array.from(document.querySelectorAll('a'))
|
var url = el.href
|
||||||
.filter( el => el.href.indexOf('cosmic.voyage') !== -1)
|
var p = url.indexOf('?') !== -1 ? url.substr(url.indexOf('?')) : ''
|
||||||
.map( el => {
|
var baseURL = url.split('?')[0]
|
||||||
var url = el.href
|
const params = new URLSearchParams(p)
|
||||||
var p = url.indexOf('?') !== -1 ? url.substr(url.indexOf('?')) : ''
|
if (val) {
|
||||||
var baseURL = url.split('?')[0]
|
params.append(mode, 1)
|
||||||
const params = new URLSearchParams(p)
|
} else {
|
||||||
if (val) {
|
params.delete(mode)
|
||||||
params.append(mode, 1)
|
}
|
||||||
} else {
|
p = params.toString()
|
||||||
params.delete(mode)
|
el.href = baseURL + (p ? '?' + p : '')
|
||||||
}
|
})
|
||||||
p = params.toString()
|
|
||||||
el.href = baseURL + (p ? '?' + p : '')
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
window.addEventListener('DOMContentLoaded', function() {
|
|
||||||
if (params.has('dark')) {
|
|
||||||
setMode('dark', true)
|
|
||||||
} else if (params.has('light')) {
|
|
||||||
setMode('light', true)
|
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
window.addEventListener('DOMContentLoaded', function() {
|
||||||
|
var params = new URLSearchParams(window.location.search)
|
||||||
|
if (params.has('dark')) {
|
||||||
|
setMode('dark', true)
|
||||||
|
} else if (params.has('light')) {
|
||||||
|
setMode('light', true)
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user