Skip to content

Instantly share code, notes, and snippets.

@tpai
Last active February 12, 2019 08:03
Show Gist options
  • Save tpai/fb0d6b14f96cda6824ee6c62be275d8d to your computer and use it in GitHub Desktop.
Save tpai/fb0d6b14f96cda6824ee6c62be275d8d to your computer and use it in GitHub Desktop.
const root = document.querySelector('#kolor-kolor');
const rootObserver = new MutationObserver((mutations) => mutations.map(mutation => {
[].slice.call(document.querySelectorAll('#kolor-options li a')).map((option) => {
if (option.style.backgroundColor === mutation.target.style.backgroundColor) {
option.click();
}
});
}));
rootObserver.observe(root, {
attributes: true,
attributeFilter: ['style']
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment