Skip to content

Instantly share code, notes, and snippets.

@JeffreyPalmer
Last active November 29, 2022 18:51
Show Gist options
  • Save JeffreyPalmer/09b7d95221de8059bd9ff37176b9313c to your computer and use it in GitHub Desktop.
Save JeffreyPalmer/09b7d95221de8059bd9ff37176b9313c to your computer and use it in GitHub Desktop.
Code to save fxhash hashes in local browser storage
<!DOCTYPE html>
<html lang="en">
<head>
<script>
// Put the following code into your index.html
// Store previous hashes
const storedKeys = JSON.parse(localStorage.getItem('fxhashes')) || [];
if (!storedKeys.includes(fxhash)) {
storedKeys.length >= 10 && storedKeys.shift();
storedKeys.push(fxhash);
localStorage.setItem('fxhashes', JSON.stringify(storedKeys));
}
localStorage.setItem('prevHash', localStorage.getItem('fxhash'));
localStorage.setItem('fxhash', fxhash);
</script>
</head>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment