Skip to content

Instantly share code, notes, and snippets.

@marcimat
Last active February 28, 2025 17:23
Show Gist options
  • Select an option

  • Save marcimat/ac445eb0f27f6ed01f7064f83631f86a to your computer and use it in GitHub Desktop.

Select an option

Save marcimat/ac445eb0f27f6ed01f7064f83631f86a to your computer and use it in GitHub Desktop.
Altered TCG : Donner toute sa collection à un ami… Très lent… mais plus pratique que de le faire à la main…
// - Dans un navigateur, se connecter à https://www.altered.gg
// - Se mettre sur sa collection.
// - ex: https://www.altered.gg/fr-fr/cards?collection=true
// Lancer en console (click droit > inspecter > console, coller le code suivant)
// - Observer...
// /!\ Donne au premier ami avec ce code. Adapter éventuellement !
// /!\ Sujet à changement dans le code HTML d’Altered…
// Si ça peut servir à d’autres…
var sleep = ms => () => new Promise((resolve, reject) => window.setTimeout(resolve, ms));
var run = function() {
Promise.resolve()
// Le premier de ma collection
.then(() => {
console.log('run...');
document.querySelector('[data-nimg]').click();
})
.then(sleep(500))
.then(() => { document.querySelector('.fixed .pointer-events-auto a').click(); })
.then(sleep(2000))
// Bouton donner
.then(() => { document.querySelector('main ul li:nth-child(3) button').click(); })
.then(sleep(300))
// Sélection du destinaitaire
.then(() => { document.querySelector('input[aria-label="Destinataire"]').click(); })
.then(sleep(400))
// Le premier ami de la liste
.then(() => { document.querySelector('div[data-state="suggesting"] li:first-child span').click(); })
.then(sleep(300))
// Changer la quantité pour le maxi
.then(() => {
let qte = document.querySelector('#quantity');
let n = qte.closest('.flex').nextSibling.querySelector('.md-bold').textContent.substr(2);
let nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, "value").set;
nativeInputValueSetter.call(qte, n);
qte.dispatchEvent(new Event('input', { bubbles: true}));
})
.then(sleep(300))
// Valider
.then(() => { document.querySelector('fieldset.contents > .flex button').click(); })
.then(sleep(5000))
// Revenir sur sa collection
.then(() => { document.querySelector('main .flex-col-reverse a:nth-child(2)').click(); })
.then(() => console.log('End... Wait to reload the Collection'))
.then(sleep(3000))
.then(run);
}
run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment