Skip to content

Instantly share code, notes, and snippets.

@hsuanxyz
Created October 16, 2018 02:38
Show Gist options
  • Save hsuanxyz/6369932d31b8138eb502d59fa2dcbae7 to your computer and use it in GitHub Desktop.
Save hsuanxyz/6369932d31b8138eb502d59fa2dcbae7 to your computer and use it in GitHub Desktop.
Google Translate Phrasebook Clean
function clean() {
const wordEles = [...document.querySelectorAll('.gt-pb-stc')];
const repeats = [];
wordEles.forEach((e, i) => {
const isRepeat = [...wordEles].splice(i + 1, wordEles.length - 1).some(s => {
return s.innerText.toLocaleLowerCase() === e.innerText.toLocaleLowerCase()
});
if (isRepeat) {
repeats.push(e);
}
})
repeats.forEach(e => {
e.parentNode.parentNode.querySelector('.pb-cb > span').click();
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment