Skip to content

Instantly share code, notes, and snippets.

@sitek94
Last active June 1, 2023 19:04
Show Gist options
  • Save sitek94/e39106c9a28204fc7616458f5d9bf14c to your computer and use it in GitHub Desktop.
Save sitek94/e39106c9a28204fc7616458f5d9bf14c to your computer and use it in GitHub Desktop.
Boost for Ahoy community to toggle focus mode
const styles = {
position: "fixed",
inset: 0,
zIndex: 99999,
overflowY: 'auto',
height: "100vh",
width: "100vw",
colorScheme: 'dark'
}
const toggleStyles = (() => {
let shouldApplyStyles = true;
return (element) => {
for (const [property, value] of Object.entries(styles)) {
element.style[property] = shouldApplyStyles ? value : 'unset';
}
shouldApplyStyles = !shouldApplyStyles;
}
})();
document.addEventListener('keydown', (event) => {
// 👇👇👇 CHANGE SHORTCUT HERE
if (event.ctrlKey && event.key === '=') {
const main = document.querySelector('div.main');
toggleStyles(main);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment