const acc=[] tableRoot = document.querySelector('table.properties-table') .querySelectorAll('tbody>tr.ng-scope:not(.ng-hide)>td>input[type="text"]') .forEach(( current,index) => { if (index % 2 === 0) { acc.push({}) acc[acc.length - 1].name = current.value } else { acc[acc.length - 1].value = current.value } }, []) acc.reduce((acc,item)=>{return acc+=item.name+'='+item.value+'\n'},'')