Как достать текст из элемента:
const getText = el => el.textContent;
// или
const getText = el => el.innerText;
// или
const getText = el => el.innerHTML;
// или
const getText = el => el.lastChild.nodeValue;
// или
const getText = el => el.childNodes[0].data;
Как вырезать из текста нужный кусок:
const getValue = text => text.match(/"(.*?)"/)[1];
// или
const getValue = text => text.split('"').slice(-2).shift();
// или
const getValue = text => text.replace(/^.*?"|"[^"]*$/g, '');
//
const getValue = text => `${/(?<=")[^"]+/.exec(text)}`;
// или
const getValue = text =>
JSON.parse(text.slice(-~text.indexOf('['), text.indexOf(']')));
Как обработать клики:
document.querySelectorAll('li button').forEach(function(n) {
n.addEventListener('click', this);
}, e => console.log(getValue(getText(e.target))));
// или
document.querySelector('ul').addEventListener('click', ({ target: t }) => {
if (t.tagName === 'BUTTON') {
console.log(getValue(getText(t)));
}
});