Skip to content

Instantly share code, notes, and snippets.

@behcet
Created May 4, 2016 19:39
Show Gist options
  • Save behcet/5f1f195596060f28ecf238c85039c2b2 to your computer and use it in GitHub Desktop.
Save behcet/5f1f195596060f28ecf238c85039c2b2 to your computer and use it in GitHub Desktop.
function getAchievements (dom) {
return Array.prototype.map.call(dom.querySelectorAll('table.data div.Achievement'), function (a) {
return a.classList.value.match(/Achievement_(\d+)/).shift();
});
}
function removeOverlapping (ach1, ach2) {
var table = document.querySelector('table.data');
ach1.forEach(function (a) {
if (ach2.indexOf(a) < 0) {
return;
}
var el = table.getElementsByClassName(a);
if (el.length < 1) {
return;
}
el = el[0].parentNode.parentNode;
el.parentNode.removeChild(el);
});
}
jQuery
.get(document.location.href.replace(/\/\d+$/, ''))
.then(function (res) {
var resDom = document.createElement('div');
resDom.innerHTML = res.replace(/<script(.|\s)*?\/script>/ig, '');
removeOverlapping(
getAchievements(document),
getAchievements(resDom));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment