Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save yarkovaleksei/3f201bc8ed1a9ac1b4548e733eb841ba to your computer and use it in GitHub Desktop.
Save yarkovaleksei/3f201bc8ed1a9ac1b4548e733eb841ba to your computer and use it in GitHub Desktop.
(function(){
const links = document.querySelectorAll('a.comment__reply[href^="#mention"]');
for (let i = 0; i < links.length; i++) {
let link = links[i];
let login = link.dataset.username;
let parent = link.parentElement;
let form = parent.parentElement.parentElement.parentElement.nextElementSibling;
let textarea = form.querySelector('textarea.form__input');
let submit = form.querySelector('button[type="submit"]');
let plusButton = document.createElement('a');
plusButton.href = "#";
plusButton.className = "toster-plus-one";
plusButton.innerHTML = "+1";
plusButton.onclick = function(e) {
e.preventDefault();
let val = textarea.value;
textarea.value = `@${login}: +1 ${val}`;
submit.disabled = "";
}
parent.appendChild(plusButton);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment