Topic de Cattardo :

J'ai fait un script BASH pour print tous mes pseudos qui sont BANNIS :rire:

Le 26 novembre 2023 à 11:45:30 Pulsionnel4 a écrit :

Le 26 novembre 2023 à 10:42:28 :
En powershell :


$ListePseudos = @("pulsionnel","Pulsionnel2","pulsionnel3","Pulsionnel4", "pulsionnel6")

foreach ($pseudo in $ListePseudos){
    try {
        if ((Invoke-WebRequest https://www.jeuxvideo.com/profil/$($pseudo.ToLower())?mode=infos).Content | Select-String "banni") {
            Write-Host "$pseudo : BANNI !" -ForegroundColor Red
        }
        Else {
            Write-Host "$pseudo : OK !" -ForegroundColor Green
        }
    }
    Catch {
        Write-Host "Le pseudo $pseudo : n'existe pas !" -ForegroundColor Gray
    }
}

Ca donne ça : https://image.noelshack.com/fichiers/2023/47/7/1700991692-capture.jpg

Avec une GUI en WPF https://image.noelshack.com/fichiers/2021/04/4/1611841177-ahiahiahi.png


Add-Type -AssemblyName PresentationFramework
Add-Type -AssemblyName System.Windows.Forms

[xml]$xamlmain = @"
<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    Title="Trouve le Pseudo JVC" Height="100" Width="339" WindowStartupLocation="CenterScreen">
    <Grid>
        <StackPanel Orientation="Vertical" HorizontalAlignment="Center">
            <StackPanel Orientation="Horizontal" FlowDirection="LeftToRight">
                <Label Content="Pseudo"/>
                <TextBox Name="TextBoxUser" HorizontalAlignment="Left" Margin="10,10,0,0" Width="150" VerticalAlignment="Top"/>
                <Button IsDefault="True" Name="BoutonSearch" Content="Recherche" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top"/>
            </StackPanel>
        </StackPanel>
    </Grid>
</Window>

"@


# Construction Main
$Global:syncHashMain = [hashtable]::Synchronized(@{})
$readermain = (New-Object System.Xml.XmlNodeReader $xamlmain)
$syncHashMain.Window = [Windows.Markup.XamlReader]::Load( $readermain )
$syncHashMain.Host = $Host

$xamlmain.SelectNodes("//*[@Name]") | ForEach-Object { $syncHashMain.($_.Name) = $syncHashMain.Window.FindName($_.Name) }

$speak = New-Object System.Speech.Synthesis.SpeechSynthesizer


Function CherchePseudo ($pseudo) {
    try {
        if ((Invoke-WebRequest https://www.jeuxvideo.com/profil/$($pseudo.ToLower())?mode=infos).Content | Select-String "banni") {
            Return "$pseudo : BANNI !"
        }
        Else {
            Return "$pseudo : Actif !"
        }
    }
    Catch {
        return "Le pseudo $pseudo : n'existe pas !"
    }
}

$syncHashMain.BoutonSearch.Add_Click({
    if (!$syncHashMain.TextBoxUser.Text) {
        [System.Windows.Forms.MessageBox]::Show("Vous n'avez rien saisi !", "Erreur - Données manquantes", 0, 16)
    }
    else {
        $Global:Utilisateur = CherchePseudo $syncHashMain.TextBoxUser.Text
        if ($Utilisateur -match "BANNI") {
            [System.Windows.Forms.MessageBox]::Show($Utilisateur, "Issou", 0, "warning")
        }
        elseif ($Utilisateur -match "Actif") {
            [System.Windows.Forms.MessageBox]::Show($Utilisateur, "Issou", 0, "Information")
        }
        else {
            [System.Windows.Forms.MessageBox]::Show($Utilisateur, "Issou", 0, "Error")
        }
    }
})


# lancement fenêtre principale
$syncHashMain.Window.ShowDialog() | Out-Null

https://image.noelshack.com/fichiers/2023/47/7/1700995397-capture.jpg
https://image.noelshack.com/fichiers/2023/47/7/1700995453-capture.jpg
https://image.noelshack.com/fichiers/2023/47/7/1700995495-capture.jpg
https://image.noelshack.com/fichiers/2022/37/1/1663014384-ahi-pince-mais.png

https://image.noelshack.com/fichiers/2020/15/5/1586500108-nagui-rogue-choque.png

[09:16:27] <Cattardo>

Le 26 novembre 2023 à 09:16:11 HermioneGrang3r a écrit :

Le 26 novembre 2023 à 09:15:56 :

Le 26 novembre 2023 à 09:15:37 HermioneGrang3r a écrit :
Tu as écris le script bash grâce a ChatGPT ?

en partie oui https://image.noelshack.com/fichiers/2019/33/7/1566153992-madsbiererire.png

Ce flemmard

c'est chiant bash à écrire j'aime pas https://image.noelshack.com/fichiers/2019/33/7/1566153992-madsbiererire.png

Bah bordel c'est pourtant le plus simple :pf:
Quel langage de scripting n'est pas chiant pour toi ?

Le 26 novembre 2023 à 18:32:45 :

[09:16:27] <Cattardo>

Le 26 novembre 2023 à 09:16:11 HermioneGrang3r a écrit :

Le 26 novembre 2023 à 09:15:56 :

Le 26 novembre 2023 à 09:15:37 HermioneGrang3r a écrit :
Tu as écris le script bash grâce a ChatGPT ?

en partie oui https://image.noelshack.com/fichiers/2019/33/7/1566153992-madsbiererire.png

Ce flemmard

c'est chiant bash à écrire j'aime pas https://image.noelshack.com/fichiers/2019/33/7/1566153992-madsbiererire.png

Bah bordel c'est pourtant le plus simple :pf:
Quel langage de scripting n'est pas chiant pour toi ?

bash est un peu relou

La manipulation de variables qui contiennent des espaces fait qu'il faut toujours échaper des \\"

Les immondices complétement non-intuitives pour manipuler les chaines :

Mettre une chaine en minuscules : "${a,,}"

# replace first blank only
bar=${foo/ /.}

# replace all blanks
bar=${foo// /.}
$ foo="re-9619-add-selling-office"
$ variable2=${foo#*-*-}
$ variable1=${foo%-"$variable2"}

Que vaut variable1 et variable2 sans exécuter ?

la rigidité face aux espaces :
if [-z "l" ]; then echo "ok" ; fi bash: [-z : commande introuvable

Les tests dégeulasses :


[  2 > 3 ] && echo "OK" # compare la taille des chaines
OK

les tests avec "-le", "-lt", "-ne", "-e", "-eq" etc... d'un autre temps, bien sûr si tu veux la négation il faut un espace avant et après le "!" sinon ça plante

Ne pas confondre bash avec les programmes gnu écrits en ligne de commande, si tu retires les programmes sed/awk/cut/etc... en bash il te reste le pipe qui est sympa le reste poubelle https://image.noelshack.com/fichiers/2021/04/4/1611841177-ahiahiahi.png

[19:34:00] <fan6b>

Le 26 novembre 2023 à 18:32:45 :

[09:16:27] <Cattardo>

Le 26 novembre 2023 à 09:16:11 HermioneGrang3r a écrit :

Le 26 novembre 2023 à 09:15:56 :

> Le 26 novembre 2023 à 09:15:37 HermioneGrang3r a écrit :

> Tu as écris le script bash grâce a ChatGPT ?

en partie oui https://image.noelshack.com/fichiers/2019/33/7/1566153992-madsbiererire.png

Ce flemmard

c'est chiant bash à écrire j'aime pas https://image.noelshack.com/fichiers/2019/33/7/1566153992-madsbiererire.png

Bah bordel c'est pourtant le plus simple :pf:
Quel langage de scripting n'est pas chiant pour toi ?

bash est un peu relou

La manipulation de variables qui contiennent des espaces fait qu'il faut toujours échaper des \\"

Les immondices complétement non-intuitives pour manipuler les chaines :

Mettre une chaine en minuscules : "${a,,}"

# replace first blank only
bar=${foo/ /.}

# replace all blanks
bar=${foo// /.}
$ foo="re-9619-add-selling-office"
$ variable2=${foo#*-*-}
$ variable1=${foo%-"$variable2"}

Que vaut variable1 et variable2 sans exécuter ?

la rigidité face aux espaces :
if [-z "l" ]; then echo "ok" ; fi bash: [-z : commande introuvable

Les tests dégeulasses :


[  2 > 3 ] && echo "OK" # compare la taille des chaines
OK

les tests avec "-le", "-lt", "-ne", "-e", "-eq" etc... d'un autre temps, bien sûr si tu veux la négation il faut un espace avant et après le "!" sinon ça plante

Ne pas confondre bash avec les programmes gnu écrits en ligne de commande, si tu retires les programmes sed/awk/cut/etc... en bash il te reste le pipe qui est sympa le reste poubelle https://image.noelshack.com/fichiers/2021/04/4/1611841177-ahiahiahi.png

OK Roger mais t'as pas répondu à la question

J'ai fais ça en js perso https://image.noelshack.com/fichiers/2023/47/7/1701030865-capture-d-ecran-2023-11-26-213352.png


(function() {
    'use strict';
    // Check only 4 times per days function
    const toCheck = (account) => {
      if (account.lastCheck === 0) return true
      if (account.lastCheck) {
       const today = new Date
       const lastCheckDate = new Date(account.lastCheck)
       const diff = today.getTime() - lastCheckDate.getTime()
       const days = diff / (1000 * 60 * 60 * 24)
       if (days >= 0.25) return true
       else return false
      }
      return true
    }
    const container = document.querySelector("#forum-right-col")
    if (container == null) return
    container.insertAdjacentHTML("beforeend",`
        <style>
            ul.account-list a {
              font-weight: bold;
            }
            ul.account-list a:not(.checked) {
              opacity: 0.3;
            }
            ul.account-list a.banned {
              color: red!important;
            }
            ul.account-list a.available {
              color: lawngreen!important;
            }
            ul.account-list a.failed {
              color: yellow!important;
            }
            ul.account-list .remove {
              margin-left: 8px;
              font-weight: bold;
            }
            ul.account-list .remove:hover {
              cursor: pointer;
            }
        </style>
    `)
    const bannedAccountsStorage = localStorage.getItem("bannedAccounts")
    let bannedAccounts = bannedAccountsStorage ? JSON.parse(bannedAccountsStorage) : []
    const buildContainer = () => {
     const template = `
       <div id="bannedAccounts" class="card card-jv-forum card-forum-margin">
         <div class="card-header">Comptes</div>
           <div class="card-body">
             <div class="bloc-forums-preferes has-scrollbar">
               <h4 class="titre-info-fofo">Comptes</h4>
                  <ul class="account-list">
                  </ul>
                <h4 class="titre-info-fofo">Ajouter un compte</h4>
                <input id="add-account" class="txt-search" type="text" placeholder="Ajouter un compte" autocomplete="off" value="">
              </div>
           </div>
         </div>
       </div>
     `
     container.insertAdjacentHTML("beforeend",template)
    }
    buildContainer()
    const bannedAccountContainer = document.querySelector("#bannedAccounts")
    const buildAccountList = (accounts) => {
      const list = []
      accounts.forEach(a => {
        list.push(`<li><a name="${a.name}" class="account ${a.status !== "" && !toCheck(a) ? `checked ${a.status}` : ""}" target="_blank" href="https://www.jeuxvideo.com/profil/${a.name.toLowerCase()}?mode=infos">${a.name}</a><span name="${a.name}" class="remove">x</span></li>`)
      })
      bannedAccountContainer.querySelector("ul.account-list").insertAdjacentHTML("beforeend",list.join(""))
    }
    // Manually add from input
    const addAccountInput = document.querySelector("#add-account")
    addAccountInput.addEventListener("keypress", (event) => {
      if (event.keyCode === 13) {
        const value = event.target.value
        const canAdd = value !== "" && bannedAccounts.findIndex(a => a.name === event.target.value) < 0
        const account = {
          name: value,
          lastCheck: 0,
          status: ""
        }
        if (canAdd) {
         buildAccountList([account])
         bannedAccounts.push(account)
         localStorage.setItem("bannedAccounts", JSON.stringify(bannedAccounts))
        }
      }
    })
    // Check account
    const checkAccount = async (account) => {
      const accountEl = document.querySelector(`a[name="${account.name}"]`)
      accountEl.classList.add("checking")
      let getAccountPage = await fetch(`https://www.jeuxvideo.com/profil/${account.name.toLowerCase()}?mode=infos`)
      if (getAccountPage.status === 503) {
        await new Promise(resolve => setTimeout(resolve, 1000))
        getAccountPage = await fetch(getAccountPage)
      }
      if (getAccountPage.status === 503) {
        accountEl.classList.add("failed")
      }
      const pageContent = await getAccountPage.text()
      const parser = new DOMParser()
      const htmlDocument = parser.parseFromString(pageContent, "text/html")
      const bannedBanner = htmlDocument.querySelector(".alert.alert-danger")
      const errorImage = htmlDocument.querySelector("img.img-erreur")
      if (bannedBanner) {
        account.status = "banned"
        accountEl.classList.add("banned")
      } else if (errorImage) {
        account.status = "failed"
        accountEl.classList.add("failed")
      }
      else {
        account.status = "available"
        accountEl.classList.add("available")
      }
      account.lastCheck = Date.now()
      accountEl.classList.add("checked")
      accountEl.classList.remove("checking")
      localStorage.setItem("bannedAccounts", JSON.stringify(bannedAccounts))
    }
    // Observers
    const observer = new MutationObserver((mutations) => {
        for (const mutation of mutations) {
            const el = mutation.target
            const accounts = Array.from(el.querySelectorAll("a"))
            const filteredAccounts = accounts.filter((a) => !a.classList.contains("checked") && !a.classList.contains("checking"))
            if (filteredAccounts.length > 0) {
              filteredAccounts.forEach(a => {
                const accountItem = bannedAccounts.find(aItem => aItem.name == a.name)
                if (accountItem) checkAccount(accountItem)
              })
            }
        }
    });
    observer.observe(bannedAccountContainer.querySelector("ul"), { subtree: false, childList: true, attributes: false });
    // Add from storage
    if (bannedAccounts.length > 0) {
      buildAccountList(bannedAccounts)
    }
    // Remove account
    bannedAccountContainer.addEventListener("click", (event) => {
      if (event.target.classList.contains("remove")) {
        bannedAccounts = bannedAccounts.filter(a => a.name !== event.target.getAttribute("name"))
        localStorage.setItem("bannedAccounts", JSON.stringify(bannedAccounts))
        event.target.parentNode.remove()
      }
    })
})();
Vous êtes de grands malades quand même

Le 26 novembre 2023 à 21:29:52 :

[19:34:00] <fan6b>

Le 26 novembre 2023 à 18:32:45 :

[09:16:27] <Cattardo>

Le 26 novembre 2023 à 09:16:11 HermioneGrang3r a écrit :

> Le 26 novembre 2023 à 09:15:56 :

> > Le 26 novembre 2023 à 09:15:37 HermioneGrang3r a écrit :

> > Tu as écris le script bash grâce a ChatGPT ?

>

> en partie oui https://image.noelshack.com/fichiers/2019/33/7/1566153992-madsbiererire.png

Ce flemmard

c'est chiant bash à écrire j'aime pas https://image.noelshack.com/fichiers/2019/33/7/1566153992-madsbiererire.png

Bah bordel c'est pourtant le plus simple :pf:
Quel langage de scripting n'est pas chiant pour toi ?

bash est un peu relou

La manipulation de variables qui contiennent des espaces fait qu'il faut toujours échaper des \\"

Les immondices complétement non-intuitives pour manipuler les chaines :

Mettre une chaine en minuscules : "${a,,}"

# replace first blank only
bar=${foo/ /.}

# replace all blanks
bar=${foo// /.}
$ foo="re-9619-add-selling-office"
$ variable2=${foo#*-*-}
$ variable1=${foo%-"$variable2"}

Que vaut variable1 et variable2 sans exécuter ?

la rigidité face aux espaces :
if [-z "l" ]; then echo "ok" ; fi bash: [-z : commande introuvable

Les tests dégeulasses :


[  2 > 3 ] && echo "OK" # compare la taille des chaines
OK

les tests avec "-le", "-lt", "-ne", "-e", "-eq" etc... d'un autre temps, bien sûr si tu veux la négation il faut un espace avant et après le "!" sinon ça plante

Ne pas confondre bash avec les programmes gnu écrits en ligne de commande, si tu retires les programmes sed/awk/cut/etc... en bash il te reste le pipe qui est sympa le reste poubelle https://image.noelshack.com/fichiers/2021/04/4/1611841177-ahiahiahi.png

OK Roger mais t'as pas répondu à la question

python de ce fait https://image.noelshack.com/fichiers/2017/13/1490886827-risibo.png

maintenant un script js, le golem

Le 27 décembre 2023 à 18:15:00 zestutuspa a écrit :
maintenant un script js, le golem

Bah fais-le toi-même https://image.noelshack.com/fichiers/2016/38/1474723937-tv9.png

Le 27 décembre 2023 à 18:15:00 :
maintenant un script js, le golem

Il est au dessus... https://image.noelshack.com/fichiers/2018/13/4/1522325846-jesusopti.png

Données du topic

Auteur
Cattardo
Date de création
26 novembre 2023 à 09:12:44
Nb. messages archivés
113
Nb. messages JVC
109
En ligne sur JvArchive 278