Skip to content

Instantly share code, notes, and snippets.

@burdiuz
Last active December 25, 2018 15:44
Show Gist options
  • Save burdiuz/8ff3f42b621d92cfcaa747ff9eff3f24 to your computer and use it in GitHub Desktop.
Save burdiuz/8ff3f42b621d92cfcaa747ff9eff3f24 to your computer and use it in GitHub Desktop.
GoGoBundle order helper, adds links for keys and titles
((cache={}, list=[]) => {
const fieldsets = document.querySelectorAll('fieldset');
document.body.innerHTML = fieldsets[fieldsets.length - 1].outerHTML;
document.querySelectorAll('table tr td:first-child')
.forEach(item => list.push(item));
document.querySelector('table thead tr').prepend(document.createElement('th'));
list
.reverse()
.filter((item) => {
const title = item.innerText.trim();
if (cache[title]) {
item.parentNode.parentNode.removeChild(item.parentNode);
return false;
} else {
cache[title] = true;
return true;
}
})
.map(item => item.parentNode)
//.reverse()
.forEach((tr) => {
const titleTd = tr.querySelector('td:nth-child(1)');
const codeTd = tr.querySelector('td:nth-child(2)');
const title = titleTd.innerText;
const code = codeTd.innerText;
titleTd.innerHTML = `<a href="https://store.steampowered.com/search/?term=${encodeURIComponent(title).replace(/%20/ig, '+')}" target="_blank">${title}</a>`;
codeTd.innerHTML = `<a href="https://store.steampowered.com/account/registerkey?key=${code}" target="_blank">${code}</a>`;
const td = document.createElement('td');
Object.assign(td.style, {
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
width: '30px',
height: '100%',
margin: '5px 10px',
cursor: 'pointer',
});
td.innerText = ' X ';
td.setAttribute("onclick", "this.parentElement.remove()");
td.setAttribute("onmouseover", "this.style.backgroundColor = '#eee'");
td.setAttribute("onmouseout", "this.style.backgroundColor = 'transparent'");
td.title = 'Remove row';
tr.prepend(td);
});
document.querySelector('body').style.backgroundColor = '#fff';
document.querySelector('body').style.color = '#000';
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment