Dark mode

pull/1/head
Swissky 2022-09-30 16:46:02 +02:00
parent 3f4feb1fe5
commit 6ea6af186f
3 changed files with 39 additions and 3 deletions

35
_includes/dark-mode.html Executable file
View File

@ -0,0 +1,35 @@
<script>
document.getElementsByClassName('dark-mode-button')[0].onclick = function() {
darkmode()
}
function darkmode() {
let enabled = localStorage.getItem('dark-mode')
if (enabled === null) {
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
enable();
}
} else if (enabled === 'true') {
enable()
}
if (localStorage.getItem('dark-mode') === 'false') {
enable();
} else {
disable();
}
function enable() {
DarkReader.setFetchMethod(window.fetch)
DarkReader.enable();
localStorage.setItem('dark-mode', 'true');
}
function disable() {
DarkReader.disable();
localStorage.setItem('dark-mode', 'false');
}
}
</script>
<script src="https://cdn.jsdelivr.net/npm/darkreader@4.9.44/darkreader.js"></script>

View File

@ -33,9 +33,11 @@
<a href="{{ site.baseurl }}/summary">📝Posts</a>
<a href="https://swisskyrepo.github.io/PayloadsAllTheThingsWeb/">📖PayloadsAllTheThings</a>
<a href="https://swisskyrepo.github.io/HardwareAllTheThings/">🖥HardwareAllTheThings</a>
<a href="{{ site.baseurl }}/about">👤About</a>
<a class="dark-mode-button" >🌗</a>
</nav>
{% include dark-mode.html %}
</header>
</div>
</div>

View File

@ -5,10 +5,9 @@ title: Offensive Nim - Auto Obfuscate Strings with Nim's Term-Rewriting Macros
TLDR: Use `nim-strenc`, or read below to discover how to write your own Nim macro.
<!--more-->
Lately I discovered the repository [Yardanico/nim-strenc](https://github.com/Yardanico/nim-strenc), you can use it very easily in your Nim code by importing `strenc`.
Let's try it on this simple example. First you need to install the package using this command: `nimble install strenc`
<!--more-->
{% highlight py%}
import strenc