Skip to content

Instantly share code, notes, and snippets.

@dmstern
Created January 12, 2019 11:10
Show Gist options
  • Save dmstern/9b013e9b736580fdbe31b0dcb704ab12 to your computer and use it in GitHub Desktop.
Save dmstern/9b013e9b736580fdbe31b0dcb704ab12 to your computer and use it in GitHub Desktop.
function createElementFromHTML(htmlString) {
var div = document.createElement('div');
div.innerHTML = htmlString.trim();
return div.firstChild;
}
const markup = `
<span>
<style>
data-testid="reaction_facepalm" {
background: '#67a22d';
border-radius: 50%;
}
data-testid="reaction_facepalm":hover {
transform(scale(1.1))
}
</style>
<span aria-pressed="false" aria-label="Facepalm" class="_iuw _iuy" data-testid="reaction_facepalm" href="#" role="button" tabindex="-1">
<div class="_39m _1ef2" data-reaction="facepalm">
<div class="_39n">
<div class="_1ef0" style="display: inline-block; line-height: 0; font-size: 0px;">
<img width="39" height="39" src="https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/120/facebook/158/face-palm_1f926.png" style="width: 39px; height: 39px;">
</div>
<div class="_d6l">
<div class="_4sm1">Facepalm</div>
</div>
</div>
</div>
</span>
</span>`;
const element = createElementFromHTML(markup);
const reactionMenu = document.querySelector('[data-testid="UFIReactionsMenu"]');
reactionMenu.append(element);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment