Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
88c16568fb | ||
|
|
f92b8d08f0 | ||
|
|
ceca0013b8 | ||
|
|
483b2436e6 |
No files matched your search
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# .gitea/scripts/prova-immagine.sh <immagine> [esecuzione]
|
||||
#
|
||||
# 1. Chromium della distribuzione risponde e /app/Mimante.dll c'è;
|
||||
# 1. /app/Mimante.dll c'è e Chromium no (la sessione si incolla, ADR 0017);
|
||||
# 2. il contenitore parte come dice il modello Unraid (PUID/PGID predefiniti, /config), le migrazioni passano, il
|
||||
# controllo di salute dell'immagine diventa «healthy» e «--salute» risponde;
|
||||
# 3. i file scritti in /config sono dell'utente 99:100, come serve alla share appdata di Unraid;
|
||||
@@ -43,9 +43,9 @@ registro() {
|
||||
docker logs --tail 80 "$nome" >&2 || true
|
||||
}
|
||||
|
||||
echo "== Chromium e programma"
|
||||
docker run --rm --network none "${segno[@]}" --entrypoint /usr/bin/chromium "$immagine" --version
|
||||
echo "== Programma, senza browser"
|
||||
docker run --rm --network none "${segno[@]}" --entrypoint sh "$immagine" -c 'test -s /app/Mimante.dll && echo "/app/Mimante.dll presente"'
|
||||
docker run --rm --network none "${segno[@]}" --entrypoint sh "$immagine" -c 'test ! -e /usr/bin/chromium && echo "nessun Chromium nell immagine"'
|
||||
|
||||
echo "== Rete interna e PostgreSQL usa e getta"
|
||||
docker network create --internal "${segno[@]}" "$rete" > /dev/null
|
||||
|
||||
@@ -38,6 +38,16 @@ copia nella release la sezione della versione.
|
||||
il primo accredito non si vede nel saldo, tetti per giro e per giorno, solo nelle ore scelte, pausa da
|
||||
sola se Bidoo chiede una verifica. Si può anche incollare un collegamento e riscattarlo subito. I
|
||||
forzieri si segnalano su Telegram, non si aprono.
|
||||
- **Grafica nuova, sulla linea di Febe** (ADR 0016): grigio caldo, carte bianche, accento blu petrolio,
|
||||
carattere Archivo, righe più ariose. La barra laterale tiene in fondo il mondo (sito vero o simulatore) e
|
||||
l'utente Bidoo; elenco e pannello stanno in due riquadri. Il tema di fabbrica segue quello del sistema:
|
||||
il bottone in alto passa fra automatico, chiaro e scuro. Ogni colore ha la sua variante per il testo, e
|
||||
una prova controlla il contrasto in tutti e due i temi.
|
||||
- **Niente più browser nel bot** (ADR 0017): la pagina Browser diventa **Accesso a Bidoo**, dove si incolla
|
||||
la sessione copiata da Chrome. Basta «Copia come cURL» dalla scheda Rete degli strumenti per
|
||||
sviluppatori: il bot ne prende cookie e User-Agent da solo. Vanno bene anche le intestazioni, la riga
|
||||
Cookie o il solo valore di `__stattrb`. Chromium esce dall'immagine, che diventa molto più leggera;
|
||||
al primo avvio il bot cancella il vecchio profilo `/config/browser`, che teneva una copia dei cookie.
|
||||
|
||||
## 1.2.0
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ dotnet run --project src/Mimante -- --config "$PWD/tools/dev/config" --simulator
|
||||
|
||||
# Immagine e screenshot per il README
|
||||
docker build -f docker/Dockerfile --build-arg VERSION=2.0.0 -t mimante:dev .
|
||||
dotnet run --project tools/Mimante.Schermate -- http://localhost:8080 dev docs/schermate # bot con --simulatore; --accesso-assistito prova anche Chromium, --messaggio il messaggio a schermo
|
||||
dotnet run --project tools/Mimante.Schermate -- http://localhost:8080 dev docs/schermate # bot con --simulatore; Chrome o Edge del PC; --messaggio il messaggio a schermo
|
||||
```
|
||||
|
||||
`--config <cartella>` e `--simulatore` servono solo allo sviluppo fuori dal container (predefinito
|
||||
|
||||
@@ -34,7 +34,7 @@ modello, previsione, paletti e contatori, in schede.*
|
||||
|---|---|
|
||||
|  *Apprendimento: stato del modello, ROI con intervallo di confidenza, perché perdi, cosa ha imparato.* |  *Storico: aste concluse con il perché, riepilogo, serie dei prezzi, esportazioni CSV.* |
|
||||
|  *Prodotti: paletti scritti nelle celle o, se vuote, calcolati dallo storico; chiusure, costo reale e come si punta sul prodotto.* |  *Cerca: il catalogo di Bidoo per categoria, aggiunta in un clic.* |
|
||||
|  *Browser: il browser del bot in streaming, per navigare in Bidoo e accedere.* |  *Impostazioni: quasi tutto vale subito; ciò che vale dal riavvio lo dice il messaggio dopo il salvataggio.* |
|
||||
|  *Accesso a Bidoo: incolli la sessione copiata da Chrome e il bot passa al tuo utente.* |  *Impostazioni: quasi tutto vale subito; ciò che vale dal riavvio lo dice il messaggio dopo il salvataggio.* |
|
||||
|  *Tema chiaro.* |  *Sotto 1100 px il menu diventa a icone e il pannello un cassetto.* |
|
||||
|  *La password dell'interfaccia.* |  *Registro: una riga per evento, filtri, file giornalieri.* |
|
||||
|  *Il registro del bot nel pannello delle aste, scelto con il selettore in cima.* |  *Il mercato di un prodotto: chiusure, puntate dei vincitori, costo reale, risparmio.* |
|
||||
@@ -66,23 +66,23 @@ Serve un container **PostgreSQL 18** già in funzione (sul server di Alberto è
|
||||
sceglila robusta). Facoltative: `DB_USER` (`admin`), `DB_NAME` (`autobidder`, creato se manca), `TZ`
|
||||
(`Europe/Rome`), `PUID`/`PGID` (`99`/`100`). Nessun'altra variabile.
|
||||
4. **Cartella dati.** `/config` → `/mnt/user/appdata/mimante`: sessione cifrata, riferimenti del
|
||||
sito, registri, esportazioni, profilo del browser, backup.
|
||||
sito, registri, esportazioni, backup.
|
||||
5. **Avvia.** L'interfaccia è su `http://<ip-di-unraid>:8080`. Se qualcosa manca (variabile, database
|
||||
spento) vedi la schermata d'errore con la causa esatta: il bot riprova da solo ogni 30 secondi, così
|
||||
regge anche l'ordine d'avvio dei container all'accensione.
|
||||
|
||||
L'immagine pesa circa 1,35 GB su disco: più di metà è Chromium, che serve alla pagina Browser.
|
||||
L'immagine non contiene un browser: la sessione di Bidoo si incolla dall'interfaccia (ADR 0017).
|
||||
|
||||
## Primo avvio
|
||||
|
||||
1. Entra con `UI_PASSWORD`.
|
||||
2. Anche senza utente Bidoo il bot lavora sul sito vero: cerchi e segui le aste, lo storico cresce e il
|
||||
modello impara. Nessuna puntata parte finché non accedi.
|
||||
3. **Browser** ▸ «Apri il browser del bot»: fai il login nel riquadro come sul sito. Il browser gira
|
||||
dentro il bot; quando il login riesce i cookie si salvano cifrati e il bot passa al tuo utente. Il
|
||||
browser resta aperto per navigare in Bidoo (indietro, avanti, indirizzo); su una pagina d'asta
|
||||
«Aggiungi al monitor» la mette in elenco. In alternativa incolla la riga *Cookie* del tuo browser
|
||||
con lo User-Agent.
|
||||
3. **Accesso a Bidoo**: nel Chrome del PC, con Bidoo aperto e il tuo utente collegato, premi `F12` ▸
|
||||
*Rete*, ricarica la pagina, tasto destro sulla prima riga ▸ *Copia* ▸ *Copia come cURL*, e incolla
|
||||
nel riquadro. Il bot ne prende cookie e User-Agent, li salva cifrati e passa al tuo utente. Vanno bene
|
||||
anche le intestazioni della richiesta, la riga *Cookie* o il solo valore di `__stattrb`. Non premere
|
||||
«Esci» su Bidoo da quel browser: chiuderebbe anche la sessione del bot.
|
||||
4. Aggiungi la prima asta in **Osserva** (Aste ▸ +, oppure da Cerca).
|
||||
|
||||
La guida completa all'uso è in **[docs/come-funziona.md](docs/come-funziona.md)**: la griglia, i tre modi
|
||||
@@ -129,7 +129,8 @@ campiona per esito, e la legenda lo dice. I file restano in `/config/esportazion
|
||||
tue puntate, previsioni, prodotti, rischio, impostazioni.
|
||||
- **Backup**: ogni notte le tabelle di riepilogo in `/config/backup/AAAA-MM-GG/*.csv.gz` (14 giorni). Le
|
||||
puntate di tutti (`bids`, la parte grossa) si affidano al **backup di Unraid del container PostgreSQL**
|
||||
(`/mnt/cache/appdata/postgresql18`): tienilo attivo.
|
||||
(`/mnt/cache/appdata/postgresql18`): tienilo attivo. Le impostazioni escono senza il token del bot
|
||||
Telegram: dopo un ripristino da questi file va riscritto.
|
||||
- **Registri**: `/config/registri/app-AAAA-MM-GG.log` e `aste-AAAA-MM-GG.log`, 90 giorni.
|
||||
|
||||
## Aggiornare
|
||||
@@ -149,8 +150,8 @@ passi sono in [docs/docker.md](docs/docker.md), «Aggiornare da Bidoo BidBot».
|
||||
|---|---|
|
||||
| Schermata «Mimante non può partire» | Leggi la voce in rosso: variabile mancante, cartella non scrivibile, PostgreSQL spento o password sbagliata. Si riprova da soli ogni 30 s. |
|
||||
| Container «unhealthy» in Unraid | È la stessa cosa: `/salute` risponde 503 finché configurazione e database non sono a posto. |
|
||||
| Pallino rosso sull'utente, «Sessione scaduta» | Le aste sono passate in Osserva. Rifai l'accesso dalla pagina Browser. |
|
||||
| «Chromium non trovato» | Solo fuori dal container: usa «incolla i cookie». |
|
||||
| Pallino rosso sull'utente, «Sessione scaduta» | Le aste sono passate in Osserva. Incolla una sessione nuova in Accesso a Bidoo. |
|
||||
| «Manca il cookie __stattrb» | La richiesta copiata non è di un utente collegato: accedi a Bidoo in Chrome e ricopiala. |
|
||||
| Il bot non punta mai | Apprendimento ▸ «Perché perdo». Di solito il modello ha ragione: vedi l'avvertenza in cima. |
|
||||
| Subito dopo un aggiornamento nessuna asta punta | Il modello sta ristudiando l'archivio (pagina Apprendimento): le puntate riprendono da sole quando ha finito. |
|
||||
| Spazio quasi pieno | Alza il tetto o lascia lavorare la rotazione notturna; controlla il backup di PostgreSQL. |
|
||||
|
||||
+8
-9
@@ -1,17 +1,16 @@
|
||||
# syntax=docker/dockerfile:1.7
|
||||
#
|
||||
# Mimante: un solo container con motore, interfaccia web e Chromium per l'accesso
|
||||
# assistito a Bidoo.
|
||||
# Mimante: un solo container con motore e interfaccia web. Niente browser: la sessione di
|
||||
# Bidoo si incolla dall'interfaccia (docs/adr/0017-sessione-incollata-senza-browser.md).
|
||||
#
|
||||
# docker build -f docker/Dockerfile --build-arg VERSION=2.0.0 --build-arg GIT_COMMIT=$(git rev-parse --short=12 HEAD) -t mimante:2.0.0 .
|
||||
#
|
||||
# Stadi: build (restore + compilazione), test (i test di logica pura; quelli su PostgreSQL
|
||||
# saltano da soli senza TEST_DB_HOST), publish (ReadyToRun per linux-x64), runtime.
|
||||
#
|
||||
# Il runtime è Debian 13 con il runtime ASP.NET copiato dall'immagine ufficiale: per .NET 10
|
||||
# Microsoft pubblica solo immagini Ubuntu/Alpine/Azure Linux, e su Ubuntu «apt install
|
||||
# chromium» installa soltanto il rimando a snap, che in un container non funziona. Su Debian
|
||||
# il pacchetto chromium è il browser vero (docs/adr/0010-immagine-debian-con-runtime-copiato.md).
|
||||
# Il runtime è Debian 13 con il runtime ASP.NET copiato dall'immagine ufficiale
|
||||
# (docs/adr/0010-immagine-debian-con-runtime-copiato.md). Era nato per Chromium, che su Ubuntu
|
||||
# si installa solo da snap; Chromium non c'è più, la base resta per non cambiare due cose insieme.
|
||||
|
||||
ARG DOTNET_VERSION=10.0
|
||||
|
||||
@@ -60,12 +59,12 @@ LABEL org.opencontainers.image.title="mimante" \
|
||||
org.opencontainers.image.authors="Alberto Balbo" \
|
||||
org.opencontainers.image.source="http://192.168.30.23:3000/Alby96/Mimante"
|
||||
|
||||
# Dipendenze del runtime .NET (ICU, OpenSSL, zlib), fuso orario, certificati, Chromium con
|
||||
# i caratteri per l'accesso assistito, setpriv (util-linux) per scendere a PUID/PGID.
|
||||
# Dipendenze del runtime .NET (ICU, OpenSSL, zlib), fuso orario, certificati, setpriv
|
||||
# (util-linux) per scendere a PUID/PGID.
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
ca-certificates tzdata libicu76 libssl3t64 libstdc++6 zlib1g libgcc-s1 \
|
||||
chromium fonts-liberation util-linux \
|
||||
util-linux \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY --from=dotnet /usr/share/dotnet /usr/share/dotnet
|
||||
|
||||
@@ -35,7 +35,7 @@ fi
|
||||
|
||||
chown -R "${PUID}:${PGID}" /config
|
||||
|
||||
# Chromium vuole una home scrivibile per la cache: la sua sta dentro /config/browser.
|
||||
# Una home scrivibile per il runtime .NET: /config, l'unica cartella persistente.
|
||||
export HOME=/config
|
||||
|
||||
echo "mimante: avvio come uid ${PUID} gid ${PGID} (${GROUP_NAME}), fuso ${TZ:-UTC}"
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<DonateLink/>
|
||||
<Requires>Il container PostgreSQL (postgresql18, utente admin, database autobidder) raggiungibile dal bot.</Requires>
|
||||
<Config Name="Interfaccia web" Target="8080" Default="8080" Mode="tcp" Description="Porta dell'interfaccia" Type="Port" Display="always" Required="true" Mask="false">8080</Config>
|
||||
<Config Name="Cartella dati (/config)" Target="/config" Default="/mnt/user/appdata/mimante" Mode="rw" Description="Sessione, riferimenti, registri, esportazioni, profilo browser, backup" Type="Path" Display="always" Required="true" Mask="false">/mnt/user/appdata/mimante</Config>
|
||||
<Config Name="Cartella dati (/config)" Target="/config" Default="/mnt/user/appdata/mimante" Mode="rw" Description="Sessione, riferimenti, registri, esportazioni, backup" Type="Path" Display="always" Required="true" Mask="false">/mnt/user/appdata/mimante</Config>
|
||||
<Config Name="DB_HOST" Target="DB_HOST" Default="192.168.30.23:5432" Mode="" Description="Indirizzo del container PostgreSQL (IP o nome, con :porta se non e' 5432)" Type="Variable" Display="always" Required="true" Mask="false">192.168.30.23:5432</Config>
|
||||
<Config Name="DB_PASSWORD" Target="DB_PASSWORD" Default="" Mode="" Description="Password dell'utente PostgreSQL" Type="Variable" Display="always" Required="true" Mask="true"></Config>
|
||||
<Config Name="UI_PASSWORD" Target="UI_PASSWORD" Default="" Mode="" Description="Password per entrare nell'interfaccia web (comanda puntate vere)" Type="Variable" Display="always" Required="true" Mask="true"></Config>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# 0003 — Client CDP scritto a mano per l'accesso assistito
|
||||
|
||||
**Stato:** accettata (specifica §6.5, D4)
|
||||
**Stato:** superata dalla 0017 (2.0.0): il bot non ha più un browser; il client CDP resta solo in `tools/Mimante.Schermate`
|
||||
|
||||
## Contesto
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# 0010 — Immagine Debian con il runtime .NET copiato
|
||||
|
||||
**Stato:** accettata (deviazione dalla specifica §10.2)
|
||||
**Stato:** accettata (deviazione dalla specifica §10.2); dalla 2.0.0 senza Chromium (ADR 0017), la base Debian resta
|
||||
|
||||
## Contesto
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
# 0016 — Grafica sulla linea di Febe, con tema automatico
|
||||
|
||||
**Stato:** accettata (2.0.0, 24/11/2026)
|
||||
|
||||
## Contesto
|
||||
|
||||
La grafica della 1.x era nata dai mockup della riscrittura: tema scuro di fabbrica, blu acceso, densità
|
||||
molto compatta, cinque colori scritti a mano fuori dai token. Gli altri progetti di Alberto (Febe in testa)
|
||||
hanno preso un'altra linea. Per la 2.0.0 sono state preparate tre proposte con lo stesso contenuto
|
||||
(`docs/mockup/redesign/`, immagini in `immagini/` e foglio di confronto `confronto.png`): A sulla linea di
|
||||
Febe, B di Khaemhat, C di Anubis. Alberto ha scelto la **A**.
|
||||
|
||||
## Decisione
|
||||
|
||||
- **Colori**: grigio caldo, carte bianche, accento blu petrolio (`#0F5C8C` in chiaro, `#62B1E0` in scuro).
|
||||
Ogni stato ha la tinta piena (`--ok`, `--warn`, `--bad`, `--gold`), la variante per il testo (`--*-text`) e
|
||||
il fondo tenue (`--*-soft`): un testo colorato usa sempre la variante `-text`, che si legge sulla
|
||||
superficie e sul suo fondo tenue.
|
||||
- **Tema** `auto | light | dark` su `data-theme`; ogni token è `light-dark(chiaro, scuro)` e
|
||||
`color-scheme` sceglie quale vale. Un browser che non ha ancora scelto segue il sistema; il bottone in alto
|
||||
gira automatico → chiaro → scuro e il browser lo ricorda. «Tema scuro» delle Impostazioni, al salvataggio,
|
||||
lo fissa per il browser da cui si salva.
|
||||
- **Carattere**: Archivo (SIL OFL 1.1), copiato in `wwwroot/fonts` con la licenza; le pagine d'accesso lo
|
||||
possono caricare prima dell'accesso, come `/css/` e `/img/`.
|
||||
- **Ossatura**: barra laterale grigia con le pagine e, in fondo, il mondo (sito vero o simulatore) e
|
||||
l'utente Bidoo; in alto gli indicatori come pastiglie sullo sfondo; titolo della pagina grande; elenco e
|
||||
pannello in due riquadri staccati, la maniglia nello spazio fra i due (`split.js` ne tiene conto). Righe
|
||||
più ariose (circa 40 px), intestazioni sobrie, riga scelta con fondo d'accento e barra a sinistra.
|
||||
- **Non cambia**: virtualizzazione della griglia, aggiornamenti chirurgici del DOM, maniglie, `title`
|
||||
ovunque, nessuna notifica laterale, nessuna risorsa da fuori.
|
||||
- **Controllo automatico** (`tests/Mimante.Tests/ContrastTests.cs`): legge `tokens.css` e verifica il
|
||||
contrasto delle coppie testo/fondo nei due temi (4,5:1; 3:1 per i segni senza testo), che fuori da
|
||||
`tokens.css` non ci siano colori scritti, che ogni `var(--…)` usato esista e che i caratteri siano locali.
|
||||
|
||||
## Conseguenze
|
||||
|
||||
- Un browser che aveva già scelto il tema scuro lo tiene; uno nuovo segue il sistema.
|
||||
- La proposta A aveva la riga di stato sotto il titolo; nell'interfaccia vera gli indicatori restano in cima,
|
||||
sopra il titolo, perché ogni pagina compone da sé la sua testa. Il conto delle aste per modo
|
||||
resta nella barra della pagina Aste invece che accanto alle voci del menu.
|
||||
- Le schermate del README si rifanno con `tools/Mimante.Schermate` contro un bot con PostgreSQL (lavoro di
|
||||
chiusura della 2.0.0).
|
||||
@@ -0,0 +1,49 @@
|
||||
# 0017 — La sessione di Bidoo si incolla: niente browser nel bot
|
||||
|
||||
**Stato:** accettata (2.0.0, 24/11/2026). Supera la 0003 e, per Chromium, la 0010.
|
||||
|
||||
## Contesto
|
||||
|
||||
Dalla 1.0.0 il bot portava dentro l'immagine un Chromium senza finestra (ADR 0003, 0010), mostrato
|
||||
nell'interfaccia come pagina **Browser**: ci si faceva il login a Bidoo come sul sito e il bot prendeva il
|
||||
cookie da solo; il ripiego era incollare la riga `Cookie` con lo User-Agent. Il browser pesava più di
|
||||
metà dell'immagine (1,35 GB su disco) e la maggior parte dei suoi pacchetti, teneva in
|
||||
`/config/browser` un profilo con una copia dei cookie e chiedeva codice proprio (screencast, mouse,
|
||||
tastiera, navigazione, chiusura dopo mezz'ora senza uso). La sessione di Bidoo invece si rifà di rado.
|
||||
|
||||
Alberto (issue #36) ha chiesto se esiste un modo più semplice dell'incollare il cookie («incollando una
|
||||
parte della pagina, o facendo una copia da qualche tasto di Chrome»); altrimenti meglio togliere il
|
||||
browser e incollare il cookie.
|
||||
|
||||
Verificato con l'accesso vero su `it.bidoo.com`: i due cookie che contano (`__stattrb`, `PHPSESSID`)
|
||||
sono **HttpOnly**. Uno script nella pagina (un segnalibro, «copia» dalla barra) non li vede, e il testo
|
||||
della pagina non li contiene: l'unica copia possibile da Chrome passa dagli strumenti per sviluppatori.
|
||||
Lì però Chrome ha già il comando giusto: **Rete ▸ tasto destro sulla richiesta ▸ Copia ▸ Copia come
|
||||
cURL**, che porta in un colpo cookie e User-Agent.
|
||||
|
||||
## Decisione
|
||||
|
||||
- Via Chromium dall'immagine (`chromium`, `fonts-liberation`), via `AssistedLogin`, i comandi `login.*`,
|
||||
i messaggi `login.frame`/`login.state` e la pagina Browser. Il client CDP e l'avvio di Chromium
|
||||
restano solo in `tools/Mimante.Schermate`, che usa il Chrome o l'Edge del PC.
|
||||
- Pagina **Accesso a Bidoo** (`#/accesso`; il vecchio `#/browser` ci porta): un riquadro dove incollare,
|
||||
le istruzioni per Chrome e lo stato della sessione. `Session/SessionPaste` riconosce, senza chiedere
|
||||
quale formato: «Copia come cURL» (bash e cmd, cookie in `-b` o in `-H 'cookie: …'`, User-Agent in
|
||||
`-H 'user-agent: …'` o `-A`), «Copia come PowerShell», le intestazioni della richiesta (anche con il
|
||||
valore sulla riga sotto il nome, come le copia il pannello), la riga `Cookie`, righe della tabella dei
|
||||
cookie e il solo valore di `__stattrb`. Lo User-Agent del testo vale più di quello del campo, che di
|
||||
fabbrica è quello del browser da cui si usa l'interfaccia.
|
||||
- All'avvio il bot cancella `/config/browser` se c'è (resto della 1.x, con una copia dei cookie).
|
||||
- La 0010 resta per la base Debian con il runtime copiato: il motivo era Chromium, ma cambiare base
|
||||
insieme al resto sarebbe stato un secondo cambiamento da provare. Si potrà rivedere.
|
||||
|
||||
## Conseguenze
|
||||
|
||||
- L'immagine è molto più piccola e ha molte meno dipendenze da aggiornare; `prova-immagine.sh` controlla
|
||||
che Chromium non ci sia.
|
||||
- Per collegare l'utente serve un PC con Chrome (o Edge) in cui Bidoo è aperto con il proprio utente.
|
||||
Uscire da Bidoo su quel browser chiude anche la sessione del bot: la pagina lo dice.
|
||||
- «Aggiungi al monitor» dal browser del bot non c'è più: un'asta si aggiunge da Aste ▸ + (anche con il suo
|
||||
indirizzo) o da Cerca.
|
||||
- La specifica (§6.5, §9, §10.2) descrive ancora l'accesso assistito: lo scostamento è qui e in
|
||||
`docs/stato.md`.
|
||||
+17
-19
@@ -9,7 +9,7 @@ loro perché sono in [adr/](adr/).
|
||||
Un solo processo .NET 10 in un solo container. Dentro: il **motore** (un runner per asta, con un
|
||||
thread dedicato nella finestra critica), la **coda di scrittura** verso PostgreSQL, l'**apprendimento**
|
||||
(tutto in memoria, salvato nei documenti `ml/*`), l'**interfaccia** (Kestrel, una pagina HTML con
|
||||
moduli ES, un WebSocket) e **Chromium** per la pagina Browser (navigare in Bidoo e accedere). PostgreSQL è un container
|
||||
moduli ES, un WebSocket). Niente browser: la sessione di Bidoo si incolla (ADR 0017). PostgreSQL è un container
|
||||
separato già presente su Unraid; tutto ciò che deve sopravvivere al riavvio sta lì, tranne i file che
|
||||
l'utente può voler leggere o correggere a mano, che stanno in `/config`.
|
||||
|
||||
@@ -27,7 +27,7 @@ l'utente può voler leggere o correggere a mano, che stanno in `/config`.
|
||||
│ ├─ WriteQueue (un consumatore, lotti 200 ms / 500 righe) ◄─┘ ──────► PostgreSQL 18 │
|
||||
│ ├─ Maintenance (04:30: partizioni, tetto dati, registri, backup) │
|
||||
│ ├─ TelegramNotifier (coda, 3 ritentativi, comandi facoltativi) │
|
||||
│ └─ AssistedLogin ─ ChromiumProcess ─ CdpClient (screencast) ◄── clic e tasti │
|
||||
│ └─ SessionStore ◄─ SessionPaste ◄── testo incollato (cURL, intestazioni, cookie) │
|
||||
└──────────────────────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
@@ -40,7 +40,7 @@ partizioni. Se qualcosa manca, l'interfaccia mostra solo la **schermata d'errore
|
||||
l'errore testuale e i valori in uso (mai le password), `/salute` risponde 503 e si riprova da soli
|
||||
ogni 30 s (D2). Con le verifiche verdi nasce `Bot`, la radice di composizione:
|
||||
impostazioni e documenti dal database, riferimenti del sito, prodotti, rischio, Telegram,
|
||||
manutenzione, sessione, hub, accesso assistito, riscaldamento del motore, poi il **mondo**.
|
||||
manutenzione, sessione, hub, riscaldamento del motore, poi il **mondo**.
|
||||
|
||||
Il database che manca per più di 60 s manda tutte le aste in Osserva; dopo 10 minuti il bot si
|
||||
ferma e torna la schermata d'errore (la coda nel frattempo accumula fino a 100.000 righe e poi
|
||||
@@ -307,7 +307,8 @@ riepilogo, non si toccano mai. Oltre il 90% del tetto parte un avviso Telegram.
|
||||
### Backup e registri
|
||||
|
||||
Dopo la manutenzione, `COPY … TO STDOUT` delle tabelle non partizionate più `my_bids` e
|
||||
`auction_forecasts` in `/config/backup/AAAA-MM-GG/*.csv.gz`, conservati 14 giorni. Il grosso
|
||||
`auction_forecasts` in `/config/backup/AAAA-MM-GG/*.csv.gz`, conservati 14 giorni; `settings` esce senza
|
||||
`TelegramBotToken` (`Maintenance.BackupCopySql`), perché i file stanno in chiaro. Il grosso
|
||||
(`bids`) si affida al backup del container PostgreSQL. I registri su file (`app-*.log`, `aste-*.log`)
|
||||
si cancellano dopo `LogRetentionDays` (90). La copia passa da `Data/BulkCopy` (file `.tmp` rinominato
|
||||
alla fine, righe esatte, impronta SHA-256).
|
||||
@@ -380,12 +381,11 @@ confronta lo stato con l'ultimo spedito e manda solo ciò che è cambiato:
|
||||
| `export` | l'esportazione in corso o l'ultima (`ExportJobs`): stato, fase, righe scritte su quelle da scrivere, file pronti, messaggio; quando cambia |
|
||||
| `event` | righe del registro (livello ≥ informazione) |
|
||||
| `learning` | ogni 5 s, solo ai client sulla pagina Apprendimento |
|
||||
| `login.frame`, `login.state` | screencast del browser del bot (con l'indirizzo della pagina), a tutti i client |
|
||||
| `progress` | avanzamento di studio e recupero |
|
||||
|
||||
Dal client: `snapshot`, `page`, `auction.watch`, `auction.add/remove/set_mode/set_limits/bid_now/refresh_product`,
|
||||
`all.set_mode`, `auctions.remove_finished`, `resume`, `settings.get/save`, `telegram.test`,
|
||||
`maintenance.run`, `session.verify/paste/logout`, `login.open/close/reload/input/back/forward/navigate/add_current`,
|
||||
`maintenance.run`, `session.verify/paste/logout`,
|
||||
`product.follow/save/set/delete`, `products.refresh_stats/recompute_limits/apply_limits/backfill_winners`,
|
||||
`learning.study_now/recalc/rebuild_bandit/reset_challenger/evaluate/forget`, `export.start/cancel` (l'esportazione gira di fondo, una alla volta: la risposta dice solo se è partita). Con `rid`
|
||||
ricevono `{"t":"ack","rid":…,"ok":…,"msg":…,"data":…}`.
|
||||
@@ -432,19 +432,17 @@ aggiorna le celle per `data-id` e sopra 60 righe disegna solo quelle visibili.
|
||||
per il costo effettivo della puntata.
|
||||
- Le barre di Prodotti, Apprendimento e Storico hanno bottoni solo icona, con `title` e `aria-label`.
|
||||
|
||||
## Il browser del bot (CDP)
|
||||
## La sessione di Bidoo (incollata)
|
||||
|
||||
`ChromiumProcess` avvia `chromium --headless=new --remote-debugging-port=0 --user-data-dir=/config/browser`
|
||||
e legge l'indirizzo da `DevToolsActivePort`. `CdpClient` è JSON-RPC scritto a mano su `ClientWebSocket`
|
||||
(id incrementale, mappa delle risposte in attesa, sessioni piatte con `Target.attachToTarget
|
||||
flatten: true`). `AssistedLogin` è la pagina **Browser**: apre la home di Bidoo (o `login.php` se non
|
||||
c'è una sessione), avvia `Page.startScreencast` (JPEG 60, 1280×900, ogni frame confermato, con
|
||||
l'indirizzo della pagina), inoltra mouse, tasti di controllo e testo (`Input.insertText`), e naviga
|
||||
con indietro/avanti (`Page.getNavigationHistory`), ricarica e indirizzo (solo host di Bidoo). Senza
|
||||
sessione, ogni secondo controlla se l'indirizzo è uscito dal login con il cookie di sessione: allora
|
||||
salva la sessione (una volta) e il bot passa al tuo utente, mentre il browser resta aperto. Su una
|
||||
pagina d'asta «Aggiungi al monitor» (`login.add_current`) mette l'asta in elenco. Trenta minuti senza
|
||||
input chiudono il browser.
|
||||
Il bot non ha un browser (ADR 0017): i cookie di Bidoo che contano (`__stattrb`, `PHPSESSID`) sono
|
||||
HttpOnly, quindi si copiano dagli strumenti per sviluppatori di Chrome. La pagina **Accesso a Bidoo**
|
||||
manda il testo con `session.paste`; `Session/SessionPaste` (puro, sotto test) ne ricava cookie e
|
||||
User-Agent da «Copia come cURL» (bash e cmd), «Copia come PowerShell», intestazioni della richiesta,
|
||||
riga `Cookie`, righe della tabella dei cookie o il solo valore di `__stattrb`, e rifiuta un testo senza
|
||||
il cookie di accesso. Lo User-Agent del testo vale più di quello del campo. `Bot.UseSessionAsync`
|
||||
salva la sessione, passa al sito vero con l'utente e la verifica sulla pagina del conto.
|
||||
Il testo incollato non si registra mai. All'avvio `ConfigPaths.RemoveOldBrowserProfile` cancella
|
||||
`/config/browser`, il profilo di Chromium della 1.x.
|
||||
|
||||
La sessione (`SessionStore`) è `/config/sessione/sessione.json` cifrato AES-256-GCM con la chiave in
|
||||
`chiave.bin` (0600). Lo User-Agent salvato è quello del browser che ha creato la sessione.
|
||||
@@ -481,7 +479,7 @@ modello impara lì resta in `ml-sim/*`.
|
||||
| Rischio, paletti, fascia oraria | `Strategy/` |
|
||||
| Registrazione, coda, migrazioni, manutenzione, CSV | `Data/` |
|
||||
| Prodotti, sorveglianza, consigli, recupero | `Products/` |
|
||||
| Sessione, verifica, CDP | `Session/` |
|
||||
| Sessione, testo incollato, verifica | `Session/` |
|
||||
| Mondi, composizione, servizi | `Host/` |
|
||||
| Interfaccia (server) | `Web/`; (client) `wwwroot/js/` |
|
||||
| Telegram | `Telegram/` |
|
||||
|
||||
@@ -45,11 +45,12 @@ alla griglia.
|
||||
1. Apri l'indirizzo del bot, scrivi la password dell'interfaccia (`UI_PASSWORD`).
|
||||
2. Anche senza utente Bidoo il bot lavora già sul sito vero: puoi cercare aste, seguirle, e il modello
|
||||
impara. Nessuna puntata parte finché non accedi.
|
||||
3. Apri **Browser**, premi «Apri il browser del bot» e fai il login nel riquadro come sul sito: il
|
||||
browser gira dentro il bot, il cookie lo prende da solo e il bot passa al tuo utente. Il browser resta
|
||||
aperto: navighi dentro Bidoo con indietro, avanti, ricarica, home e la barra dell'indirizzo, e su una
|
||||
pagina d'asta «Aggiungi al monitor» la mette in elenco. Si chiude da solo dopo mezz'ora senza uso. In
|
||||
alternativa incolla la riga Cookie dal tuo browser.
|
||||
3. Apri **Accesso a Bidoo** e incolla la sessione del tuo Chrome: con Bidoo aperto e il tuo utente
|
||||
collegato premi `F12`, scheda *Rete*, ricarica la pagina, tasto destro sulla prima riga ▸ *Copia* ▸
|
||||
*Copia come cURL*. Il bot ne prende cookie e User-Agent, controlla la sessione sulla pagina del conto,
|
||||
la salva cifrata e passa al tuo utente. Vanno bene anche le intestazioni della richiesta, la sola riga
|
||||
Cookie o il valore del cookie `__stattrb` (*Applicazione* ▸ *Cookie*). Il bot non ha un browser suo:
|
||||
non premere «Esci» su Bidoo da quel Chrome, chiuderebbe anche la sessione del bot.
|
||||
4. Aggiungi la prima asta in **Osserva** (Aste → +, oppure da Cerca) e guarda il pannello: verdetto del
|
||||
modello, previsione, registro.
|
||||
|
||||
@@ -303,7 +304,7 @@ bottone e la modifica è già in uso.
|
||||
errori, puntatori, contabilità del rischio, prodotti, impostazioni, modello appreso.
|
||||
- **`/config`** (la cartella `appdata` del container): `sessione/` (cookie cifrati), `riferimenti/bidoo.json`
|
||||
(indirizzi ed espressioni del sito: si corregge a mano se Bidoo cambia qualcosa, e vale subito),
|
||||
`registri/` (un file al giorno), `esportazioni/`, `browser/`, `backup/`, `cache/`.
|
||||
`registri/` (un file al giorno), `esportazioni/`, `backup/`, `cache/`.
|
||||
|
||||
Le singole interrogazioni a Bidoo non si registrano. Il database ha un tetto (50 GB di fabbrica): oltre,
|
||||
ogni notte si tolgono le decisioni e le puntate altrui più vecchie; aste, tue puntate, previsioni,
|
||||
@@ -314,8 +315,8 @@ prodotti e rischio non si cancellano mai. Ogni notte un backup delle tabelle di
|
||||
|
||||
- **Schermata «Mimante non può partire»**: dice cosa manca (variabile, cartella, database) con
|
||||
l'errore esatto; il bot riprova da solo ogni 30 secondi, o premi «Riprova adesso».
|
||||
- **Sessione scaduta** (pallino rosso sull'utente): tutte le aste sono passate in Osserva; rifai
|
||||
l'accesso dalla pagina **Browser**.
|
||||
- **Sessione scaduta** (pallino rosso sull'utente): tutte le aste sono passate in Osserva; incolla una
|
||||
sessione nuova in **Accesso a Bidoo**.
|
||||
- **Il motore non punta mai**: guarda «Perché perdo». Se il motivo è «il modello sconsigliava», il
|
||||
modello ha ragione più spesso di quanto sembri: sui dati raccolti una puntata resta senza risposta
|
||||
meno dell'1% delle volte, e su un buono da 10 € servirebbe il 2% per andare in pari con puntate tutte
|
||||
|
||||
+7
-6
@@ -1,18 +1,18 @@
|
||||
# Mimante in Docker (e su Unraid)
|
||||
|
||||
Un solo contenitore con il motore, l'interfaccia web e Chromium (per l'accesso assistito e la pagina
|
||||
Browser); PostgreSQL 18 sta in un contenitore a parte. L'installazione passo per passo è nel
|
||||
Un solo contenitore con il motore e l'interfaccia web, senza browser (la sessione di Bidoo si incolla,
|
||||
ADR 0017); PostgreSQL 18 sta in un contenitore a parte. L'installazione passo per passo è nel
|
||||
[README](../README.md), «Installazione su Unraid»; qui ciò che serve a chi costruisce, aggiorna o
|
||||
controlla l'immagine.
|
||||
|
||||
## Che cosa c'è nell'immagine
|
||||
|
||||
- Debian 13 ridotta (`debian:trixie-slim`) con il runtime ASP.NET copiato dall'immagine ufficiale
|
||||
(ADR 0010): per .NET 10 non ci sono immagini Debian, e su Ubuntu Chromium è uno snap.
|
||||
(ADR 0010; il motivo era Chromium, tolto nella 2.0.0, la base è rimasta).
|
||||
- Il programma pubblicato ReadyToRun per `linux-x64` in `/app`; la compilazione e i test di logica pura
|
||||
girano dentro la costruzione, e la pubblicazione parte solo con i test verdi.
|
||||
- `chromium`, `fonts-liberation`, ICU, OpenSSL, `tzdata`, certificati e `setpriv` per scendere
|
||||
all'utente `PUID`/`PGID`. Nessun altro programma: niente curl, niente ffmpeg.
|
||||
- ICU, OpenSSL, `tzdata`, certificati e `setpriv` per scendere all'utente `PUID`/`PGID`. Nessun altro
|
||||
programma: niente browser, niente curl, niente ffmpeg.
|
||||
- `/salute` è il controllo di salute (il programma stesso con `--salute`): 200 solo con configurazione e
|
||||
database a posto.
|
||||
|
||||
@@ -40,7 +40,8 @@ servono per tornare indietro.
|
||||
## Volumi, variabili, porte
|
||||
|
||||
- `/config` (predefinito `/mnt/user/appdata/mimante`): sessione cifrata, riferimenti del sito,
|
||||
registri, esportazioni, profilo del browser, backup notturni, cache di Telegram.
|
||||
registri, esportazioni, backup notturni, cache di Telegram. Il profilo del browser della 1.x
|
||||
(`/config/browser`) il bot lo cancella al primo avvio della 2.0.0.
|
||||
- Obbligatorie `DB_HOST`, `DB_PASSWORD`, `UI_PASSWORD`; facoltative `DB_USER` (`admin`), `DB_NAME`
|
||||
(`autobidder`), `TZ` (`Europe/Rome`), `PUID`/`PGID` (`99`/`100`). Nessun'altra variabile: tutto il
|
||||
resto sta nelle Impostazioni (nel database) o in `/config/riferimenti/bidoo.json`.
|
||||
|
||||
+25
-14
@@ -144,23 +144,23 @@ Chromium con i fotogrammi, spegnimento ordinato) e pubblicata come `alby96/miman
|
||||
|
||||
## Cosa manca o va provato
|
||||
|
||||
1. **Prova reale (M7)**: accesso assistito con l'account vero, verifica del conto, prima asta seguita in
|
||||
Osserva per qualche giorno. Controllare in particolare: formato di `buy_bids.php` e
|
||||
`update_credits_status.php` (i parser vengono dal legacy), che il cookie `__stattrb` compaia solo a
|
||||
login fatto, e che lo screencast regga il cambio di processo dopo il login (in locale e nel container
|
||||
parte dopo il caricamento, con ritentativi).
|
||||
2. **Runner Linux (M1, M10)**: vedi D3. Finché non c'è, i workflow in `.gitea/workflows/` non girano e
|
||||
l'immagine si carica a mano (`docker push` come il 28/09). Dalla 2.0.0 il repository è alla radice
|
||||
e la CI è quella di Febe (`docs/processo.md`).
|
||||
1. **Prova reale (M7)**: sessione incollata dal Chrome di Alberto (dalla 2.0.0, ADR 0017), verifica
|
||||
del conto, prima asta seguita in Osserva per qualche giorno. Controllare in particolare il formato di
|
||||
`buy_bids.php` e `update_credits_status.php` (i parser vengono dal legacy) e che la sessione copiata
|
||||
regga a lungo sul server con lo User-Agent del Chrome da cui viene.
|
||||
2. **CI su Gitea (2.0.0)**: il runner Linux c'è (lo stesso di Febe, sul Docker di Unraid). Dal 24/11/2026
|
||||
`verifica` è verde sul ramo (esecuzione 402, prima volta con tutte le prove su PostgreSQL, la prova del
|
||||
contenitore e Trivy) e la prova del rilascio `v2.0.0-rc.2` ha pubblicato `mimante:2.0.0-rc.2` con la
|
||||
sua pre-release (esecuzione 405); `v2.0.0-rc.1` si era fermata su una prova dei tempi troppo stretta
|
||||
per un runner condiviso. Restano da fare a mano su Gitea la protezione di `main` e dei tag `v*`.
|
||||
3. **Criteri di prestazione dell'interfaccia (§9.11)**: l'architettura li rispetta per costruzione
|
||||
(delta a 10 Hz, countdown locale solo sulle righe disegnate, nessun re-render della griglia,
|
||||
virtualizzazione oltre 60 righe, maniglie che cambiano solo una variabile CSS), ma CPU della scheda,
|
||||
frame persi e tempi di aggiornamento **non sono stati misurati** con 60 aste reali. Da misurare con
|
||||
gli strumenti del browser alla prima settimana di uso vero, e scrivere qui i numeri.
|
||||
4. **Telegram**: provare «Invia messaggio di prova» con il bot vero.
|
||||
5. **Dimensione dell'immagine**: 1,35 GB su disco (la specifica stimava ~600 MB): Chromium di Debian con
|
||||
le sue dipendenze pesa ~500 MB, il runtime ASP.NET ~200 MB. Accettabile per Unraid; ridurla vorrebbe
|
||||
dire togliere la pagina Browser.
|
||||
5. **Dimensione dell'immagine**: era 1,35 GB su disco con Chromium; dalla 2.0.0 il browser non c'è più
|
||||
(ADR 0017). Il peso nuovo va scritto qui dalla prima immagine costruita in CI.
|
||||
6. **Anticipo più stretto (1.1.0)**: nella prima settimana vera guardare in Apprendimento le puntate
|
||||
tardive e il margine: se le tardive salgono, il margine si alza da solo di 100 ms ciascuna.
|
||||
7. **Bot senza utente sul sito vero**: provato il 28/09 (catalogo, `data.php`, puntate registrate con il
|
||||
@@ -226,7 +226,8 @@ cambiarle; dove serve, il punto nel codice è indicato.
|
||||
per Aste e Storico) e lo spazio che serve all'elenco; sotto 1100 px restano cassetti.
|
||||
- **Nome del programma nella barra laterale** (1.2.0): §9.1 lo metteva nella barra in alto. Sta in cima
|
||||
alla barra laterale con l'icona; compressa resta l'icona. La barra laterale si comprime e si espande
|
||||
solo con le frecce in fondo; la barra in alto tiene i chip di stato, il tema e l'uscita.
|
||||
solo con le frecce in fondo; la barra in alto tiene i chip di stato, il tema e l'uscita. Dalla 2.0.0
|
||||
in fondo alla barra laterale stanno anche il mondo (sito vero o simulatore) e l'utente Bidoo.
|
||||
- **Saldo solo come totale** (1.2.0): §9.1 voleva le puntate residue con `(pagate + gratis)`. Su
|
||||
richiesta di Alberto si mostra solo il totale; la divisione resta in `AccountState.Paid/Free` per il
|
||||
costo effettivo della puntata del modello.
|
||||
@@ -250,6 +251,16 @@ cambiarle; dove serve, il punto nel codice è indicato.
|
||||
nuovo, spento di fabbrica, con la pagina «Puntate gratis»; i forzieri si segnalano e non si aprono.
|
||||
Mancano ancora la lettura delle ricompense (`/my_chests.php`, `/bids_history.php`) e la campanella come
|
||||
seconda fonte, e il primo riscatto dal bot va fatto dal vivo.
|
||||
- **Niente browser nel bot** (2.0.0, ADR 0017): §6.5, §9 e §10.2 volevano l'accesso assistito con
|
||||
Chromium nel container. Su richiesta di Alberto la sessione si incolla dalla pagina «Accesso a Bidoo»
|
||||
(«Copia come cURL» di Chrome, intestazioni, riga Cookie o valore di `__stattrb`): i cookie di Bidoo
|
||||
sono HttpOnly, quindi non c'è un modo più semplice dagli strumenti normali del browser.
|
||||
- **Grafica** (2.0.0, ADR 0016): §9 descriveva la grafica dei mockup della riscrittura, scura di fabbrica.
|
||||
Alberto ha scelto la proposta A, sulla linea di Febe: tema che segue il sistema (automatico, chiaro,
|
||||
scuro), carattere Archivo, mondo e utente Bidoo in fondo alla barra laterale invece che fra i chip in
|
||||
alto. Provata con un bot finto su un server statico (Aste, Impostazioni, Puntate gratis e accesso, a
|
||||
1600, 1366 e 1000 px, nei due temi, senza errori JavaScript); le schermate con
|
||||
`tools/Mimante.Schermate` contro un bot vero restano per la chiusura.
|
||||
|
||||
## Cosa è rimasto della versione desktop dopo la rimozione di `legacy/` (1.1.0)
|
||||
|
||||
@@ -278,8 +289,8 @@ parser, catalogo, trasporto, motore, modello, strategia, rischio, prodotti) era
|
||||
|
||||
## Domande aperte per Alberto
|
||||
|
||||
1. Il runner Linux di Gitea c'è o va registrato (Appendice B della specifica, procedura nel README)?
|
||||
Con quale utente e token per il registry?
|
||||
1. ~~Il runner Linux di Gitea c'è o va registrato?~~ C'è: la CI è verde dal 24/11/2026 e il segreto
|
||||
`REGISTRY_TOKEN` funziona (la prova del rilascio ha pubblicato l'immagine).
|
||||
2. ~~Il repository nuovo va creato su Gitea, o si resta in Mimante?~~ Risposta del 24/11/2026: si resta
|
||||
in Mimante, con tutto alla radice e il prodotto rinominato Mimante (ADR 0014).
|
||||
3. Dopo la prima settimana in Osserva sul sito vero: i paletti dell'anticipo (D10) vanno bene con la
|
||||
|
||||
@@ -21,8 +21,11 @@ public sealed class ConfigPaths
|
||||
|
||||
public string Exports => Path.Combine(Root, "esportazioni");
|
||||
|
||||
/// <summary>Profilo di Chromium per l'accesso assistito.</summary>
|
||||
public string Browser => Path.Combine(Root, "browser");
|
||||
/// <summary>
|
||||
/// Il profilo di Chromium dell'accesso assistito, tolto nella 2.0.0 (ADR 0017). Conteneva anche i
|
||||
/// cookie di Bidoo: chi aggiorna dalla 1.x lo trova ancora e il bot lo cancella all'avvio.
|
||||
/// </summary>
|
||||
public string OldBrowserProfile => Path.Combine(Root, "browser");
|
||||
|
||||
public string Backups => Path.Combine(Root, "backup");
|
||||
|
||||
@@ -33,10 +36,25 @@ public sealed class ConfigPaths
|
||||
|
||||
public void EnsureAll()
|
||||
{
|
||||
foreach (var dir in new[] { Root, Session, References, Logs, Exports, Browser, Backups, Cache })
|
||||
foreach (var dir in new[] { Root, Session, References, Logs, Exports, Backups, Cache })
|
||||
Directory.CreateDirectory(dir);
|
||||
}
|
||||
|
||||
/// <summary>Cancella il profilo di Chromium della 1.x, se c'è. Vero se l'ha cancellato.</summary>
|
||||
public bool RemoveOldBrowserProfile()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!Directory.Exists(OldBrowserProfile)) return false;
|
||||
Directory.Delete(OldBrowserProfile, recursive: true);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e) when (e is IOException or UnauthorizedAccessException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>La cartella è scrivibile? Serve alla schermata d'errore di configurazione.</summary>
|
||||
public (bool Ok, string? Error) CheckWritable()
|
||||
{
|
||||
|
||||
@@ -40,6 +40,14 @@ public sealed class Maintenance
|
||||
"risk_ledger", "products", "watched_products", "product_stats", "promo_redemptions", "chests"
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Il COPY del backup di una tabella. Da <c>settings</c> esce senza il token del bot Telegram: il backup sta in
|
||||
/// chiaro in <c>/config/backup</c> e un segreto non ci deve finire (dopo un ripristino il token si riscrive).
|
||||
/// </summary>
|
||||
internal static string BackupCopySql(string table) => table == "settings"
|
||||
? "COPY (SELECT id, value - 'TelegramBotToken' AS value, updated_at FROM settings) TO STDOUT (FORMAT csv, HEADER)"
|
||||
: $"COPY {table} TO STDOUT (FORMAT csv, HEADER)";
|
||||
|
||||
public long? LastSizeBytes { get; private set; }
|
||||
public long CapBytes => (long)(Math.Max(0.001, _settings().DataCapGb) * 1024 * 1024 * 1024);
|
||||
public DateTime? LastRunUtc { get; private set; }
|
||||
@@ -161,7 +169,7 @@ public sealed class Maintenance
|
||||
{
|
||||
foreach (var table in BackupTables)
|
||||
{
|
||||
var copied = await BulkCopy.ToFileAsync(conn, $"COPY {table} TO STDOUT (FORMAT csv, HEADER)",
|
||||
var copied = await BulkCopy.ToFileAsync(conn, BackupCopySql(table),
|
||||
Path.Combine(folder, table + ".csv.gz"), ct: ct).ConfigureAwait(false);
|
||||
total += copied.Bytes;
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ public sealed partial class AuctionMonitor
|
||||
{
|
||||
var a = Find(id);
|
||||
if (a == null) return (false, "Asta non in elenco");
|
||||
if (!CanBid) return (false, "Nessun utente Bidoo collegato: accedi dal Browser per puntare");
|
||||
if (!CanBid) return (false, "Nessun utente Bidoo collegato: collega l'utente da Accesso a Bidoo per puntare");
|
||||
if (_d.Risk.Halted) return (false, "Il gestore del rischio ha fermato le puntate (tetti in Impostazioni): toglilo da lì");
|
||||
if (a.IsFinished) return (false, "Asta conclusa");
|
||||
if (a.Mode == RunMode.Stopped) return (false, "Asta Ferma: il bot non la sta leggendo, mettila in Osserva o Attiva");
|
||||
|
||||
@@ -106,8 +106,8 @@ public sealed partial class AuctionMonitor
|
||||
var note = "";
|
||||
if (mode == RunMode.Active && !CanBid)
|
||||
{
|
||||
note = ": senza utente Bidoo collegato segue e decide ma non punta. Accedi dal Browser per puntare";
|
||||
a.Log.Add("Attiva senza utente collegato: decide e registra, ma nessuna puntata parte finché non accedi dal Browser",
|
||||
note = ": senza utente Bidoo collegato segue e decide ma non punta. Collega l'utente da Accesso a Bidoo per puntare";
|
||||
a.Log.Add("Attiva senza utente collegato: decide e registra, ma nessuna puntata parte finché non colleghi l'utente da Accesso a Bidoo",
|
||||
LogLevel.Warning, AuctionLogCategory.Status);
|
||||
}
|
||||
MarkDirty();
|
||||
|
||||
@@ -5,7 +5,6 @@ using Mimante.Logging;
|
||||
using Mimante.Ml;
|
||||
using Mimante.Products;
|
||||
using Mimante.Session;
|
||||
using Mimante.Session.Cdp;
|
||||
using Mimante.Settings;
|
||||
using Mimante.Strategy;
|
||||
using Mimante.Telegram;
|
||||
@@ -30,7 +29,6 @@ public sealed partial class Bot
|
||||
public SessionStore Sessions { get; private set; } = null!;
|
||||
public TelegramNotifier Telegram { get; private set; } = null!;
|
||||
public Maintenance Maintenance { get; private set; } = null!;
|
||||
public AssistedLogin Login { get; private set; } = null!;
|
||||
public CsvExport Exports { get; private set; } = null!;
|
||||
|
||||
/// <summary>L'esportazione in corso o l'ultima fatta: una alla volta, annullabile.</summary>
|
||||
@@ -68,18 +66,6 @@ public sealed partial class Bot
|
||||
Exports = new CsvExport(Db, Queue, Paths, () => Settings.Current, name => _world is { } w && w.Name == name ? w.Learning : null);
|
||||
ExportJobs = new ExportJobs(Exports, Log, Lifetime);
|
||||
|
||||
Login = new AssistedLogin(Paths.Browser, () => ReferencesProvider.Current, Log);
|
||||
Login.Frame += (data, w, h, url) => Hub.Broadcast(new Dictionary<string, object?>
|
||||
{
|
||||
["t"] = "login.frame", ["jpegBase64"] = data, ["w"] = w, ["h"] = h, ["url"] = url
|
||||
}, page: "accesso");
|
||||
Login.State += (state, detail) => Hub.Broadcast(new Dictionary<string, object?> { ["t"] = "login.state", ["state"] = state, ["detail"] = detail });
|
||||
Login.LoggedIn += async session =>
|
||||
{
|
||||
var (ok, msg) = await UseSessionAsync(session, Lifetime).ConfigureAwait(false);
|
||||
Hub.Broadcast(new Dictionary<string, object?> { ["t"] = "login.state", ["state"] = ok ? "riuscito" : "errore", ["detail"] = msg });
|
||||
};
|
||||
|
||||
Host.SetStartingStep("riscaldamento del motore");
|
||||
await Warmup.RunAsync(ReferencesProvider.Current, Log, ct).ConfigureAwait(false);
|
||||
|
||||
@@ -96,7 +82,6 @@ public sealed partial class Bot
|
||||
|
||||
private async Task StopServicesAsync()
|
||||
{
|
||||
if (Login != null) await Login.DisposeAsync().ConfigureAwait(false);
|
||||
if (Hub != null) await Hub.DisposeAsync().ConfigureAwait(false);
|
||||
var world = _world;
|
||||
_world = null;
|
||||
@@ -142,7 +127,7 @@ public sealed partial class Bot
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Una sessione nuova (accesso assistito o cookie incollati): si salva, si verifica, si passa al sito vero.</summary>
|
||||
/// <summary>Una sessione nuova (incollata dall'utente): si salva, si passa al sito vero, si verifica.</summary>
|
||||
public async Task<(bool Ok, string Message)> UseSessionAsync(BidooSession session, CancellationToken ct)
|
||||
{
|
||||
Sessions.Save(session);
|
||||
@@ -158,7 +143,7 @@ public sealed partial class Bot
|
||||
}
|
||||
return ok
|
||||
? (true, $"Collegato come {World.Account.Username}: {World.Account.BalanceText()} puntate")
|
||||
: (false, "Sessione salvata ma Bidoo non la riconosce: controlla i cookie o rifai l'accesso assistito");
|
||||
: (false, "Sessione salvata ma Bidoo non la riconosce: ricopiala da Chrome con il tuo utente collegato a Bidoo");
|
||||
}
|
||||
|
||||
/// <summary>«Disconnetti»: la sessione si cancella; il bot continua a seguire le aste senza puntare.</summary>
|
||||
|
||||
@@ -207,7 +207,7 @@ public sealed class BotWorld : IAsyncDisposable
|
||||
? "Modalità debug: stai vedendo il simulatore (nessuna sessione Bidoo salvata)"
|
||||
: HasSession
|
||||
? $"Sito vero: sessione di {Account.Username ?? "utente da verificare"} ({Account.SessionSource}), {Monitor.Auctions.Count} aste in elenco"
|
||||
: $"Sito vero senza utente collegato: segue le aste e impara, non punta. Accedi dal Browser per puntare. {Monitor.Auctions.Count} aste in elenco");
|
||||
: $"Sito vero senza utente collegato: segue le aste e impara, non punta. Collega l'utente da Accesso a Bidoo per puntare. {Monitor.Auctions.Count} aste in elenco");
|
||||
}
|
||||
|
||||
/// <summary>Al primo giro nel simulatore l'elenco non è vuoto: qualche asta in ogni modo, per vedere il bot all'opera.</summary>
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Mimante.Net;
|
||||
/// <list type="bullet">
|
||||
/// <item>Un solo <see cref="SocketsHttpHandler"/> con pool ampio e connessioni calde,
|
||||
/// HTTP/2 con ripiego, decompressione automatica, cookie a mano.</item>
|
||||
/// <item>User-Agent: lo stesso del browser dell'accesso assistito, salvato con la sessione.</item>
|
||||
/// <item>User-Agent: lo stesso del browser da cui si è copiata la sessione, salvato con lei.</item>
|
||||
/// <item>Token bucket (spento di fabbrica: <c>MaxRequestsPerSecond</c> = 0) con riserva per il
|
||||
/// polling, semaforo di concorrenza; le richieste <see cref="RequestPriority.Critical"/> saltano
|
||||
/// entrambi.</item>
|
||||
|
||||
@@ -50,6 +50,8 @@ catch
|
||||
var log = new AppLog(fileLog) { EchoToConsole = true };
|
||||
log.Info("AVVIO", $"{AppInfo.Name} {AppInfo.Version}, .NET {Environment.Version}, {Environment.OSVersion}, " +
|
||||
$"cartella dati {paths.Root}, interfaccia sulla porta {env.HttpPort}");
|
||||
if (paths.RemoveOldBrowserProfile())
|
||||
log.Info("AVVIO", $"Cancellato {paths.OldBrowserProfile}: il profilo del browser del bot della 1.x, non più usato, con una copia dei cookie di Bidoo");
|
||||
|
||||
await using var host = new BotHost(env, paths, log, fileLog);
|
||||
var app = WebServer.Build(host);
|
||||
|
||||
@@ -1,328 +0,0 @@
|
||||
using System.Text.Json;
|
||||
using Mimante.Bidoo;
|
||||
using Mimante.Logging;
|
||||
using Mimante.Net;
|
||||
|
||||
namespace Mimante.Session.Cdp;
|
||||
|
||||
/// <summary>Un gesto dell'utente sul riquadro del browser, in pixel della pagina.</summary>
|
||||
public sealed record LoginInput(
|
||||
string Kind, string? Type, double X, double Y, string? Button, int ClickCount, string? Key, string? Code, string? Text,
|
||||
int Modifiers, double DeltaX, double DeltaY, int KeyCode)
|
||||
{
|
||||
public static LoginInput From(JsonElement m)
|
||||
{
|
||||
string? S(string n) => m.TryGetProperty(n, out var v) && v.ValueKind == JsonValueKind.String ? v.GetString() : null;
|
||||
double D(string n) => m.TryGetProperty(n, out var v) && v.ValueKind == JsonValueKind.Number ? v.GetDouble() : 0;
|
||||
return new LoginInput(S("kind") ?? "", S("type"), D("x"), D("y"), S("button"), (int)D("clickCount"), S("key"), S("code"), S("text"),
|
||||
(int)D("modifiers"), D("deltaX"), D("deltaY"), (int)D("keyCode"));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// L'accesso assistito (specifica §6.5): Chromium senza finestra apre la pagina di login di
|
||||
/// Bidoo, l'interfaccia ne mostra lo screencast e inoltra clic e tasti. È il «Browser» del
|
||||
/// bot (come nella versione desktop): si naviga dentro Bidoo con indietro, avanti, indirizzo e
|
||||
/// home, e un'asta aperta si aggiunge al monitor. Aperto senza sessione, riconosce il login:
|
||||
/// quando l'indirizzo esce dal login e c'è il cookie di sessione, i cookie si salvano (una
|
||||
/// volta) e il browser resta aperto per continuare a navigare. La password di Bidoo passa solo
|
||||
/// dal browser del bot a Bidoo: il bot non la vede come campo, vede soltanto tasti.
|
||||
/// </summary>
|
||||
public sealed class AssistedLogin : IAsyncDisposable
|
||||
{
|
||||
private readonly string _profileDir;
|
||||
private readonly Func<BidooReferences> _refs;
|
||||
private readonly AppLog _log;
|
||||
private readonly SemaphoreSlim _gate = new(1, 1);
|
||||
private ChromiumProcess? _chromium;
|
||||
private CdpClient? _cdp;
|
||||
private string? _session;
|
||||
private string? _userAgent;
|
||||
private string _url = "";
|
||||
private CancellationTokenSource? _watch;
|
||||
private long _lastInput;
|
||||
private volatile bool _done;
|
||||
private volatile bool _detectLogin;
|
||||
private TaskCompletionSource? _loaded;
|
||||
|
||||
/// <summary>Senza gesti per tanto tempo il browser si chiude (libera la memoria di Chromium).</summary>
|
||||
public static readonly TimeSpan IdleTimeout = TimeSpan.FromMinutes(30);
|
||||
|
||||
public AssistedLogin(string profileDir, Func<BidooReferences> refs, AppLog log)
|
||||
{
|
||||
_profileDir = profileDir;
|
||||
_refs = refs;
|
||||
_log = log;
|
||||
}
|
||||
|
||||
/// <summary>Un fotogramma JPEG (base64), le sue dimensioni in pixel della pagina, l'indirizzo.</summary>
|
||||
public event Action<string, int, int, string>? Frame;
|
||||
|
||||
/// <summary>«aperto», «riuscito», «chiuso», «errore», con il dettaglio.</summary>
|
||||
public event Action<string, string?>? State;
|
||||
|
||||
/// <summary>L'accesso è riuscito: la sessione da salvare.</summary>
|
||||
public event Func<BidooSession, Task>? LoggedIn;
|
||||
|
||||
public bool IsOpen => _cdp != null && !_cdp.IsClosed;
|
||||
public string CurrentUrl => _url;
|
||||
|
||||
public static bool Available => ChromiumProcess.FindExecutable() != null;
|
||||
|
||||
/// <summary>
|
||||
/// Apre il browser: sulla pagina di login se nessun utente è collegato (e allora riconosce
|
||||
/// l'accesso), sulla home di Bidoo altrimenti.
|
||||
/// </summary>
|
||||
public async Task<(bool Ok, string Message)> OpenAsync(bool loggedIn, CancellationToken ct)
|
||||
{
|
||||
await _gate.WaitAsync(ct).ConfigureAwait(false);
|
||||
try
|
||||
{
|
||||
if (IsOpen)
|
||||
{
|
||||
State?.Invoke("aperto", _url);
|
||||
return (true, "Il browser del bot è già aperto");
|
||||
}
|
||||
await CloseCoreAsync(null).ConfigureAwait(false);
|
||||
_done = false;
|
||||
_detectLogin = !loggedIn;
|
||||
|
||||
var refs = _refs();
|
||||
_chromium = await ChromiumProcess.StartAsync(_profileDir, ct).ConfigureAwait(false);
|
||||
_cdp = await CdpClient.ConnectAsync(_chromium.Endpoint, ct).ConfigureAwait(false);
|
||||
_cdp.Event += OnEvent;
|
||||
_cdp.Closed += () => { if (!_done) State?.Invoke("chiuso", "il browser del bot si è chiuso"); };
|
||||
|
||||
var version = await _cdp.SendAsync("Browser.getVersion", ct: ct).ConfigureAwait(false);
|
||||
_userAgent = (version.TryGetProperty("userAgent", out var ua) ? ua.GetString() : null)?.Replace("HeadlessChrome", "Chrome", StringComparison.Ordinal);
|
||||
|
||||
var target = await _cdp.SendAsync("Target.createTarget", new { url = "about:blank" }, ct: ct).ConfigureAwait(false);
|
||||
var targetId = target.GetProperty("targetId").GetString();
|
||||
var attached = await _cdp.SendAsync("Target.attachToTarget", new { targetId, flatten = true }, ct: ct).ConfigureAwait(false);
|
||||
_session = attached.GetProperty("sessionId").GetString();
|
||||
|
||||
await _cdp.SendAsync("Page.enable", sessionId: _session, ct: ct).ConfigureAwait(false);
|
||||
await _cdp.SendAsync("Network.enable", sessionId: _session, ct: ct).ConfigureAwait(false);
|
||||
if (_userAgent != null)
|
||||
await _cdp.SendAsync("Network.setUserAgentOverride", new { userAgent = _userAgent, acceptLanguage = "it-IT,it;q=0.9,en;q=0.7" }, _session, ct).ConfigureAwait(false);
|
||||
await _cdp.SendAsync("Emulation.setDeviceMetricsOverride", new { width = 1280, height = 900, deviceScaleFactor = 1, mobile = false }, _session, ct).ConfigureAwait(false);
|
||||
_loaded = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var start = loggedIn ? refs.BaseUrl + "/" : refs.Url(refs.Endpoints.Login);
|
||||
await _cdp.SendAsync("Page.navigate", new { url = start }, _session, ct).ConfigureAwait(false);
|
||||
|
||||
// Da about:blank a Bidoo la pagina cambia processo: lo screencast parte a caricamento
|
||||
// finito, con qualche ritentativo («Not attached to an active page» nel frattempo).
|
||||
try { await _loaded.Task.WaitAsync(TimeSpan.FromSeconds(15), ct).ConfigureAwait(false); }
|
||||
catch (TimeoutException) { /* pagina lenta: si prova lo stesso */ }
|
||||
await StartScreencastAsync(ct).ConfigureAwait(false);
|
||||
|
||||
_lastInput = Environment.TickCount64;
|
||||
_watch = new CancellationTokenSource();
|
||||
_ = Task.Run(() => WatchAsync(_watch.Token));
|
||||
_log.Info("SESSIONE", loggedIn ? "Browser del bot aperto sulla home di Bidoo" : "Browser del bot aperto sulla pagina di login di Bidoo");
|
||||
State?.Invoke("aperto", start);
|
||||
return (true, loggedIn ? "Browser del bot aperto" : "Browser del bot aperto: accedi a Bidoo nel riquadro");
|
||||
}
|
||||
catch (Exception ex) when (ex is not OperationCanceledException)
|
||||
{
|
||||
await CloseCoreAsync(null).ConfigureAwait(false);
|
||||
var msg = $"Browser del bot non avviato: {ex.Message}";
|
||||
_log.Warn("SESSIONE", msg);
|
||||
State?.Invoke("errore", msg);
|
||||
return (false, msg);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_gate.Release();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task StartScreencastAsync(CancellationToken ct)
|
||||
{
|
||||
for (var attempt = 1; ; attempt++)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _cdp!.SendAsync("Page.startScreencast", new { format = "jpeg", quality = 60, maxWidth = 1280, maxHeight = 900, everyNthFrame = 1 }, _session, ct).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
catch (CdpException) when (attempt < 10)
|
||||
{
|
||||
await Task.Delay(500, ct).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEvent(string method, JsonElement p, string? session)
|
||||
{
|
||||
switch (method)
|
||||
{
|
||||
case "Page.loadEventFired":
|
||||
_loaded?.TrySetResult();
|
||||
break;
|
||||
case "Page.screencastFrame":
|
||||
var frameSession = p.GetProperty("sessionId").GetInt32();
|
||||
_cdp?.Post("Page.screencastFrameAck", new { sessionId = frameSession }, _session);
|
||||
var meta = p.GetProperty("metadata");
|
||||
var w = (int)Math.Round(meta.GetProperty("deviceWidth").GetDouble());
|
||||
var h = (int)Math.Round(meta.GetProperty("deviceHeight").GetDouble());
|
||||
Frame?.Invoke(p.GetProperty("data").GetString() ?? "", w, h, _url);
|
||||
break;
|
||||
case "Page.frameNavigated":
|
||||
var frame = p.GetProperty("frame");
|
||||
if (!frame.TryGetProperty("parentId", out _)) _url = frame.GetProperty("url").GetString() ?? "";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Ogni secondo: siamo usciti dal login con il cookie di sessione? Mezz'ora ferma chiude il browser.</summary>
|
||||
private async Task WatchAsync(CancellationToken ct)
|
||||
{
|
||||
while (!ct.IsCancellationRequested && IsOpen)
|
||||
{
|
||||
try { await Task.Delay(1000, ct).ConfigureAwait(false); } catch (OperationCanceledException) { return; }
|
||||
if (Environment.TickCount64 - _lastInput > IdleTimeout.TotalMilliseconds)
|
||||
{
|
||||
await CloseAsync("mezz'ora senza attività").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
if (!_detectLogin) continue;
|
||||
|
||||
try
|
||||
{
|
||||
var refs = _refs();
|
||||
if (IsLoginUrl(_url, refs)) continue;
|
||||
if (!_url.StartsWith(refs.BaseUrl, StringComparison.OrdinalIgnoreCase)) continue;
|
||||
|
||||
var result = await _cdp!.SendAsync("Network.getCookies", new { urls = new[] { refs.BaseUrl + "/" } }, _session, ct).ConfigureAwait(false);
|
||||
var cookies = new List<(string, string)>();
|
||||
foreach (var c in result.GetProperty("cookies").EnumerateArray())
|
||||
cookies.Add((c.GetProperty("name").GetString() ?? "", c.GetProperty("value").GetString() ?? ""));
|
||||
if (!cookies.Any(c => c.Item1 == refs.Recognizers.SessionCookie)) continue;
|
||||
|
||||
// Una volta sola: il browser resta aperto per navigare.
|
||||
_detectLogin = false;
|
||||
var session = new BidooSession { Cookie = CookieText.Join(cookies), UserAgent = _userAgent, Source = SessionStore.SourceAssisted };
|
||||
State?.Invoke("riuscito", "Accesso riuscito: salvo la sessione");
|
||||
_log.Success("SESSIONE", "Accesso dal Browser riuscito: cookie di sessione ricevuti");
|
||||
if (LoggedIn != null) await LoggedIn(session).ConfigureAwait(false);
|
||||
}
|
||||
catch (OperationCanceledException) { return; }
|
||||
catch (CdpException) { /* pagina in caricamento: si riprova */ }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Siamo ancora sul login? Oltre ai segni dei riferimenti, Bidoo apre il login anche come
|
||||
/// finestra sulla home (<c>/?login=true&redirect=…</c>).
|
||||
/// </summary>
|
||||
internal static bool IsLoginUrl(string url, BidooReferences refs) =>
|
||||
url.Length == 0 ||
|
||||
refs.Recognizers.LoginPageMarkers.Any(m => url.Contains(m, StringComparison.OrdinalIgnoreCase)) ||
|
||||
url.Contains("login=true", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
public async Task InputAsync(LoginInput input, CancellationToken ct)
|
||||
{
|
||||
var cdp = _cdp;
|
||||
if (cdp == null || !IsOpen) return;
|
||||
_lastInput = Environment.TickCount64;
|
||||
switch (input.Kind)
|
||||
{
|
||||
case "mouse":
|
||||
var type = input.Type is "mousePressed" or "mouseReleased" or "mouseMoved" or "mouseWheel" ? input.Type : "mouseMoved";
|
||||
await cdp.SendAsync("Input.dispatchMouseEvent", new
|
||||
{
|
||||
type, x = input.X, y = input.Y, button = input.Button ?? (type == "mouseMoved" ? "none" : "left"),
|
||||
clickCount = Math.Max(input.ClickCount, type is "mousePressed" or "mouseReleased" ? 1 : 0),
|
||||
modifiers = input.Modifiers, deltaX = input.DeltaX, deltaY = input.DeltaY
|
||||
}, _session, ct).ConfigureAwait(false);
|
||||
break;
|
||||
case "key":
|
||||
var keyType = input.Type == "keyUp" ? "keyUp" : "keyDown";
|
||||
// I tasti che scrivono passano da insertText (più affidabile con le tastiere italiane);
|
||||
// qui restano quelli di controllo: Invio, Tab, frecce, cancellazione.
|
||||
await cdp.SendAsync("Input.dispatchKeyEvent", new
|
||||
{
|
||||
type = keyType == "keyDown" ? "rawKeyDown" : "keyUp", key = input.Key, code = input.Code,
|
||||
windowsVirtualKeyCode = input.KeyCode, nativeVirtualKeyCode = input.KeyCode, modifiers = input.Modifiers
|
||||
}, _session, ct).ConfigureAwait(false);
|
||||
if (keyType == "keyDown" && input.Key == "Enter")
|
||||
await cdp.SendAsync("Input.dispatchKeyEvent", new { type = "char", text = "\r", key = "Enter" }, _session, ct).ConfigureAwait(false);
|
||||
break;
|
||||
case "text":
|
||||
if (!string.IsNullOrEmpty(input.Text))
|
||||
await cdp.SendAsync("Input.insertText", new { text = input.Text }, _session, ct).ConfigureAwait(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Indietro (-1) o avanti (+1) nella cronologia della scheda.</summary>
|
||||
public async Task HistoryAsync(int delta, CancellationToken ct)
|
||||
{
|
||||
if (_cdp == null || !IsOpen) return;
|
||||
_lastInput = Environment.TickCount64;
|
||||
var h = await _cdp.SendAsync("Page.getNavigationHistory", sessionId: _session, ct: ct).ConfigureAwait(false);
|
||||
var index = h.GetProperty("currentIndex").GetInt32() + delta;
|
||||
var entries = h.GetProperty("entries");
|
||||
if (index < 0 || index >= entries.GetArrayLength()) return;
|
||||
var entryId = entries[index].GetProperty("id").GetInt32();
|
||||
await _cdp.SendAsync("Page.navigateToHistoryEntry", new { entryId }, _session, ct).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Va a un indirizzo di Bidoo (anche solo un percorso come «/auction.php?a=…», o vuoto per
|
||||
/// la home). Solo pagine di Bidoo: è il browser del bot, non un browser qualunque.
|
||||
/// </summary>
|
||||
public async Task<(bool Ok, string Message)> NavigateAsync(string address, CancellationToken ct)
|
||||
{
|
||||
if (_cdp == null || !IsOpen) return (false, "Il browser del bot è chiuso");
|
||||
var refs = _refs();
|
||||
var text = (address ?? "").Trim();
|
||||
var url = text.Length == 0 ? refs.BaseUrl + "/"
|
||||
: text.StartsWith('/') ? refs.BaseUrl + text
|
||||
: text.Contains("://", StringComparison.Ordinal) ? text : "https://" + text;
|
||||
if (!Uri.TryCreate(url, UriKind.Absolute, out var uri) || !uri.Host.Contains("bidoo", StringComparison.OrdinalIgnoreCase))
|
||||
return (false, "Il Browser apre solo le pagine di Bidoo");
|
||||
_lastInput = Environment.TickCount64;
|
||||
await _cdp.SendAsync("Page.navigate", new { url = uri.ToString() }, _session, ct).ConfigureAwait(false);
|
||||
return (true, "");
|
||||
}
|
||||
|
||||
public async Task ReloadAsync(CancellationToken ct)
|
||||
{
|
||||
if (_cdp == null || !IsOpen) return;
|
||||
_lastInput = Environment.TickCount64;
|
||||
await _cdp.SendAsync("Page.reload", new { ignoreCache = false }, _session, ct).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task CloseAsync(string? reason)
|
||||
{
|
||||
await _gate.WaitAsync().ConfigureAwait(false);
|
||||
try { await CloseCoreAsync(reason).ConfigureAwait(false); }
|
||||
finally { _gate.Release(); }
|
||||
}
|
||||
|
||||
private async Task CloseCoreAsync(string? reason)
|
||||
{
|
||||
_watch?.Cancel();
|
||||
_watch = null;
|
||||
var cdp = _cdp;
|
||||
_cdp = null;
|
||||
if (cdp != null)
|
||||
{
|
||||
try { await cdp.SendAsync("Browser.close", timeout: TimeSpan.FromSeconds(3)).ConfigureAwait(false); } catch { }
|
||||
await cdp.DisposeAsync().ConfigureAwait(false);
|
||||
}
|
||||
var chromium = _chromium;
|
||||
_chromium = null;
|
||||
if (chromium != null) await chromium.DisposeAsync().ConfigureAwait(false);
|
||||
_session = null;
|
||||
if (reason != null)
|
||||
{
|
||||
_log.Info("SESSIONE", $"Browser del bot chiuso: {reason}");
|
||||
State?.Invoke("chiuso", reason);
|
||||
}
|
||||
}
|
||||
|
||||
public async ValueTask DisposeAsync() => await CloseAsync(null).ConfigureAwait(false);
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Mimante.Net;
|
||||
|
||||
namespace Mimante.Session;
|
||||
|
||||
/// <summary>Quello che si ricava da un testo incollato: i cookie e, se c'è, lo User-Agent.</summary>
|
||||
public sealed record PastedSession(string? Cookie, string? UserAgent, string? Error, string Format = "");
|
||||
|
||||
/// <summary>
|
||||
/// La sessione di Bidoo incollata dall'utente (ADR 0017). Accetta, dal più comodo:
|
||||
/// <list type="bullet">
|
||||
/// <item>«Copy as cURL» di Chrome o Edge, nelle due varianti (bash con <c>'…'</c> e cmd con <c>^"…^"</c>),
|
||||
/// con i cookie in <c>-b</c> o in <c>-H 'cookie: …'</c> e lo User-Agent in <c>-H 'user-agent: …'</c> o <c>-A</c>;</item>
|
||||
/// <item>«Copy as PowerShell» (<c>New-Object System.Net.Cookie("nome", "valore", …)</c> e <c>$session.UserAgent</c>);</item>
|
||||
/// <item>le intestazioni della richiesta copiate dal pannello Rete, anche con il nome su una riga e il valore sulla successiva;</item>
|
||||
/// <item>la sola riga <c>Cookie</c>, con o senza il prefisso;</item>
|
||||
/// <item>righe copiate dalla tabella dei cookie (nome e valore separati da tabulazione);</item>
|
||||
/// <item>il solo valore del cookie di accesso (<c>__stattrb</c>).</item>
|
||||
/// </list>
|
||||
/// Pura, sotto test: non registra mai il testo, che contiene la sessione.
|
||||
/// </summary>
|
||||
public static class SessionPaste
|
||||
{
|
||||
private static readonly Regex HeaderLine = new(@"^\s*(cookie|user-agent)\s*:\s*(.*)$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
|
||||
private static readonly Regex HeaderNameOnly = new(@"^\s*(cookie|user-agent)\s*:?\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
|
||||
private static readonly Regex PsCookie = new(@"New-Object\s+System\.Net\.Cookie\(\s*""((?:[^""`]|`.)*)""\s*,\s*""((?:[^""`]|`.)*)""", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
|
||||
private static readonly Regex PsUserAgent = new(@"\.UserAgent\s*=\s*""((?:[^""`]|`.)*)""", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
|
||||
private static readonly Regex CookieName = new(@"^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$", RegexOptions.CultureInvariant);
|
||||
|
||||
public static PastedSession Parse(string? text, string sessionCookie = "__stattrb")
|
||||
{
|
||||
var t = (text ?? "").Trim();
|
||||
if (t.Length == 0) return new(null, null, "Incolla il testo copiato da Chrome: «Copy as cURL», la riga Cookie o il valore di " + sessionCookie);
|
||||
|
||||
string? cookie = null, ua = null, format;
|
||||
if (Regex.IsMatch(t, @"^curl(\.exe)?\s", RegexOptions.IgnoreCase))
|
||||
{
|
||||
(cookie, ua) = FromCurl(t);
|
||||
format = "cURL";
|
||||
}
|
||||
else if (PsCookie.IsMatch(t))
|
||||
{
|
||||
var parts = PsCookie.Matches(t).Select(m => (PsUnescape(m.Groups[1].Value), PsUnescape(m.Groups[2].Value)));
|
||||
cookie = CookieText.Join(parts);
|
||||
if (PsUserAgent.Match(t) is { Success: true } m) ua = PsUnescape(m.Groups[1].Value);
|
||||
format = "PowerShell";
|
||||
}
|
||||
else
|
||||
{
|
||||
(cookie, ua, format) = FromLines(t);
|
||||
}
|
||||
|
||||
var cookies = CookieText.Split(cookie).Where(c => CookieName.IsMatch(c.Name)).ToList();
|
||||
if (!cookies.Any(c => c.Name == sessionCookie && c.Value.Length > 0))
|
||||
{
|
||||
// Un solo pezzo senza spazi, «;» né forma nome=valore (un «=» finale è il riempimento
|
||||
// del base64): è il valore del cookie di accesso.
|
||||
if (format == "" && !t.Contains(';') && !t.Any(char.IsWhiteSpace) && !Regex.IsMatch(t, "^[^=]+=[^=]"))
|
||||
return new(CookieText.Join([(sessionCookie, t)]), null, null, "valore di " + sessionCookie);
|
||||
return new(null, ua, cookies.Count == 0
|
||||
? "Nessun cookie riconosciuto nel testo incollato: copia la richiesta con «Copy as cURL» o la riga Cookie"
|
||||
: $"Manca il cookie {sessionCookie}: la richiesta copiata non è di un utente collegato a Bidoo");
|
||||
}
|
||||
return new(CookieText.Join(cookies), string.IsNullOrWhiteSpace(ua) ? null : ua.Trim(), null, format == "" ? "riga Cookie" : format);
|
||||
}
|
||||
|
||||
// ── cURL ──────────────────────────────────────────────────────────
|
||||
|
||||
private static (string? Cookie, string? UserAgent) FromCurl(string t)
|
||||
{
|
||||
// La variante per cmd: ^ protegge il carattere che segue e ^ a fine riga continua la riga.
|
||||
if (t.Contains("^\"", StringComparison.Ordinal))
|
||||
{
|
||||
t = Regex.Replace(t, @"\^\r?\n", " ");
|
||||
t = t.Replace("\\^\"", "\\\"", StringComparison.Ordinal);
|
||||
t = Regex.Replace(t, @"\^(.)", "$1");
|
||||
}
|
||||
var args = ShellWords(t);
|
||||
var cookies = new List<string>();
|
||||
string? ua = null;
|
||||
for (var i = 0; i < args.Count - 1; i++)
|
||||
{
|
||||
var a = args[i];
|
||||
var next = args[i + 1];
|
||||
switch (a)
|
||||
{
|
||||
case "-H" or "--header":
|
||||
if (HeaderLine.Match(next) is { Success: true } h)
|
||||
{
|
||||
if (h.Groups[1].Value.Equals("cookie", StringComparison.OrdinalIgnoreCase)) cookies.Add(h.Groups[2].Value);
|
||||
else ua = h.Groups[2].Value;
|
||||
}
|
||||
i++;
|
||||
break;
|
||||
case "-b" or "--cookie":
|
||||
cookies.Add(next);
|
||||
i++;
|
||||
break;
|
||||
case "-A" or "--user-agent":
|
||||
ua = next;
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return (cookies.Count == 0 ? null : string.Join("; ", cookies), ua);
|
||||
}
|
||||
|
||||
/// <summary>Le parole di una riga di comando come le divide la shell: virgolette semplici, doppie e <c>$'…'</c>.</summary>
|
||||
internal static List<string> ShellWords(string s)
|
||||
{
|
||||
var words = new List<string>();
|
||||
var sb = new StringBuilder();
|
||||
var inWord = false;
|
||||
for (var i = 0; i < s.Length; i++)
|
||||
{
|
||||
var c = s[i];
|
||||
if (c == '\\' && i + 1 < s.Length && (s[i + 1] == '\n' || s[i + 1] == '\r'))
|
||||
{
|
||||
// Continuazione della riga.
|
||||
i++;
|
||||
if (s[i] == '\r' && i + 1 < s.Length && s[i + 1] == '\n') i++;
|
||||
continue;
|
||||
}
|
||||
if (char.IsWhiteSpace(c))
|
||||
{
|
||||
if (inWord) { words.Add(sb.ToString()); sb.Clear(); inWord = false; }
|
||||
continue;
|
||||
}
|
||||
inWord = true;
|
||||
if (c == '$' && i + 1 < s.Length && s[i + 1] == '\'')
|
||||
{
|
||||
i += 2;
|
||||
for (; i < s.Length && s[i] != '\''; i++)
|
||||
{
|
||||
if (s[i] == '\\' && i + 1 < s.Length)
|
||||
{
|
||||
i++;
|
||||
sb.Append(s[i] switch { 'n' => '\n', 't' => '\t', 'r' => '\r', _ => s[i] });
|
||||
}
|
||||
else sb.Append(s[i]);
|
||||
}
|
||||
}
|
||||
else if (c == '\'')
|
||||
{
|
||||
for (i++; i < s.Length && s[i] != '\''; i++) sb.Append(s[i]);
|
||||
}
|
||||
else if (c == '"')
|
||||
{
|
||||
for (i++; i < s.Length && s[i] != '"'; i++)
|
||||
{
|
||||
if (s[i] == '\\' && i + 1 < s.Length && s[i + 1] is '"' or '\\' or '$' or '`') i++;
|
||||
sb.Append(s[i]);
|
||||
}
|
||||
}
|
||||
else if (c == '\\' && i + 1 < s.Length)
|
||||
{
|
||||
sb.Append(s[++i]);
|
||||
}
|
||||
else sb.Append(c);
|
||||
}
|
||||
if (inWord) words.Add(sb.ToString());
|
||||
return words;
|
||||
}
|
||||
|
||||
// ── intestazioni, riga Cookie, tabella dei cookie ─────────────────
|
||||
|
||||
private static (string? Cookie, string? UserAgent, string Format) FromLines(string t)
|
||||
{
|
||||
var lines = t.Replace("\r", "").Split('\n');
|
||||
var cookies = new List<string>();
|
||||
string? ua = null;
|
||||
var headers = false;
|
||||
var table = new List<(string, string)>();
|
||||
for (var i = 0; i < lines.Length; i++)
|
||||
{
|
||||
var line = lines[i];
|
||||
if (HeaderNameOnly.Match(line) is { Success: true } n)
|
||||
{
|
||||
// Il pannello delle intestazioni di Chrome copia il nome su una riga e il valore sotto.
|
||||
var j = i + 1;
|
||||
while (j < lines.Length && lines[j].Trim().Length == 0) j++;
|
||||
if (j < lines.Length)
|
||||
{
|
||||
Take(n.Groups[1].Value, lines[j].Trim());
|
||||
i = j;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (HeaderLine.Match(line) is { Success: true } h)
|
||||
{
|
||||
Take(h.Groups[1].Value, h.Groups[2].Value);
|
||||
continue;
|
||||
}
|
||||
var cells = line.Split('\t');
|
||||
if (cells.Length >= 2 && CookieName.IsMatch(cells[0].Trim()) && cells[1].Trim().Length > 0)
|
||||
table.Add((cells[0].Trim(), cells[1].Trim()));
|
||||
}
|
||||
if (headers) return (string.Join("; ", cookies), ua, "intestazioni");
|
||||
if (table.Count > 0) return (CookieText.Join(table), null, "tabella dei cookie");
|
||||
// La riga Cookie da sola, anche spezzata su più righe.
|
||||
return (t.Replace("\r", "").Replace("\n", ""), null, "");
|
||||
|
||||
void Take(string name, string value)
|
||||
{
|
||||
headers = true;
|
||||
if (name.Equals("cookie", StringComparison.OrdinalIgnoreCase)) cookies.Add(value);
|
||||
else ua = value;
|
||||
}
|
||||
}
|
||||
|
||||
private static string PsUnescape(string s) => Regex.Replace(s, "`(.)", "$1");
|
||||
}
|
||||
@@ -13,7 +13,7 @@ public sealed class BidooSession
|
||||
public string? Username { get; set; }
|
||||
public string? UserId { get; set; }
|
||||
|
||||
/// <summary>«accesso assistito» o «cookie incollati».</summary>
|
||||
/// <summary>Da dove viene: «cookie incollati» (le sessioni della 1.x possono dire «accesso assistito»).</summary>
|
||||
public string Source { get; set; } = "";
|
||||
|
||||
public DateTime SavedAtUtc { get; set; } = DateTime.UtcNow;
|
||||
@@ -30,7 +30,6 @@ public sealed class BidooSession
|
||||
/// </summary>
|
||||
public sealed class SessionStore
|
||||
{
|
||||
public const string SourceAssisted = "accesso assistito";
|
||||
public const string SourcePasted = "cookie incollati";
|
||||
|
||||
private readonly string _folder;
|
||||
@@ -134,20 +133,4 @@ public sealed class SessionStore
|
||||
ConfigPaths.RestrictToOwner(KeyPath);
|
||||
return key;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// I cookie incollati dall'utente: la riga intera dell'intestazione <c>Cookie</c>, con o
|
||||
/// senza il prefisso «Cookie:». Serve almeno <c>__stattrb</c> (il cookie di accesso).
|
||||
/// </summary>
|
||||
public static (string? Cookie, string? Error) NormalizePastedCookie(string? text, string sessionCookie = "__stattrb")
|
||||
{
|
||||
var t = (text ?? "").Trim();
|
||||
if (t.StartsWith("cookie:", StringComparison.OrdinalIgnoreCase)) t = t[7..].Trim();
|
||||
t = t.Replace("\r", "").Replace("\n", "");
|
||||
if (t.Length == 0) return (null, "Incolla la riga Cookie intera");
|
||||
var parts = Net.CookieText.Split(t);
|
||||
if (parts.Count == 0) return (null, "Nessun cookie riconosciuto: il formato è nome=valore; nome=valore");
|
||||
if (!parts.Any(p => p.Name == sessionCookie)) return (null, $"Manca il cookie {sessionCookie}: non è la sessione di un utente collegato");
|
||||
return (Net.CookieText.Join(parts), null);
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ public static class Pages
|
||||
|
||||
private static string Head(string title) => $$"""
|
||||
<!doctype html>
|
||||
<html lang="it" data-theme="dark">
|
||||
<html lang="it" data-theme="auto">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
@@ -167,6 +167,7 @@ public static class WebServer
|
||||
private static bool IsPublicAsset(string path) =>
|
||||
path.StartsWith("/css/", StringComparison.Ordinal) ||
|
||||
path.StartsWith("/img/", StringComparison.Ordinal) ||
|
||||
path.StartsWith("/fonts/", StringComparison.Ordinal) ||
|
||||
path == "/favicon.ico";
|
||||
|
||||
private static async Task LoginPageAsync(UiAuth auth, HttpContext ctx, string client, string? error)
|
||||
|
||||
@@ -6,7 +6,6 @@ using Mimante.Engine;
|
||||
using Mimante.Ml;
|
||||
using Mimante.Products;
|
||||
using Mimante.Session;
|
||||
using Mimante.Session.Cdp;
|
||||
using Mimante.Settings;
|
||||
|
||||
namespace Mimante.Web;
|
||||
@@ -172,61 +171,28 @@ public sealed partial class WebSocketHub
|
||||
case "maintenance.run":
|
||||
return new Ack(true, await _bot.Maintenance.RunOnceAsync(full: Bool(m, "full"), ct).ConfigureAwait(false));
|
||||
|
||||
// ── sessione e accesso assistito ──────────────────────────
|
||||
// ── sessione di Bidoo ──────────────────────────
|
||||
case "session.verify":
|
||||
if (world.Checker == null)
|
||||
return new Ack(false, world.IsSimulator ? "Modalità debug: stai vedendo il simulatore" : "Nessun utente Bidoo collegato: accedi dal Browser");
|
||||
return new Ack(false, world.IsSimulator ? "Modalità debug: stai vedendo il simulatore" : "Nessun utente Bidoo collegato: incolla la sessione in Accesso a Bidoo");
|
||||
return await world.Checker.VerifyAsync(full: true, ct).ConfigureAwait(false)
|
||||
? new Ack(true, $"Sessione valida: {world.Account.Username}, {world.Account.BalanceText()} puntate")
|
||||
: new Ack(false, world.Account.StatusDetail ?? "Bidoo non riconosce la sessione");
|
||||
case "session.paste":
|
||||
{
|
||||
var (cookie, error) = SessionStore.NormalizePastedCookie(Str(m, "cookie"), world.References().Recognizers.SessionCookie);
|
||||
if (cookie == null) return new Ack(false, error);
|
||||
var ua = Str(m, "userAgent");
|
||||
// Il testo copiato da Chrome: cURL, intestazioni, riga Cookie o solo il valore del cookie di accesso.
|
||||
var pasted = SessionPaste.Parse(Str(m, "cookie"), world.References().Recognizers.SessionCookie);
|
||||
if (pasted.Cookie == null) return new Ack(false, pasted.Error);
|
||||
var ua = pasted.UserAgent ?? Str(m, "userAgent");
|
||||
var (ok, msg) = await _bot.UseSessionAsync(new BidooSession
|
||||
{
|
||||
Cookie = cookie, UserAgent = string.IsNullOrWhiteSpace(ua) ? null : ua.Trim(), Source = SessionStore.SourcePasted
|
||||
Cookie = pasted.Cookie, UserAgent = string.IsNullOrWhiteSpace(ua) ? null : ua.Trim(), Source = SessionStore.SourcePasted
|
||||
}, ct).ConfigureAwait(false);
|
||||
return new Ack(ok, msg);
|
||||
return new Ack(ok, msg, new { format = pasted.Format, userAgentFromPaste = pasted.UserAgent != null });
|
||||
}
|
||||
case "session.logout":
|
||||
await _bot.LogoutAsync(ct).ConfigureAwait(false);
|
||||
return new Ack(true, "Sessione cancellata: il bot continua a seguire le aste senza puntare");
|
||||
case "login.open":
|
||||
{
|
||||
var (ok, msg) = await _bot.Login.OpenAsync(world.HasSession && !world.IsSimulator, ct).ConfigureAwait(false);
|
||||
return new Ack(ok, msg);
|
||||
}
|
||||
case "login.close":
|
||||
await _bot.Login.CloseAsync("chiuso dall'utente").ConfigureAwait(false);
|
||||
return new Ack(true);
|
||||
case "login.reload":
|
||||
await _bot.Login.ReloadAsync(ct).ConfigureAwait(false);
|
||||
return new Ack(true);
|
||||
case "login.input":
|
||||
await _bot.Login.InputAsync(LoginInput.From(m), ct).ConfigureAwait(false);
|
||||
return new Ack(true);
|
||||
case "login.back":
|
||||
await _bot.Login.HistoryAsync(-1, ct).ConfigureAwait(false);
|
||||
return new Ack(true);
|
||||
case "login.forward":
|
||||
await _bot.Login.HistoryAsync(+1, ct).ConfigureAwait(false);
|
||||
return new Ack(true);
|
||||
case "login.navigate":
|
||||
{
|
||||
var (ok, msg) = await _bot.Login.NavigateAsync(Str(m, "url") ?? "", ct).ConfigureAwait(false);
|
||||
return new Ack(ok, msg);
|
||||
}
|
||||
case "login.add_current":
|
||||
{
|
||||
// «Aggiungi al monitor» l'asta aperta nel browser.
|
||||
var url = _bot.Login.CurrentUrl;
|
||||
if (AuctionUrl.Parse(url, world.References()) is null) return new Ack(false, "La pagina aperta non è un'asta di Bidoo");
|
||||
RunMode? mode = Str(m, "mode") is { } ms2 ? RunModes.Parse(ms2) : null;
|
||||
var (a, msg) = await monitor.AddAsync(new AddAuctionRequest(url, "mano", mode), ct).ConfigureAwait(false);
|
||||
return new Ack(a != null, msg, a != null ? new { id = a.Id } : null);
|
||||
}
|
||||
|
||||
// ── prodotti ──────────────────────────────────────────────
|
||||
case "product.follow":
|
||||
|
||||
+261
-203
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
Mimante — componenti dell'interfaccia. Solo token di tokens.css, niente colori
|
||||
scritti qui. Densità compatta; layout fluido (grid/flex con 1fr, nessuna larghezza fissa
|
||||
nelle colonne della griglia); le maniglie cambiano solo grid-template-columns/rows.
|
||||
Mimante — componenti dell'interfaccia (proposta A «stile Febe», ADR 0016). Solo token di tokens.css,
|
||||
niente colori scritti qui (lo controlla ContrastTests). Layout fluido (grid/flex con 1fr, nessuna
|
||||
larghezza fissa nelle colonne della griglia); le maniglie cambiano solo grid-template-columns/rows.
|
||||
*/
|
||||
*, *::before, *::after { box-sizing: border-box; }
|
||||
|
||||
@@ -10,12 +10,14 @@ html, body {
|
||||
height: 100%;
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
font: var(--fs)/1.35 var(--font);
|
||||
font: var(--fs)/1.42 var(--font);
|
||||
font-variant-numeric: tabular-nums;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
text-rendering: optimizeLegibility;
|
||||
}
|
||||
|
||||
a { color: var(--accent); }
|
||||
code { font-family: var(--mono); font-size: .95em; background: var(--surface-2); border: 1px solid var(--line); border-radius: 3px; padding: 0 4px; }
|
||||
a { color: var(--accent-text); }
|
||||
code { font-family: var(--mono); font-size: .92em; background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
|
||||
b, strong { font-weight: 600; }
|
||||
button, input, select, textarea { font: inherit; color: inherit; }
|
||||
button { cursor: pointer; }
|
||||
@@ -24,7 +26,7 @@ button:disabled { cursor: not-allowed; opacity: .55; }
|
||||
[hidden] { display: none !important; }
|
||||
|
||||
::-webkit-scrollbar { width: 10px; height: 10px; }
|
||||
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 6px; border: 2px solid var(--bg); }
|
||||
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 6px; border: 2px solid var(--surface); }
|
||||
::-webkit-scrollbar-track { background: transparent; }
|
||||
|
||||
.muted { color: var(--muted); }
|
||||
@@ -33,112 +35,122 @@ button:disabled { cursor: not-allowed; opacity: .55; }
|
||||
.help { color: var(--faint); font-size: var(--fs-small); }
|
||||
.right, .num { text-align: right; }
|
||||
.nowrap { white-space: nowrap; }
|
||||
.ok { color: var(--ok); }
|
||||
.warn { color: var(--warn); }
|
||||
.bad { color: var(--bad); }
|
||||
.gold, .me, .won { color: var(--gold); font-weight: 600; }
|
||||
.pos { color: var(--ok); }
|
||||
.neg { color: var(--bad); }
|
||||
.ok { color: var(--ok-text); }
|
||||
.warn { color: var(--warn-text); }
|
||||
.bad { color: var(--bad-text); }
|
||||
.gold, .me, .won { color: var(--gold-text); font-weight: 600; }
|
||||
.pos { color: var(--ok-text); }
|
||||
.neg { color: var(--bad-text); }
|
||||
.spacer { flex: 1; }
|
||||
|
||||
/* ── bottoni e campi ─────────────────────────────────────────────────── */
|
||||
.btn {
|
||||
display: inline-flex; align-items: center; gap: 6px;
|
||||
padding: 6px 11px; border-radius: var(--r);
|
||||
border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
|
||||
white-space: nowrap; line-height: 1.2;
|
||||
display: inline-flex; align-items: center; gap: 7px;
|
||||
min-height: var(--ctl-h); padding: 0 12px; border-radius: var(--r);
|
||||
border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
|
||||
white-space: nowrap; line-height: 1.2; font-weight: 550;
|
||||
}
|
||||
.btn:hover:not(:disabled) { background: var(--surface-3); }
|
||||
.btn:hover:not(:disabled) { background: var(--hover); }
|
||||
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
|
||||
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
|
||||
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; font-weight: 600; }
|
||||
.btn.ghost { background: transparent; }
|
||||
.btn.wide { width: 100%; justify-content: center; padding: 9px; }
|
||||
.btn.danger { background: var(--bad); border-color: var(--bad); color: var(--bad-ink); font-weight: 600; }
|
||||
.btn.danger:hover:not(:disabled) { filter: brightness(1.08); background: var(--bad); }
|
||||
.btn.ghost { background: transparent; border-color: transparent; }
|
||||
.btn.ghost:hover:not(:disabled) { background: var(--hover); }
|
||||
.btn.wide { width: 100%; justify-content: center; min-height: 38px; }
|
||||
.btn .ic { font-size: 12px; }
|
||||
|
||||
input.txt, select.txt, textarea.txt, .field input, .field select {
|
||||
background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
|
||||
border-radius: var(--r); padding: 5px 8px; min-width: 0;
|
||||
background: var(--surface); border: 1px solid var(--line-strong); color: var(--text);
|
||||
border-radius: var(--r); padding: 0 9px; min-height: var(--ctl-h); min-width: 0;
|
||||
}
|
||||
input.txt:focus, select.txt:focus, .field input:focus, .field select:focus { border-color: var(--accent); outline: none; }
|
||||
textarea.txt { padding: 6px 9px; }
|
||||
input.txt::placeholder, textarea.txt::placeholder { color: var(--faint); }
|
||||
input.txt:focus, select.txt:focus, textarea.txt:focus, .field input:focus, .field select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
|
||||
input[type="number"] { -moz-appearance: textfield; }
|
||||
input[type="number"]::-webkit-inner-spin-button { opacity: .4; }
|
||||
select option { background: var(--surface); color: var(--text); }
|
||||
|
||||
/* interruttore: checkbox con aspetto a levetta */
|
||||
.switch { position: relative; display: inline-block; width: 34px; height: 18px; flex: none; }
|
||||
.switch { position: relative; display: inline-block; width: 36px; height: 20px; flex: none; }
|
||||
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
|
||||
.switch span { position: absolute; inset: 0; border-radius: 9px; background: var(--line); transition: background .15s; }
|
||||
.switch span::after { content: ""; position: absolute; left: 2px; top: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; }
|
||||
.switch span { position: absolute; inset: 0; border-radius: 10px; background: var(--line-strong); transition: background .15s; }
|
||||
.switch span::after { content: ""; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--knob); box-shadow: 0 1px 2px var(--shadow); transition: transform .15s; }
|
||||
.switch input:checked + span { background: var(--accent); }
|
||||
.switch input:checked + span::after { transform: translateX(16px); }
|
||||
.switch input:checked + span::after { transform: translateX(16px); background: var(--accent-ink); }
|
||||
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
|
||||
|
||||
/* indicatori (la riga di stato in alto) e chip delle pagine */
|
||||
.chip {
|
||||
display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; min-width: 0;
|
||||
border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line);
|
||||
color: var(--muted); white-space: nowrap; font-size: var(--fs-small);
|
||||
display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; min-width: 0;
|
||||
border-radius: 15px; background: var(--surface); border: 1px solid var(--line);
|
||||
color: var(--muted); white-space: nowrap; font-size: 13px;
|
||||
}
|
||||
.chip b { color: var(--text); font-weight: 600; }
|
||||
.chip small { color: var(--faint); font-size: var(--fs-tiny); }
|
||||
.chip.shadow { border-color: var(--accent); color: var(--accent); }
|
||||
.chip.shadow b { color: var(--accent); }
|
||||
.chip.sim { border-color: var(--warn); color: var(--warn); }
|
||||
.chip.shadow { border-color: var(--accent-line); color: var(--accent-text); background: var(--accent-soft); }
|
||||
.chip.shadow b { color: var(--accent-text); }
|
||||
.chip.sim { border-color: var(--warn); color: var(--warn-text); background: var(--warn-soft); }
|
||||
.chip.sim b { color: var(--warn-text); }
|
||||
.chip.clickable { cursor: pointer; }
|
||||
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); display: inline-block; flex: none; }
|
||||
.chip.clickable:hover { border-color: var(--line-strong); }
|
||||
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; flex: none; }
|
||||
.dot.warn { background: var(--warn); }
|
||||
.dot.bad { background: var(--bad); }
|
||||
.dot.off { background: var(--faint); }
|
||||
.dot.accent { background: var(--accent); }
|
||||
|
||||
.badge { display: inline-block; padding: 2px 7px; border-radius: 4px; font-size: var(--fs-tiny); font-weight: 600; letter-spacing: .1px; white-space: nowrap; }
|
||||
.b-lead { background: var(--ok-soft); color: var(--ok); }
|
||||
.b-active { background: var(--accent-soft); color: var(--accent); }
|
||||
.badge { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: var(--r-badge); font-size: var(--fs-tiny); font-weight: 600; white-space: nowrap; }
|
||||
.b-lead { background: var(--ok-soft); color: var(--ok-text); }
|
||||
.b-active { background: var(--accent-soft); color: var(--accent-text); }
|
||||
.b-watch { background: var(--muted-soft); color: var(--muted); }
|
||||
.b-stop { background: var(--muted-soft); color: var(--faint); }
|
||||
.b-won { background: var(--gold-soft); color: var(--gold); }
|
||||
.b-lost { background: var(--bad-soft); color: var(--bad); }
|
||||
.b-pause { background: var(--warn-soft); color: var(--warn); }
|
||||
.b-won { background: var(--gold-soft); color: var(--gold-text); }
|
||||
.b-lost { background: var(--bad-soft); color: var(--bad-text); }
|
||||
.b-pause { background: var(--warn-soft); color: var(--warn-text); }
|
||||
.b-sched { background: var(--muted-soft); color: var(--muted); }
|
||||
|
||||
.pill { padding: 2px 8px; border-radius: 999px; font-size: var(--fs-tiny); font-weight: 600; white-space: nowrap; }
|
||||
.pill.ok { background: var(--ok-soft); color: var(--ok); }
|
||||
.pill.warn { background: var(--warn-soft); color: var(--warn); }
|
||||
.pill.bad { background: var(--bad-soft); color: var(--bad); }
|
||||
.pill.info { background: var(--accent-soft); color: var(--accent); }
|
||||
.pill { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 10px; font-size: var(--fs-tiny); font-weight: 600; white-space: nowrap; }
|
||||
.pill.ok { background: var(--ok-soft); color: var(--ok-text); }
|
||||
.pill.warn { background: var(--warn-soft); color: var(--warn-text); }
|
||||
.pill.bad { background: var(--bad-soft); color: var(--bad-text); }
|
||||
.pill.info { background: var(--accent-soft); color: var(--accent-text); }
|
||||
.pill.muted { background: var(--muted-soft); color: var(--muted); }
|
||||
|
||||
.banner { padding: 10px 14px; border-radius: var(--r); border: 1px solid var(--warn); background: var(--warn-soft); color: var(--warn); display: flex; gap: 12px; align-items: center; }
|
||||
.banner.bad { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
|
||||
.banner.info { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
|
||||
.banner.ok { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
|
||||
.banner { padding: 10px 14px; border-radius: var(--r); border: 1px solid var(--warn); background: var(--warn-soft); color: var(--warn-text); display: flex; gap: 12px; align-items: center; }
|
||||
.banner.bad { border-color: var(--bad); background: var(--bad-soft); color: var(--bad-text); }
|
||||
.banner.info { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent-text); }
|
||||
.banner.ok { border-color: var(--ok); background: var(--ok-soft); color: var(--ok-text); }
|
||||
.banner .btn { margin-left: auto; }
|
||||
|
||||
/* ── pagine intere: accesso, errore, avvio ───────────────────────────── */
|
||||
body.fullpage { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
|
||||
.box {
|
||||
width: min(440px, 100%); background: var(--surface); border: 1px solid var(--line);
|
||||
border-radius: var(--r-lg); padding: 26px 28px; display: flex; flex-direction: column; gap: 12px;
|
||||
border-radius: var(--r-lg); padding: 28px 30px; display: flex; flex-direction: column; gap: 14px;
|
||||
box-shadow: 0 12px 40px var(--shadow);
|
||||
}
|
||||
.box h1 { margin: 0; font-size: 18px; font-weight: 600; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
|
||||
.box h1 { margin: 0; font-size: 20px; font-weight: 650; font-stretch: 104%; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
|
||||
.box .v { color: var(--faint); font-size: var(--fs-small); font-weight: 400; margin-left: auto; }
|
||||
.box .lead { margin: 0; color: var(--muted); }
|
||||
.box form { display: flex; flex-direction: column; gap: 10px; }
|
||||
.box input[type="password"] { width: 100%; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 9px 10px; }
|
||||
.box .form-error { margin: 0; color: var(--bad); }
|
||||
.box input[type="password"] { width: 100%; min-height: 38px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r); padding: 0 11px; }
|
||||
.box input[type="password"]:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
|
||||
.box .form-error { margin: 0; color: var(--bad-text); }
|
||||
.box .help { margin: 0; }
|
||||
.box.err { width: min(720px, 100%); }
|
||||
.box .row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
|
||||
.logo { width: 22px; height: 22px; border-radius: 5px; background: var(--accent); display: grid; place-items: center; color: var(--accent-ink); font-weight: 800; font-size: 12px; flex: none; }
|
||||
.sq { width: 16px; height: 16px; background: var(--bad); border-radius: 2px; flex: none; }
|
||||
.sq { width: 16px; height: 16px; background: var(--bad); border-radius: 3px; flex: none; }
|
||||
.err-item { display: grid; grid-template-columns: 22px 1fr; gap: 10px; padding: 10px 12px; border-radius: var(--r); border: 1px solid var(--bad); background: var(--bad-soft); }
|
||||
.err-item.ok { border-color: var(--ok); background: var(--ok-soft); }
|
||||
.err-item .mark { color: var(--bad); font-weight: 700; }
|
||||
.err-item.ok .mark { color: var(--ok); }
|
||||
.err-item .mark { color: var(--bad-text); font-weight: 700; }
|
||||
.err-item.ok .mark { color: var(--ok-text); }
|
||||
.err-item .detail { color: var(--muted); }
|
||||
.mono { font-family: var(--mono); font-size: var(--fs-small); color: var(--muted); background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 8px 10px; white-space: pre-wrap; margin-top: 6px; }
|
||||
.mono { font-family: var(--mono); font-size: var(--fs-small); color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; white-space: pre-wrap; margin-top: 6px; }
|
||||
|
||||
/* ── struttura dell'applicazione ─────────────────────────────────────── */
|
||||
/* barra laterale a tutta altezza (nome del programma in cima); a destra barra in alto e pagina */
|
||||
/* barra laterale a tutta altezza (nome in cima, pagine, stato in fondo); a destra gli indicatori e la pagina */
|
||||
.app {
|
||||
display: grid;
|
||||
grid-template-columns: var(--nav-w) minmax(0, 1fr);
|
||||
@@ -148,57 +160,80 @@ body.fullpage { display: grid; place-items: center; min-height: 100vh; padding:
|
||||
.app.narrow { grid-template-columns: var(--nav-w-narrow) minmax(0, 1fr); }
|
||||
|
||||
.topbar {
|
||||
grid-column: 2; grid-row: 1; display: flex; align-items: center; gap: 6px; padding: 0 12px;
|
||||
overflow: hidden; background: var(--surface); border-bottom: 1px solid var(--line); min-width: 0;
|
||||
grid-column: 2; grid-row: 1; display: flex; align-items: center; gap: 8px; padding: 0 22px;
|
||||
overflow: hidden; background: var(--bg); min-width: 0;
|
||||
}
|
||||
.topbar .chips { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; }
|
||||
.topbar .chips { display: flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; }
|
||||
.logo-img { width: 26px; height: 26px; object-fit: contain; flex: none; }
|
||||
.icon-btn { flex: none; width: 30px; height: 30px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); display: grid; place-items: center; font-size: 14px; padding: 0; }
|
||||
.icon-btn:hover:not(:disabled) { color: var(--text); background: var(--surface-3); }
|
||||
.icon-btn { flex: none; width: 32px; height: 32px; border-radius: var(--r); border: 1px solid var(--line-strong); background: var(--surface); color: var(--muted); display: grid; place-items: center; font-size: 14px; padding: 0; }
|
||||
.icon-btn:hover:not(:disabled) { color: var(--text); background: var(--hover); }
|
||||
.icon-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
|
||||
.icon-btn.primary:hover:not(:disabled) { background: var(--accent); color: var(--accent-ink); filter: brightness(1.08); }
|
||||
.topbar .icon-btn { border-color: var(--line); }
|
||||
|
||||
/* icone SVG (icons.js): il colore dice la funzione */
|
||||
.ico { width: 1em; height: 1em; display: block; flex: none; }
|
||||
.icon-btn .ico { width: 16px; height: 16px; }
|
||||
.btn .ico { width: 14px; height: 14px; }
|
||||
.c-bid { color: var(--gold); }
|
||||
.c-play { color: var(--ok); }
|
||||
.c-watch { color: var(--accent); }
|
||||
.c-stop { color: var(--bad); }
|
||||
.c-won { color: var(--gold); }
|
||||
.c-lost { color: var(--bad); }
|
||||
.icon-btn.c-play, .icon-btn.c-watch, .icon-btn.c-stop { background: var(--surface-2); }
|
||||
.icon-btn.c-play:hover:not(:disabled) { color: var(--ok); background: var(--ok-soft); }
|
||||
.icon-btn.c-watch:hover:not(:disabled) { color: var(--accent); background: var(--accent-soft); }
|
||||
.icon-btn.c-stop:hover:not(:disabled) { color: var(--bad); background: var(--bad-soft); }
|
||||
.btn .ico { width: 15px; height: 15px; }
|
||||
.c-bid { color: var(--gold-text); }
|
||||
.c-play { color: var(--ok-text); }
|
||||
.c-watch { color: var(--accent-text); }
|
||||
.c-stop { color: var(--bad-text); }
|
||||
.c-won { color: var(--gold-text); }
|
||||
.c-lost { color: var(--bad-text); }
|
||||
.icon-btn.c-play, .icon-btn.c-watch, .icon-btn.c-stop { background: var(--surface); }
|
||||
.icon-btn.c-play:hover:not(:disabled) { color: var(--ok-text); background: var(--ok-soft); }
|
||||
.icon-btn.c-watch:hover:not(:disabled) { color: var(--accent-text); background: var(--accent-soft); }
|
||||
.icon-btn.c-stop:hover:not(:disabled) { color: var(--bad-text); background: var(--bad-soft); }
|
||||
.tool-sep { width: 1px; height: 20px; background: var(--line); margin: 0 2px; flex: none; }
|
||||
|
||||
/* barra di elaborazione in corso (util.busy): sotto la barra in alto, fuori dalla griglia */
|
||||
.busy-bar { position: fixed; top: calc(var(--topbar-h) - 1px); left: var(--nav-w); right: 0; height: 3px; z-index: 60; overflow: hidden; background: var(--accent-soft); pointer-events: none; }
|
||||
/* barra di elaborazione in corso (util.busy): sotto gli indicatori, fuori dalla griglia */
|
||||
.busy-bar { position: fixed; top: calc(var(--topbar-h) - 3px); left: var(--nav-w); right: 0; height: 3px; z-index: 60; overflow: hidden; background: var(--accent-soft); pointer-events: none; }
|
||||
.busy-bar i, .progress i { position: absolute; top: 0; bottom: 0; left: 0; width: 32%; background: var(--accent); animation: busy 1.1s ease-in-out infinite; }
|
||||
@keyframes busy { from { left: -32%; } to { left: 100%; } }
|
||||
.progress { position: relative; width: 220px; max-width: 80%; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
|
||||
.progress { position: relative; width: 220px; max-width: 80%; height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; }
|
||||
|
||||
.nav {
|
||||
grid-column: 1; grid-row: 1 / 3; background: var(--surface); border-right: 1px solid var(--line);
|
||||
padding: 0 8px 10px; display: flex; flex-direction: column; gap: 2px; min-height: 0; overflow: hidden auto;
|
||||
grid-column: 1; grid-row: 1 / 3; background: var(--surface-3); border-right: 1px solid var(--line);
|
||||
padding: 0 12px 12px; display: flex; flex-direction: column; gap: 2px; min-height: 0; overflow: hidden auto;
|
||||
}
|
||||
/* il nome del programma: alto quanto la barra in alto, logo sulla colonna delle icone */
|
||||
/* il nome del programma: alto quanto gli indicatori, logo sulla colonna delle icone */
|
||||
.nav .brand {
|
||||
flex: none; height: var(--topbar-h); margin-bottom: 6px; padding: 0 6px; display: flex; align-items: center; gap: 10px;
|
||||
color: var(--text); font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden;
|
||||
flex: none; height: var(--topbar-h); margin-bottom: 4px; padding: 0 8px; display: flex; align-items: center; gap: 10px;
|
||||
color: var(--text); font-weight: 650; font-size: 17px; font-stretch: 108%; white-space: nowrap; overflow: hidden;
|
||||
}
|
||||
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r); color: var(--muted); text-decoration: none; white-space: nowrap; }
|
||||
.nav a:hover { color: var(--text); background: var(--surface-2); }
|
||||
.nav a.on { background: var(--surface-3); color: var(--text); font-weight: 600; }
|
||||
.nav a {
|
||||
display: flex; align-items: center; gap: 11px; height: 36px; padding: 0 10px; border-radius: var(--r);
|
||||
border: 1px solid transparent; color: var(--muted); text-decoration: none; white-space: nowrap; font-weight: 500;
|
||||
}
|
||||
.nav a:hover { color: var(--text); background: var(--hover); }
|
||||
.nav a.on { background: var(--surface); border-color: var(--line); color: var(--text); font-weight: 600; }
|
||||
.nav a.on .ic { color: var(--accent-text); }
|
||||
.nav .ic { width: 18px; display: grid; place-items: center; flex: none; }
|
||||
.nav .ic .ico { width: 16px; height: 16px; }
|
||||
.nav .ic .ico { width: 17px; height: 17px; }
|
||||
.nav .sep { flex: 1; }
|
||||
/* stato in fondo alla barra: mondo (sito vero o simulatore) e utente Bidoo */
|
||||
.nav .side-status {
|
||||
flex: none; margin-top: 10px; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-lg);
|
||||
padding: 11px 12px; display: flex; flex-direction: column; gap: 10px; min-width: 0;
|
||||
}
|
||||
.side-status .world { display: flex; align-items: center; gap: 8px; font-weight: 600; white-space: nowrap; overflow: hidden; }
|
||||
.side-status .world.sim { color: var(--warn-text); }
|
||||
.side-status .who { display: flex; align-items: center; gap: 9px; padding-top: 10px; border-top: 1px solid var(--line); color: inherit; text-decoration: none; min-width: 0; }
|
||||
.side-status .who b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.side-status .who small { display: block; font-size: var(--fs-small); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.side-status .who > span:last-child { min-width: 0; }
|
||||
.avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--muted-soft); color: var(--muted); font-weight: 700; font-size: 12px; flex: none; text-transform: uppercase; }
|
||||
.avatar.ok { background: var(--ok-soft); color: var(--ok-text); }
|
||||
.avatar.warn { background: var(--warn-soft); color: var(--warn-text); }
|
||||
.avatar.bad { background: var(--bad-soft); color: var(--bad-text); }
|
||||
/* comprimi/espandi: solo la doppia freccia, sulla colonna delle icone */
|
||||
.nav .collapse { flex: none; color: var(--faint); padding: 8px 10px; background: none; border: 0; border-radius: var(--r); display: flex; align-items: center; }
|
||||
.nav .collapse:hover { color: var(--text); background: var(--surface-2); }
|
||||
.app.narrow .nav .lbl { display: none; }
|
||||
.nav .collapse { flex: none; margin-top: 6px; color: var(--faint); height: 32px; padding: 0 10px; background: none; border: 0; border-radius: var(--r); display: flex; align-items: center; }
|
||||
.nav .collapse:hover { color: var(--text); background: var(--hover); }
|
||||
.app.narrow .nav { padding-left: 8px; padding-right: 8px; }
|
||||
.app.narrow .nav .lbl, .app.narrow .side-status .world, .app.narrow .side-status .who > span:last-child { display: none; }
|
||||
.app.narrow .side-status { padding: 6px; border: 0; background: none; }
|
||||
.app.narrow .side-status .who { border: 0; padding: 0; justify-content: center; }
|
||||
.app.narrow .nav a, .app.narrow .nav .collapse, .app.narrow .nav .brand { justify-content: center; }
|
||||
.app.narrow .nav .brand { padding: 0; }
|
||||
.app.narrow .busy-bar { left: var(--nav-w-narrow); }
|
||||
@@ -207,42 +242,52 @@ body.fullpage { display: grid; place-items: center; min-height: 100vh; padding:
|
||||
.page-host { min-height: 0; min-width: 0; overflow: hidden; display: flex; flex-direction: column; }
|
||||
.page-host > section { flex: 1; min-height: 0; display: flex; flex-direction: column; }
|
||||
|
||||
.toolbar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface); flex-wrap: wrap; min-width: 0; }
|
||||
.toolbar h1 { font-size: 15px; font-weight: 600; margin: 0 8px 0 0; white-space: nowrap; }
|
||||
.counters { display: flex; align-items: center; gap: 12px; }
|
||||
.counter { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); white-space: nowrap; }
|
||||
.counter .ico { width: 14px; height: 14px; }
|
||||
/* la testa della pagina: titolo grande, poi strumenti; sullo sfondo, senza riquadro */
|
||||
.toolbar { display: flex; align-items: center; gap: 10px; padding: 6px 22px 14px; flex-wrap: wrap; min-width: 0; }
|
||||
.toolbar h1 { font-size: 22px; font-weight: 650; font-stretch: 104%; letter-spacing: -.005em; margin: 0 6px 0 0; white-space: nowrap; }
|
||||
/* una barra dentro un riquadro (per esempio «Incolla un collegamento») non è una testa di pagina */
|
||||
.section .toolbar, .panel .toolbar { padding: 0; }
|
||||
.counters { display: flex; align-items: center; gap: 14px; }
|
||||
.counter { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); white-space: nowrap; }
|
||||
.counter .ico { width: 15px; height: 15px; }
|
||||
.counter b { color: var(--text); }
|
||||
.counter.c-play { color: var(--ok); }
|
||||
.counter.c-watch { color: var(--accent); }
|
||||
.counter.c-stop, .counter.c-lost { color: var(--bad); }
|
||||
.counter.c-won, .counter.c-won b { color: var(--gold); }
|
||||
.toolbar .sub { color: var(--muted); font-size: var(--fs-small); }
|
||||
.counter.c-play { color: var(--ok-text); }
|
||||
.counter.c-watch { color: var(--accent-text); }
|
||||
.counter.c-stop, .counter.c-lost { color: var(--bad-text); }
|
||||
.counter.c-won, .counter.c-won b { color: var(--gold-text); }
|
||||
.toolbar .sub { color: var(--muted); font-size: 13px; }
|
||||
|
||||
/* due colonne ridimensionabili: elenco | maniglia | pannello */
|
||||
.split { display: grid; grid-template-columns: minmax(480px, 1fr) 6px var(--panel-w, 400px); flex: 1; min-height: 0; }
|
||||
.split.collapsed { grid-template-columns: minmax(0, 1fr) 6px 0; }
|
||||
/* due colonne ridimensionabili: elenco | maniglia | pannello, ognuno nel suo riquadro */
|
||||
.split { display: grid; grid-template-columns: minmax(480px, 1fr) 14px var(--panel-w, 400px); flex: 1; min-height: 0; padding: 0 22px 22px; }
|
||||
.split.collapsed { grid-template-columns: minmax(0, 1fr) 14px 0; }
|
||||
.split.collapsed > .panel { display: none; }
|
||||
.split > .content { overflow: auto; min-width: 0; min-height: 0; position: relative; }
|
||||
.vsplit { cursor: col-resize; background: var(--surface); border-left: 1px solid var(--line); border-right: 1px solid var(--line); position: relative; }
|
||||
.vsplit::after { content: ""; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 2px; height: 28px; background: var(--faint); border-radius: 2px; }
|
||||
.vsplit button { position: absolute; top: 6px; left: -8px; width: 20px; height: 20px; padding: 0; border-radius: 50%; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); font-size: 10px; z-index: 2; }
|
||||
.split > .content {
|
||||
overflow: auto; min-width: 0; min-height: 0; position: relative;
|
||||
background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
|
||||
}
|
||||
.vsplit { cursor: col-resize; background: transparent; position: relative; }
|
||||
.vsplit::after { content: ""; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 3px; height: 32px; background: var(--line-strong); border-radius: 2px; }
|
||||
.vsplit:hover::after { background: var(--accent); }
|
||||
.vsplit button { position: absolute; top: 8px; left: -4px; width: 22px; height: 22px; padding: 0; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--surface); color: var(--muted); font-size: 10px; z-index: 2; }
|
||||
body.dragging, body.dragging * { user-select: none !important; cursor: inherit; }
|
||||
|
||||
/* ── tabelle ─────────────────────────────────────────────────────────── */
|
||||
table.grid { border-collapse: separate; border-spacing: 0; width: 100%; }
|
||||
table.grid th {
|
||||
position: sticky; top: 0; z-index: 1; background: var(--surface); color: var(--muted);
|
||||
font-weight: 600; text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line);
|
||||
font-weight: 500; text-align: left; height: 38px; padding: 0 10px; border-bottom: 1px solid var(--line);
|
||||
font-size: var(--fs-small); white-space: nowrap; user-select: none;
|
||||
}
|
||||
table.grid th.sortable { cursor: pointer; }
|
||||
table.grid th.sorted-asc::after { content: " \25B4"; color: var(--accent); }
|
||||
table.grid th.sorted-desc::after { content: " \25BE"; color: var(--accent); }
|
||||
table.grid td { padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
|
||||
table.grid th.sortable:hover { color: var(--text); }
|
||||
table.grid th.sorted-asc, table.grid th.sorted-desc { color: var(--text); }
|
||||
table.grid th.sorted-asc::after { content: " \25B4"; color: var(--accent-text); }
|
||||
table.grid th.sorted-desc::after { content: " \25BE"; color: var(--accent-text); }
|
||||
table.grid td { padding: 9px 10px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; vertical-align: middle; }
|
||||
table.grid tbody tr { cursor: default; }
|
||||
table.grid tbody tr:hover td { background: var(--surface-2); }
|
||||
table.grid tbody tr.sel td { background: var(--surface-3); }
|
||||
table.grid tbody tr:hover td { background: var(--hover); }
|
||||
table.grid tbody tr.sel td { background: var(--accent-soft); }
|
||||
table.grid tbody tr.sel td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
|
||||
table.grid td.num, table.grid th.num { text-align: right; }
|
||||
table.grid td.wrap { white-space: normal; }
|
||||
table.grid td.ell { max-width: 0; overflow: hidden; text-overflow: ellipsis; }
|
||||
@@ -250,130 +295,138 @@ table.grid td.ell { max-width: 0; overflow: hidden; text-overflow: ellipsis; }
|
||||
table.grid.fixed { table-layout: fixed; }
|
||||
table.grid.fixed th, table.grid.fixed td { overflow: hidden; text-overflow: ellipsis; }
|
||||
table.grid .spacer-row td { padding: 0; border: 0; }
|
||||
.empty { padding: 30px 14px; color: var(--muted); text-align: center; }
|
||||
table.grid .spacer-row:hover td { background: none; }
|
||||
.empty { padding: 34px 16px; color: var(--muted); text-align: center; }
|
||||
|
||||
.timer { display: flex; flex-direction: column; gap: 3px; min-width: 86px; }
|
||||
.timer .t { font-weight: 600; }
|
||||
.timer .t.warn { color: var(--warn); }
|
||||
.timer .t.bad { color: var(--bad); }
|
||||
.bar { height: 3px; border-radius: 2px; background: var(--line); overflow: hidden; }
|
||||
.timer .t.warn { color: var(--warn-text); }
|
||||
.timer .t.bad { color: var(--bad-text); font-weight: 700; }
|
||||
.bar { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
|
||||
.bar i { display: block; height: 100%; background: var(--ok); width: 0; }
|
||||
.bar i.warn { background: var(--warn); }
|
||||
.bar i.bad { background: var(--bad); }
|
||||
.ping { color: var(--ok); }
|
||||
.ping.warn { color: var(--warn); }
|
||||
.ping.bad { color: var(--bad); }
|
||||
.ping { color: var(--ok-text); }
|
||||
.ping.warn { color: var(--warn-text); }
|
||||
.ping.bad { color: var(--bad-text); }
|
||||
|
||||
.acts { display: flex; gap: 4px; }
|
||||
.acts button { width: 26px; height: 26px; padding: 0; border-radius: 5px; border: 1px solid var(--line); background: var(--surface-2); display: grid; place-items: center; font-size: 11px; color: var(--muted); }
|
||||
.acts button .ico { width: 15px; height: 15px; }
|
||||
.acts button:hover:not(:disabled) { background: var(--surface-3); }
|
||||
.acts button.c-bid { color: var(--gold); }
|
||||
.acts button.c-play { color: var(--ok); }
|
||||
.acts button.c-watch { color: var(--accent); }
|
||||
.acts button.c-stop { color: var(--bad); }
|
||||
.acts { display: flex; gap: 2px; }
|
||||
.acts button { width: 26px; height: 26px; padding: 0; border-radius: var(--r); border: 1px solid transparent; background: transparent; display: grid; place-items: center; font-size: 11px; color: var(--muted); }
|
||||
.acts button .ico { width: 16px; height: 16px; }
|
||||
.acts button:hover:not(:disabled) { background: var(--surface-2); border-color: var(--line); }
|
||||
.acts button.c-bid { color: var(--gold-text); }
|
||||
.acts button.c-play { color: var(--ok-text); }
|
||||
.acts button.c-watch { color: var(--accent-text); }
|
||||
.acts button.c-stop { color: var(--bad-text); }
|
||||
.acts button.c-bid:hover:not(:disabled) { background: var(--gold-soft); border-color: var(--gold); }
|
||||
.acts button.on.c-play { background: var(--ok-soft); border-color: var(--ok); }
|
||||
.acts button.on.c-watch { background: var(--accent-soft); border-color: var(--accent); }
|
||||
.acts button.on.c-watch { background: var(--accent-soft); border-color: var(--accent-line); }
|
||||
.acts button.on.c-stop { background: var(--bad-soft); border-color: var(--bad); }
|
||||
.acts button.c-del:hover:not(:disabled) { color: var(--text); }
|
||||
table.grid td.manual { font-style: italic; }
|
||||
.star { background: none; border: 0; padding: 0 2px; font-size: 14px; color: var(--faint); }
|
||||
.star { background: none; border: 0; padding: 0 2px; font-size: 15px; color: var(--faint); }
|
||||
.star.on { color: var(--gold); }
|
||||
|
||||
/* ── pannello dettagli ───────────────────────────────────────────────── */
|
||||
.panel { background: var(--surface); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
|
||||
.panel .head { padding: 10px 14px; border-bottom: 1px solid var(--line); }
|
||||
.panel .head h2 { margin: 0; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
|
||||
.panel {
|
||||
background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
|
||||
display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden;
|
||||
}
|
||||
.panel .head { padding: 14px 16px 12px; border-bottom: 1px solid var(--line); }
|
||||
.panel .head h2 { margin: 0; font-size: 16px; font-weight: 650; overflow-wrap: anywhere; }
|
||||
.panel .head small { color: var(--muted); }
|
||||
.tabs { display: flex; flex-wrap: wrap; gap: 0 2px; padding: 4px 8px 0; border-bottom: 1px solid var(--line); flex: none; }
|
||||
.tabs button { padding: 7px 8px; color: var(--muted); border: 0; border-bottom: 2px solid transparent; background: none; white-space: nowrap; }
|
||||
.tabs { display: flex; flex-wrap: wrap; gap: 0 2px; padding: 0 10px; border-bottom: 1px solid var(--line); flex: none; }
|
||||
.tabs button { padding: 10px 9px 9px; margin-bottom: -1px; color: var(--muted); border: 0; border-bottom: 2px solid transparent; background: none; white-space: nowrap; }
|
||||
.tabs button:hover { color: var(--text); }
|
||||
.tabs button.on { color: var(--text); border-color: var(--accent); font-weight: 600; }
|
||||
.panel .body { padding: 12px 14px; overflow: auto; display: flex; flex-direction: column; gap: 12px; min-height: 0; flex: 1; }
|
||||
.panel .placeholder { color: var(--muted); padding: 24px 14px; }
|
||||
.panel .body { padding: 14px 16px; overflow: auto; display: flex; flex-direction: column; gap: 14px; min-height: 0; flex: 1; }
|
||||
.panel .placeholder { color: var(--muted); padding: 28px 16px; }
|
||||
|
||||
.kv { display: grid; grid-template-columns: minmax(0, max-content) minmax(40%, 1fr); gap: 6px 10px; font-size: 12.5px; margin: 0; }
|
||||
.kv { display: grid; grid-template-columns: minmax(0, max-content) minmax(40%, 1fr); gap: 7px 12px; font-size: var(--fs-small); margin: 0; }
|
||||
.kv dt { color: var(--muted); margin: 0; }
|
||||
.kv dd { margin: 0; text-align: right; font-weight: 600; overflow-wrap: anywhere; }
|
||||
.field { display: grid; grid-template-columns: minmax(0, 1fr) 130px; align-items: center; gap: 8px; }
|
||||
.field { display: grid; grid-template-columns: minmax(0, 1fr) 130px; align-items: center; gap: 10px; }
|
||||
.field label { color: var(--muted); }
|
||||
.field input, .field select { text-align: right; width: 100%; }
|
||||
.field.wide { grid-template-columns: minmax(0, 1fr) minmax(0, 220px); }
|
||||
.card { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; }
|
||||
.card h3 { margin: 0 0 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
|
||||
.verdict { padding: 8px 10px; border-radius: var(--r); border: 1px solid var(--muted); color: var(--muted); background: var(--muted-soft); }
|
||||
.verdict.yes { border-color: var(--ok); color: var(--ok); background: var(--ok-soft); }
|
||||
.verdict.no { border-color: var(--bad); color: var(--bad); background: var(--bad-soft); }
|
||||
.verdict.explore { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
|
||||
.log { font-size: var(--fs-small); line-height: 1.5; color: var(--muted); white-space: pre-wrap; font-family: var(--font); }
|
||||
.card { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; }
|
||||
.card h3 { margin: 0 0 8px; font-size: 13px; font-weight: 650; color: var(--text); }
|
||||
.verdict { padding: 12px; border-radius: var(--r); border: 1px solid var(--line-strong); color: var(--muted); background: var(--muted-soft); }
|
||||
.verdict.yes { border-color: var(--ok); color: var(--ok-text); background: var(--ok-soft); }
|
||||
.verdict.no { border-color: var(--bad); color: var(--bad-text); background: var(--bad-soft); }
|
||||
.verdict.explore { border-color: var(--accent-line); color: var(--accent-text); background: var(--accent-soft); }
|
||||
.log { font-size: var(--fs-small); line-height: 1.55; color: var(--muted); white-space: pre-wrap; font-family: var(--font); }
|
||||
.log b { color: var(--text); font-weight: 600; }
|
||||
.log .cnt { color: var(--faint); }
|
||||
.product { display: grid; grid-template-columns: 108px minmax(0, 1fr); gap: 12px; align-items: start; }
|
||||
.product .img { width: 108px; height: 108px; border-radius: var(--r); background: var(--surface-3); display: grid; place-items: center; color: var(--faint); font-size: var(--fs-tiny); text-align: center; overflow: hidden; }
|
||||
.product .img img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
|
||||
.product { display: grid; grid-template-columns: 108px minmax(0, 1fr); gap: 14px; align-items: start; }
|
||||
.product .img { width: 108px; height: 108px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; color: var(--faint); font-size: var(--fs-tiny); text-align: center; overflow: hidden; }
|
||||
.product .img img { width: 100%; height: 100%; object-fit: contain; background: var(--image-bg); }
|
||||
|
||||
/* ── pagine generiche ────────────────────────────────────────────────── */
|
||||
.page { padding: 14px; overflow: auto; display: flex; flex-direction: column; gap: 14px; min-height: 0; flex: 1; }
|
||||
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
|
||||
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
|
||||
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
|
||||
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; min-width: 0; }
|
||||
.stat .v { font-size: 22px; font-weight: 600; margin: 2px 0; }
|
||||
.page { padding: 0 22px 22px; overflow: auto; display: flex; flex-direction: column; gap: var(--gap); min-height: 0; flex: 1; }
|
||||
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
|
||||
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap); }
|
||||
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--gap); }
|
||||
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 12px 14px; min-width: 0; }
|
||||
.stat .v { font-size: 24px; font-weight: 650; font-stretch: 96%; line-height: 1.25; margin: 2px 0; }
|
||||
.stat .l { color: var(--muted); font-size: var(--fs-small); }
|
||||
.stat .s { color: var(--muted); font-size: var(--fs-small); }
|
||||
.section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); min-width: 0; display: flex; flex-direction: column; }
|
||||
.section > h2 { margin: 0; padding: 10px 14px; font-size: 13.5px; font-weight: 600; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: center; }
|
||||
.section > .in { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
|
||||
.stat .s { color: var(--muted); font-size: 12px; }
|
||||
/* dentro un riquadro i numeri stanno su una superficie appena diversa */
|
||||
.section .stat { background: var(--surface-2); }
|
||||
.section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); min-width: 0; display: flex; flex-direction: column; }
|
||||
.section > h2 { margin: 0; padding: 13px 16px 11px; font-size: 15px; font-weight: 650; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: center; }
|
||||
.section > .in { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
|
||||
.section > .table-wrap { overflow: auto; max-height: 420px; }
|
||||
.section > .tabs { padding: 0 12px; }
|
||||
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
|
||||
.help.note { margin: 0 0 2px; line-height: 1.4; }
|
||||
.help.note { margin: 0 0 2px; line-height: 1.45; }
|
||||
|
||||
.weights { display: flex; flex-direction: column; gap: 5px; font-size: var(--fs-small); }
|
||||
.weights { display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-small); }
|
||||
.weights .w { display: grid; grid-template-columns: minmax(0, 1fr) minmax(60px, 160px) 48px; gap: 8px; align-items: center; }
|
||||
.weights .w .bar { height: 6px; }
|
||||
.weights .w .bar i { background: var(--accent); }
|
||||
.weights .w .bar i.neg { background: var(--bad); }
|
||||
.hist { height: 60px; display: flex; align-items: flex-end; gap: 2px; }
|
||||
.hist i { display: block; flex: 1; background: var(--accent); opacity: .8; border-radius: 1px; min-height: 1px; }
|
||||
.hist { height: 62px; display: flex; align-items: flex-end; gap: 3px; }
|
||||
.hist i { display: block; flex: 1; background: var(--accent); opacity: .75; border-radius: 2px 2px 0 0; min-height: 1px; }
|
||||
.hist i:last-child { opacity: 1; }
|
||||
|
||||
/* Browser: il browser del bot (screencast) e accanto la sessione */
|
||||
.browser-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 320px); gap: 14px; flex: 1; min-height: 0; }
|
||||
.browser-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; min-height: 0; overflow: auto; }
|
||||
ul.plain { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
|
||||
.browser { background: var(--browser-bg); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; display: flex; flex-direction: column; min-height: 0; }
|
||||
.browser .url { display: flex; gap: 6px; align-items: center; padding: 6px 8px; background: var(--surface-2); border-bottom: 1px solid var(--line); color: var(--muted); font-size: var(--fs-small); }
|
||||
.browser .url .icon-btn { width: 28px; height: 28px; }
|
||||
.browser .url input.addr { flex: 1; min-width: 120px; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 5px 8px; color: var(--text); font-size: var(--fs-small); }
|
||||
.browser .url input.addr:focus { border-color: var(--accent); outline: none; }
|
||||
.browser .url .btn { padding: 5px 9px; }
|
||||
.browser .view { position: relative; flex: 1; min-height: 300px; display: grid; place-items: center; outline: none; }
|
||||
.browser .view canvas { max-width: 100%; max-height: 100%; cursor: pointer; display: block; }
|
||||
.browser .view .idle { color: var(--muted); padding: 30px; text-align: center; }
|
||||
/* Accesso a Bidoo: la sessione da incollare e le istruzioni, accanto lo stato */
|
||||
.access-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 340px); gap: var(--gap); align-items: start; }
|
||||
.access-main { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
|
||||
textarea.txt.paste { width: 100%; resize: vertical; min-height: 150px; font-family: var(--mono); font-size: var(--fs-small); line-height: 1.45; }
|
||||
.access-main input.txt { width: 100%; }
|
||||
ul.plain, ol.plain { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
|
||||
ol.steps { gap: 7px; line-height: 1.5; }
|
||||
kbd { font-family: var(--mono); font-size: .88em; background: var(--surface-2); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; }
|
||||
|
||||
/* ── dialoghi e avvisi ───────────────────────────────────────────────── */
|
||||
.modal-back { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
|
||||
.modal { width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: 0 10px 40px var(--shadow); display: flex; flex-direction: column; }
|
||||
.modal header { padding: 14px 16px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 14px; }
|
||||
.modal .content { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
|
||||
.modal footer { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
|
||||
.modal-back { position: fixed; inset: 0; background: var(--scrim); display: grid; place-items: center; z-index: 50; padding: 16px; }
|
||||
.modal { width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: 0 16px 48px var(--shadow); display: flex; flex-direction: column; }
|
||||
.modal header { padding: 15px 18px 13px; border-bottom: 1px solid var(--line); font-weight: 650; font-size: 15px; }
|
||||
.modal .content { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
|
||||
.modal footer { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
|
||||
.modal .field { grid-template-columns: minmax(0, 1fr) minmax(0, 220px); }
|
||||
/* messaggio importante al centro (util.notice): la barra a sinistra dice il tipo */
|
||||
.notice { margin: 0; padding: 2px 0 2px 12px; border-left: 4px solid var(--accent); white-space: pre-line; overflow-wrap: anywhere; }
|
||||
.notice.ok { border-left-color: var(--ok); color: var(--text); }
|
||||
.notice.warn { border-left-color: var(--warn); color: var(--text); }
|
||||
.notice.bad { border-left-color: var(--bad); color: var(--text); }
|
||||
.conn-lost { position: fixed; top: calc(var(--topbar-h) + 8px); left: 50%; transform: translateX(-50%); z-index: 40; }
|
||||
.conn-lost { position: fixed; top: calc(var(--topbar-h) + 8px); left: 50%; transform: translateX(-50%); z-index: 40; box-shadow: 0 8px 24px var(--shadow); }
|
||||
|
||||
/* catalogo: categorie a sinistra */
|
||||
.catalog { display: grid; grid-template-columns: 220px minmax(0, 1fr); flex: 1; min-height: 0; }
|
||||
.catalog .cats { border-right: 1px solid var(--line); overflow: auto; padding: 8px; background: var(--surface); }
|
||||
.catalog .cats button { display: block; width: 100%; text-align: left; padding: 6px 10px; border: 0; background: none; border-radius: var(--r); color: var(--muted); }
|
||||
.catalog .cats button.on { background: var(--surface-3); color: var(--text); font-weight: 600; }
|
||||
/* catalogo: categorie a sinistra, elenco a destra, nello stesso riquadro */
|
||||
.catalog {
|
||||
display: grid; grid-template-columns: 220px minmax(0, 1fr); flex: 1; min-height: 0; margin: 0 22px 22px;
|
||||
background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden;
|
||||
}
|
||||
.catalog .cats { border-right: 1px solid var(--line); overflow: auto; padding: 8px; background: var(--surface-2); }
|
||||
.catalog .cats button { display: block; width: 100%; text-align: left; padding: 7px 10px; border: 0; background: none; border-radius: var(--r); color: var(--muted); }
|
||||
.catalog .cats button:hover { color: var(--text); background: var(--hover); }
|
||||
.catalog .cats button.on { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
|
||||
.catalog .list-wrap { position: relative; min-width: 0; min-height: 0; display: flex; }
|
||||
.catalog .list { overflow: auto; min-width: 0; flex: 1; }
|
||||
/* velo di caricamento: l'elenco resta visibile sotto, la barra dice che si sta leggendo */
|
||||
.loading-veil { display: none; position: absolute; inset: 0; z-index: 3; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--muted); }
|
||||
.loading-veil::before { content: ""; position: absolute; inset: 0; background: var(--bg); opacity: .72; }
|
||||
.loading-veil::before { content: ""; position: absolute; inset: 0; background: var(--surface); opacity: .72; }
|
||||
.loading-veil > * { position: relative; }
|
||||
.list-wrap.loading .loading-veil { display: flex; }
|
||||
|
||||
@@ -382,30 +435,35 @@ ul.plain { margin: 0; padding-left: 18px; display: flex; flex-direction: column;
|
||||
numero: scritto o no lo dicono il title e il puntino della cella (prodotti.css). */
|
||||
table.grid td.edit { padding: 3px 5px; }
|
||||
table.grid th.edit::after { content: " \270E"; color: var(--faint); font-weight: 400; }
|
||||
.cell-edit { width: 100%; min-width: 62px; background: transparent; border: 1px solid transparent; border-radius: 4px; padding: 3px 6px; color: var(--text); text-align: right; }
|
||||
.cell-edit { width: 100%; min-width: 62px; min-height: 30px; background: transparent; border: 1px solid transparent; border-radius: var(--r); padding: 0 7px; color: var(--text); text-align: right; }
|
||||
select.cell-edit { text-align: left; min-width: 112px; }
|
||||
table.grid th.pname, table.grid td.pname { min-width: 190px; width: 22%; }
|
||||
.cell-edit::placeholder { color: var(--text); opacity: 1; }
|
||||
.cell-edit:hover { border-color: var(--line); }
|
||||
.cell-edit:focus { border-color: var(--accent); background: var(--surface-2); outline: none; }
|
||||
select.cell-edit option { background: var(--surface); color: var(--text); }
|
||||
.thumb { width: 40px; height: 40px; object-fit: contain; background: #fff; border-radius: 4px; }
|
||||
.cell-edit:hover { border-color: var(--line-strong); background: var(--surface); }
|
||||
.cell-edit:focus { border-color: var(--accent); background: var(--surface); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
|
||||
.thumb { width: 40px; height: 40px; object-fit: contain; background: var(--image-bg); border-radius: var(--r-badge); }
|
||||
|
||||
/* ── finestre strette ────────────────────────────────────────────────── */
|
||||
@media (max-width: 1100px) {
|
||||
.app { grid-template-columns: var(--nav-w-narrow) minmax(0, 1fr); }
|
||||
.app .nav .lbl { display: none; }
|
||||
.app .nav { padding-left: 8px; padding-right: 8px; }
|
||||
.app .nav .lbl, .app .side-status .world, .app .side-status .who > span:last-child { display: none; }
|
||||
.app .side-status { padding: 6px; border: 0; background: none; }
|
||||
.app .side-status .who { border: 0; padding: 0; justify-content: center; }
|
||||
.app .nav a, .app .nav .brand { justify-content: center; }
|
||||
.app .nav .brand { padding: 0; }
|
||||
/* qui la barra è sempre a sole icone: il bottone per comprimerla non servirebbe */
|
||||
.app .nav .collapse { display: none; }
|
||||
.busy-bar, .app.narrow .busy-bar { left: var(--nav-w-narrow); }
|
||||
.topbar, .toolbar { padding-left: 14px; padding-right: 14px; }
|
||||
.topbar .opt { display: none; }
|
||||
.counters { display: none; }
|
||||
.split { grid-template-columns: minmax(0, 1fr) 6px 0; position: relative; }
|
||||
.page { padding: 0 14px 14px; }
|
||||
.catalog { margin: 0 14px 14px; }
|
||||
.split { grid-template-columns: minmax(0, 1fr) 14px 0; position: relative; padding: 0 0 14px 14px; }
|
||||
.split > .panel {
|
||||
position: absolute; top: 0; right: 0; bottom: 0; width: min(var(--panel-w, 400px), 92%);
|
||||
border-left: 1px solid var(--line); box-shadow: -10px 0 30px var(--shadow); z-index: 5;
|
||||
position: absolute; top: 0; right: 14px; bottom: 14px; width: min(var(--panel-w, 400px), 92%);
|
||||
box-shadow: -10px 0 30px var(--shadow); z-index: 5;
|
||||
}
|
||||
.split:not(.drawer-open) > .panel { display: none; }
|
||||
.grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
||||
@@ -424,13 +482,13 @@ select.cell-edit option { background: var(--surface); color: var(--text); }
|
||||
|
||||
/* ── aggiunte dell'interfaccia (M6) ──────────────────────────────────── */
|
||||
a.btn, a.icon-btn { text-decoration: none; }
|
||||
.stat .v.pos { color: var(--ok); }
|
||||
.stat .v.neg { color: var(--bad); }
|
||||
.ev.pos { color: var(--ok); }
|
||||
.ev.neg { color: var(--bad); }
|
||||
.stat .v.pos { color: var(--ok-text); }
|
||||
.stat .v.neg { color: var(--bad-text); }
|
||||
.ev.pos { color: var(--ok-text); }
|
||||
.ev.neg { color: var(--bad-text); }
|
||||
.content > .btn.wide { margin: 10px 0; }
|
||||
.panel .head .icon-btn { width: 24px; height: 24px; font-size: 11px; }
|
||||
.panel .head .icon-btn { width: 26px; height: 26px; font-size: 11px; }
|
||||
@media (min-width: 1101px) { .panel .head .icon-btn, .drawer-only { display: none; } }
|
||||
@media (max-width: 1100px) { .browser-grid { grid-template-columns: minmax(0, 1fr); } }
|
||||
@media (max-width: 1100px) { .access-grid { grid-template-columns: minmax(0, 1fr); } }
|
||||
table.grid th.grow, table.grid td.grow { width: 36%; }
|
||||
.toolbar .sub.grow { flex: 1 1 240px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
@@ -16,22 +16,22 @@
|
||||
box-shadow: inset 1px 0 0 var(--line);
|
||||
}
|
||||
.aste-list table.grid th.col-acts { z-index: 2; }
|
||||
.aste-list table.grid td.col-acts { z-index: 1; background: var(--bg); }
|
||||
.aste-list table.grid tbody tr:hover td.col-acts { background: var(--surface-2); }
|
||||
.aste-list table.grid tbody tr.sel td.col-acts { background: var(--surface-3); }
|
||||
.aste-list table.grid td.col-acts { z-index: 1; background: var(--surface); }
|
||||
.aste-list table.grid tbody tr:hover td.col-acts { background: var(--hover); }
|
||||
.aste-list table.grid tbody tr.sel td.col-acts { background: var(--accent-soft); }
|
||||
|
||||
/* ── pannello: selettore del modo in cima (Asta | Registro del bot) ─────── */
|
||||
.aste-panel .panel-mode { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); flex: none; }
|
||||
.aste-panel .seg { flex: 1; min-width: 0; display: flex; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); }
|
||||
.aste-panel .panel-mode { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); flex: none; }
|
||||
.aste-panel .seg { flex: 1; min-width: 0; display: flex; gap: 2px; padding: 2px; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface); }
|
||||
.aste-panel .seg button {
|
||||
flex: 1 1 0; min-width: 0; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
|
||||
padding: 5px 8px; border: 0; border-radius: calc(var(--r) - 2px); background: none; color: var(--muted); white-space: nowrap;
|
||||
height: 28px; padding: 0 9px; border: 0; border-radius: calc(var(--r) - 2px); background: none; color: var(--muted); white-space: nowrap;
|
||||
}
|
||||
.aste-panel .seg button span { overflow: hidden; text-overflow: ellipsis; }
|
||||
.aste-panel .seg button .ico { width: 15px; height: 15px; }
|
||||
.aste-panel .seg button:hover { color: var(--text); }
|
||||
.aste-panel .seg button.on { background: var(--surface-3); color: var(--text); font-weight: 600; }
|
||||
.aste-panel .seg button.on .ico { color: var(--accent); }
|
||||
.aste-panel .seg button.on { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
|
||||
.aste-panel .seg button.on .ico { color: var(--accent-text); }
|
||||
|
||||
/* i due modi: uno visibile, l'altro con hidden (il suo contenuto resta, per esempio i paletti in scrittura) */
|
||||
.aste-panel .pane { flex: 1; min-height: 0; display: flex; flex-direction: column; }
|
||||
|
||||
@@ -11,14 +11,12 @@
|
||||
|
||||
.settings-page { gap: 12px; }
|
||||
|
||||
.settings-page > .section > h2 { padding: 8px 12px; }
|
||||
|
||||
.settings-page > .section > .in {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr));
|
||||
align-items: center;
|
||||
gap: 4px 28px;
|
||||
padding: 8px 12px 10px;
|
||||
padding: 10px 16px 14px;
|
||||
}
|
||||
|
||||
.settings-page .in > .full { grid-column: 1 / -1; min-width: 0; }
|
||||
@@ -26,9 +24,9 @@
|
||||
.settings-page .in > .extra { margin-top: 6px; padding-top: 8px; border-top: 1px dashed var(--line); }
|
||||
.settings-page .in > .help.note { margin: 0 0 4px; line-height: 1.4; }
|
||||
|
||||
.settings-page .field { grid-template-columns: minmax(0, 1fr) minmax(84px, 128px); gap: 8px; min-height: 28px; min-width: 0; }
|
||||
.settings-page .field { grid-template-columns: minmax(0, 1fr) minmax(84px, 128px); gap: 10px; min-height: 38px; min-width: 0; border-bottom: 1px solid var(--line-soft); }
|
||||
.settings-page .field.toggle-row { grid-template-columns: minmax(0, 1fr) auto; }
|
||||
.settings-page .field input, .settings-page .field select { padding: 3px 7px; }
|
||||
.settings-page .field input, .settings-page .field select { min-height: 30px; padding: 0 8px; }
|
||||
.settings-page .field label { line-height: 1.3; }
|
||||
|
||||
/* Coppie nome-valore (rete, dati, database) nella stessa griglia dei campi. */
|
||||
|
||||
@@ -1,75 +1,84 @@
|
||||
/*
|
||||
Mimante — token dell'interfaccia (unica origine dei colori).
|
||||
Nati dai token semantici di docs/mockup/mock.css. Il colore ha significato:
|
||||
neutro = secondario, accento = primario, verde/ambra/rosso = ok/attenzione/pericolo,
|
||||
oro = asta vinta o «sono io». Tema scuro predefinito; chiaro con gli stessi nomi.
|
||||
Mimante — token dell'interfaccia: l'unica origine dei colori (ADR 0016, proposta A «stile Febe»).
|
||||
|
||||
Grigio caldo, carte bianche, accento blu petrolio. Il colore ha significato: neutro = secondario,
|
||||
accento = primario, verde/ambra/rosso = ok/attenzione/pericolo, oro = asta vinta o «sono io».
|
||||
Ogni stato ha la tinta piena (--ok, --warn, --bad, --gold: punti, barre, sfondi pieni), la variante
|
||||
per il testo (--*-text, leggibile su --surface e sul suo --*-soft) e il fondo tenue (--*-soft).
|
||||
|
||||
Tema: data-theme sull'elemento html vale auto (segue il sistema), light o dark. Ogni token è
|
||||
light-dark(chiaro, scuro): color-scheme sceglie quale dei due vale. tests/Mimante.Tests/ContrastTests.cs
|
||||
legge questo file e controlla il contrasto delle coppie testo/fondo nei due temi.
|
||||
*/
|
||||
:root,
|
||||
:root[data-theme="dark"] {
|
||||
color-scheme: dark;
|
||||
--bg: #151920;
|
||||
--surface: #1c2129;
|
||||
--surface-2: #232a34;
|
||||
--surface-3: #2a323d;
|
||||
--line: #2c3441;
|
||||
--text: #e6eaf1;
|
||||
--muted: #93a0b4;
|
||||
--faint: #5f6b7d;
|
||||
--accent: #5b9cff;
|
||||
--accent-ink: #0b1d3a;
|
||||
--ok: #3ecf8e;
|
||||
--warn: #f2b640;
|
||||
--bad: #f15b50;
|
||||
--gold: #e5b94e;
|
||||
--shadow: rgba(0, 0, 0, .45);
|
||||
|
||||
--ok-soft: rgba(62, 207, 142, .16);
|
||||
--warn-soft: rgba(242, 182, 64, .16);
|
||||
--bad-soft: rgba(241, 91, 80, .14);
|
||||
--accent-soft: rgba(91, 156, 255, .16);
|
||||
--gold-soft: rgba(229, 185, 78, .18);
|
||||
--muted-soft: rgba(147, 160, 180, .16);
|
||||
|
||||
--browser-bg: #0e1116;
|
||||
}
|
||||
|
||||
:root[data-theme="light"] {
|
||||
color-scheme: light;
|
||||
--bg: #eef1f5;
|
||||
--surface: #ffffff;
|
||||
--surface-2: #f4f6f9;
|
||||
--surface-3: #e9edf3;
|
||||
--line: #d7dde6;
|
||||
--text: #1b2230;
|
||||
--muted: #5b6778;
|
||||
--faint: #9aa5b5;
|
||||
--accent: #2f6fe4;
|
||||
--accent-ink: #ffffff;
|
||||
--ok: #1f9d63;
|
||||
--warn: #c98a10;
|
||||
--bad: #d63b31;
|
||||
--gold: #b8891a;
|
||||
--shadow: rgba(20, 30, 50, .18);
|
||||
|
||||
--ok-soft: rgba(31, 157, 99, .14);
|
||||
--warn-soft: rgba(201, 138, 16, .14);
|
||||
--bad-soft: rgba(214, 59, 49, .12);
|
||||
--accent-soft: rgba(47, 111, 228, .12);
|
||||
--gold-soft: rgba(184, 137, 26, .16);
|
||||
--muted-soft: rgba(91, 103, 120, .12);
|
||||
|
||||
--browser-bg: #dfe3ea;
|
||||
}
|
||||
:root[data-theme="auto"] { color-scheme: light dark; }
|
||||
:root[data-theme="light"] { color-scheme: light; }
|
||||
:root[data-theme="dark"] { color-scheme: dark; }
|
||||
|
||||
:root {
|
||||
--font: "Segoe UI", system-ui, "Liberation Sans", Arial, sans-serif;
|
||||
--mono: ui-monospace, "Cascadia Mono", "Liberation Mono", monospace;
|
||||
--r: 6px;
|
||||
--r-lg: 8px;
|
||||
--fs: 13px;
|
||||
--fs-small: 12px;
|
||||
--fs-tiny: 11px;
|
||||
--topbar-h: 46px;
|
||||
--nav-w: 212px;
|
||||
--nav-w-narrow: 56px;
|
||||
--bg: light-dark(#F4F4F4, #1B1B1B);
|
||||
--surface: light-dark(#FFFFFF, #242424);
|
||||
--surface-2: light-dark(#FAFAFA, #2B2B2B);
|
||||
--surface-3: light-dark(#ECECEC, #151515);
|
||||
--hover: light-dark(#F2F2F2, #303030);
|
||||
--line: light-dark(#E1E1E1, #363636);
|
||||
--line-soft: light-dark(#ECECEC, #2F2F2F);
|
||||
--line-strong: light-dark(#CCCCCC, #4A4A4A);
|
||||
|
||||
--text: light-dark(#1A1A1A, #EDEDED);
|
||||
--muted: light-dark(#555555, #B0B0B0);
|
||||
--faint: light-dark(#6A6A6A, #9C9C9C);
|
||||
|
||||
--accent: light-dark(#0F5C8C, #62B1E0);
|
||||
--accent-ink: light-dark(#FFFFFF, #0C2230);
|
||||
--accent-text: light-dark(#0B4A72, #8AC6EA);
|
||||
--accent-soft: light-dark(#E3EEF5, #1B3342);
|
||||
--accent-line: light-dark(#B5D0E2, #2C5068);
|
||||
|
||||
--ok: light-dark(#1E7B4F, #5CC08D);
|
||||
--ok-text: light-dark(#1E7B4F, #5CC08D);
|
||||
--ok-soft: light-dark(#E3F2EA, #1A3326);
|
||||
--warn: light-dark(#E0A021, #E0A021);
|
||||
--warn-text: light-dark(#8F5400, #E7B04C);
|
||||
--warn-soft: light-dark(#FBF0DA, #3A2E14);
|
||||
--bad: light-dark(#B42318, #E5534B);
|
||||
--bad-ink: light-dark(#FFFFFF, #2A0B08);
|
||||
--bad-text: light-dark(#B42318, #F0776C);
|
||||
--bad-soft: light-dark(#FBE9E7, #3F1E1B);
|
||||
--gold: light-dark(#B07F0C, #E2BD5A);
|
||||
--gold-text: light-dark(#7D5A00, #E2BD5A);
|
||||
--gold-soft: light-dark(#F5ECD2, #3A3115);
|
||||
--muted-soft: light-dark(#EEEEEE, #2F2F2F);
|
||||
|
||||
--knob: light-dark(#FFFFFF, #F2F2F2);
|
||||
--image-bg: #FFFFFF;
|
||||
--scrim: light-dark(rgba(26, 26, 26, .38), rgba(0, 0, 0, .6));
|
||||
--shadow: light-dark(rgba(26, 26, 26, .12), rgba(0, 0, 0, .5));
|
||||
|
||||
--font: "Archivo", system-ui, "Segoe UI", "Liberation Sans", Arial, sans-serif;
|
||||
--mono: "Cascadia Mono", ui-monospace, "Liberation Mono", monospace;
|
||||
--r: 7px;
|
||||
--r-lg: 10px;
|
||||
--r-badge: 4px;
|
||||
--fs: 13.5px;
|
||||
--fs-small: 12.5px;
|
||||
--fs-tiny: 11.5px;
|
||||
--ctl-h: 32px;
|
||||
--topbar-h: 54px;
|
||||
--nav-w: 220px;
|
||||
--nav-w-narrow: 60px;
|
||||
--gap: 14px;
|
||||
}
|
||||
|
||||
/* Archivo (SIL OFL 1.1, fonts/Archivo-OFL.txt), copiato in wwwroot: nessuna risorsa da fuori. */
|
||||
@font-face {
|
||||
font-family: "Archivo";
|
||||
src: url(../fonts/archivo-latin.woff2) format("woff2");
|
||||
font-weight: 100 900; font-stretch: 62% 125%; font-display: swap;
|
||||
}
|
||||
@font-face {
|
||||
font-family: "Archivo";
|
||||
src: url(../fonts/archivo-latin-ext.woff2) format("woff2");
|
||||
font-weight: 100 900; font-stretch: 62% 125%; font-display: swap;
|
||||
unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
Copyright 2020 The Archivo Project Authors (https://github.com/Omnibus-Type/Archivo) Archivo-Italic[wdth,wght].ttf: Copyright 2020 The Archivo Project Authors (https://github.com/Omnibus-Type/Archivo)
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
http://scripts.sil.org/OFL
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,5 @@
|
||||
<!doctype html>
|
||||
<html lang="it" data-theme="dark">
|
||||
<html lang="it" data-theme="auto">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// al pannello o con il bottone del registro nella barra); la pagina #/registro, fuori dal menu,
|
||||
// è il registro completo con i filtri.
|
||||
|
||||
import { el, $, num, euro, bytes, store, notice, pingLevel, pingText, PING_COLORS } from './util.js';
|
||||
import { el, $, num, euro, bytes, store, pingLevel, pingText, PING_COLORS } from './util.js';
|
||||
import { conn, state, subscribe, post } from './state.js';
|
||||
import { icon } from './icons.js';
|
||||
import './exports.js'; // il risultato di un'esportazione si apre anche da un'altra pagina
|
||||
@@ -16,23 +16,33 @@ const pages = [
|
||||
{ id: 'storico', label: 'Storico', ic: 'history', title: 'Le aste concluse, con il perché e le esportazioni CSV', load: () => import('./pages/storico.js') },
|
||||
{ id: 'apprendimento', label: 'Apprendimento', ic: 'chart', title: 'Cosa ha imparato il modello e quanto rende', load: () => import('./pages/apprendimento.js') },
|
||||
{ id: 'puntate-gratis', label: 'Puntate gratis', ic: 'gift', title: 'Riscatto automatico delle puntate gratuite, forzieri e registro delle operazioni', load: () => import('./pages/puntate-gratis.js') },
|
||||
{ id: 'browser', label: 'Browser', ic: 'globe', title: 'Il browser del bot: naviga dentro Bidoo, accedi con il tuo utente, aggiungi un\'asta al monitor', load: () => import('./pages/browser.js') },
|
||||
{ id: 'accesso', label: 'Accesso a Bidoo', ic: 'globe', title: 'Collega il tuo utente Bidoo incollando la sessione copiata da Chrome; stato della sessione', load: () => import('./pages/accesso.js') },
|
||||
{ id: 'impostazioni', label: 'Impostazioni', ic: 'gear', title: 'Paletti, rischio, puntate, apprendimento, rete, Telegram, dati', load: () => import('./pages/impostazioni.js') },
|
||||
{ id: 'registro', label: 'Registro', ic: 'log', title: 'Il registro dell\'applicazione, con filtri', load: () => import('./pages/registro.js'), hidden: true }
|
||||
];
|
||||
|
||||
// Indirizzi delle versioni precedenti dell'interfaccia.
|
||||
const aliases = { accesso: 'browser' };
|
||||
const aliases = { browser: 'accesso' };
|
||||
|
||||
let current = null; // { id, module }
|
||||
|
||||
// ── tema ──────────────────────────────────────────────────────────────
|
||||
|
||||
// auto segue il tema del sistema (tokens.css: color-scheme light dark); light e dark lo fissano.
|
||||
const THEMES = ['auto', 'light', 'dark'];
|
||||
const THEME_NAMES = { auto: 'automatico (come il sistema)', light: 'chiaro', dark: 'scuro' };
|
||||
|
||||
function applyTheme(theme) {
|
||||
if (!THEMES.includes(theme)) theme = 'auto';
|
||||
document.documentElement.dataset.theme = theme;
|
||||
store.set('theme', theme);
|
||||
if (themeBtn) {
|
||||
const next = THEMES[(THEMES.indexOf(theme) + 1) % THEMES.length];
|
||||
themeBtn.title = `Tema ${THEME_NAMES[theme]}. Clic: tema ${THEME_NAMES[next]} (ricordato in questo browser)`;
|
||||
}
|
||||
}
|
||||
applyTheme(store.get('theme', 'dark'));
|
||||
let themeBtn = null;
|
||||
applyTheme(store.get('theme', 'auto'));
|
||||
|
||||
// ── struttura ─────────────────────────────────────────────────────────
|
||||
|
||||
@@ -57,14 +67,17 @@ function setText(node, text) {
|
||||
|
||||
function buildTopbar() {
|
||||
const bar = $('#topbar');
|
||||
const theme = el('button', { class: 'icon-btn', type: 'button', title: 'Tema chiaro o scuro (ricordato in questo browser)', 'aria-label': 'Tema' }, icon('theme'));
|
||||
theme.addEventListener('click', () => applyTheme(document.documentElement.dataset.theme === 'light' ? 'dark' : 'light'));
|
||||
const theme = el('button', { class: 'icon-btn', type: 'button', 'aria-label': 'Tema' }, icon('theme'));
|
||||
themeBtn = theme;
|
||||
theme.addEventListener('click', () => {
|
||||
const now = document.documentElement.dataset.theme;
|
||||
applyTheme(THEMES[(THEMES.indexOf(now) + 1) % THEMES.length]);
|
||||
});
|
||||
applyTheme(document.documentElement.dataset.theme);
|
||||
const exit = el('a', { class: 'icon-btn', href: '/esci', title: 'Esci dall\'interfaccia (il bot continua a lavorare)', 'aria-label': 'Esci' }, icon('logout'));
|
||||
|
||||
bar.append(
|
||||
el('div', { class: 'chips' },
|
||||
chip('sim', 'Modalità debug (--simulatore): aste e avversari finti del simulatore interno'),
|
||||
chip('user', 'Utente Bidoo collegato. Senza utente il bot segue le aste e impara, ma non punta: accedi dal Browser'),
|
||||
chip('bids', BIDS_TITLE),
|
||||
chip('credit', 'Credito Bidoo Shop', true),
|
||||
chip('confirm', 'Aste vinte in attesa di conferma su Bidoo', true),
|
||||
@@ -77,9 +90,17 @@ function buildTopbar() {
|
||||
parts.pingDot = el('span', { class: 'dot off' });
|
||||
parts.ping = el('b', null, '—');
|
||||
chips.ping.append(parts.pingDot, 'Ping ', parts.ping);
|
||||
chips.sim.hidden = true;
|
||||
chips.user.classList.add('clickable');
|
||||
chips.user.addEventListener('click', () => { location.hash = '#/browser'; });
|
||||
}
|
||||
|
||||
// Lo stato in fondo alla barra laterale: in che mondo lavora il bot e con quale utente di Bidoo.
|
||||
const side = {};
|
||||
function buildSideStatus() {
|
||||
side.world = el('div', { class: 'world' });
|
||||
side.avatar = el('span', { class: 'avatar', 'aria-hidden': 'true' });
|
||||
side.user = el('b');
|
||||
side.detail = el('small');
|
||||
side.who = el('a', { class: 'who', href: '#/accesso' }, side.avatar, el('span', null, side.user, side.detail));
|
||||
return el('div', { class: 'side-status' }, side.world, side.who);
|
||||
}
|
||||
|
||||
let brand = null;
|
||||
@@ -100,7 +121,7 @@ function buildNav() {
|
||||
nav.append(el('a', { href: '#/' + p.id, title: p.title, dataset: { page: p.id } },
|
||||
el('span', { class: 'ic', 'aria-hidden': 'true' }, icon(p.ic)), el('span', { class: 'lbl' }, p.label)));
|
||||
}
|
||||
nav.append(el('span', { class: 'sep' }));
|
||||
nav.append(el('span', { class: 'sep' }), buildSideStatus());
|
||||
const collapse = el('button', { class: 'collapse', type: 'button' });
|
||||
const setNarrow = narrow => {
|
||||
app.classList.toggle('narrow', narrow);
|
||||
@@ -124,20 +145,25 @@ function buildNav() {
|
||||
// ── barra: aggiornamenti ──────────────────────────────────────────────
|
||||
|
||||
function renderMode() {
|
||||
chips.sim.hidden = !state.mode.simulator;
|
||||
chips.sim.className = 'chip sim';
|
||||
chips.sim.replaceChildren(el('span', { class: 'dot warn' }), el('b', null, 'SIMULATORE'));
|
||||
const sim = !!state.mode.simulator;
|
||||
side.world.className = 'world' + (sim ? ' sim' : '');
|
||||
side.world.replaceChildren(el('span', { class: 'dot ' + (sim ? 'warn' : '') }), el('span', { class: 'lbl' }, sim ? 'Simulatore' : 'Sul sito vero'));
|
||||
side.world.title = sim
|
||||
? 'Modalità debug (--simulatore): aste e avversari finti del simulatore interno; niente arriva al modello vero'
|
||||
: 'Il bot segue le aste vere di Bidoo';
|
||||
}
|
||||
|
||||
function renderSession() {
|
||||
const s = state.session;
|
||||
const dot = { ok: '', verifica: 'warn', scaduta: 'bad', simulatore: 'warn', assente: 'off' }[s.state] ?? 'off';
|
||||
if (s.state === 'assente' || !s.user) {
|
||||
chips.user.replaceChildren(el('span', { class: 'dot off' }), 'Bidoo ', el('b', null, 'non collegato'));
|
||||
} else {
|
||||
chips.user.replaceChildren(el('span', { class: 'dot ' + dot }), 'Bidoo ', el('b', null, s.user), s.state === 'scaduta' ? ' sessione scaduta' : '');
|
||||
}
|
||||
chips.user.title = `Utente Bidoo: ${s.user || 'nessuno'}${s.detail ? ' (' + s.detail + ')' : ''}. Clic per il Browser`;
|
||||
const level = { ok: 'ok', verifica: 'warn', scaduta: 'bad', simulatore: 'warn', assente: '' }[s.state] ?? '';
|
||||
const present = s.state !== 'assente' && !!s.user;
|
||||
side.avatar.className = 'avatar ' + (present ? level : '');
|
||||
side.avatar.textContent = present ? s.user.replace(/[^\p{L}\p{N}]/gu, '').slice(0, 2) || '?' : '–';
|
||||
side.user.textContent = present ? s.user : 'Nessun utente';
|
||||
side.detail.textContent = !present ? 'Bidoo non collegato'
|
||||
: { ok: 'Bidoo collegato', verifica: 'Bidoo da verificare', scaduta: 'Sessione scaduta', simulatore: 'Utente del simulatore' }[s.state] ?? s.state;
|
||||
side.who.title = `Utente Bidoo: ${s.user || 'nessuno'}${s.detail ? ' (' + s.detail + ')' : ''}. `
|
||||
+ 'Senza utente il bot segue le aste e impara, ma non punta. Clic per il Browser';
|
||||
}
|
||||
|
||||
function renderAccount() {
|
||||
@@ -225,11 +251,6 @@ function start() {
|
||||
subscribe('net', renderNet);
|
||||
subscribe('db', renderDb);
|
||||
subscribe('hello', m => { brand.title = brandTitle(m.version); });
|
||||
subscribe('login.state', m => {
|
||||
// L'esito dell'accesso a Bidoo conta: da lì il bot può puntare.
|
||||
if (m.state === 'riuscito' && m.detail && !m.detail.startsWith('Accesso riuscito: salvo')) notice(m.detail, 'ok', 'Accesso a Bidoo');
|
||||
if (m.state === 'errore') notice(m.detail || 'Accesso a Bidoo non riuscito.', 'bad', 'Accesso a Bidoo');
|
||||
});
|
||||
renderMode(); renderSession(); renderAccount(); renderNet(); renderDb();
|
||||
window.addEventListener('hashchange', route);
|
||||
conn.connect();
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
// Accesso a Bidoo (ADR 0017): si incolla la sessione copiata da Chrome, che il bot salva cifrata
|
||||
// e usa per puntare. Accanto: stato della sessione e come copiarla. Il browser del bot della 1.x
|
||||
// non c'è più.
|
||||
|
||||
import { el, time, dateTime, report, confirmDialog, kv, num } from '../util.js';
|
||||
import { state, subscribe, send } from '../state.js';
|
||||
import { icon } from '../icons.js';
|
||||
|
||||
let bidsValue, unsub = [];
|
||||
|
||||
// Solo il totale: la divisione fra a pagamento e gratuite serve al modello, non a chi guarda.
|
||||
const BIDS_TITLE = 'Puntate sul conto (a pagamento e gratuite insieme)';
|
||||
|
||||
export async function mount(host) {
|
||||
host.append(el('div', { class: 'toolbar', id: 'login-toolbar' }), build());
|
||||
unsub.push(subscribe('session', renderSession), subscribe('account', renderBids));
|
||||
renderSession();
|
||||
}
|
||||
|
||||
export function unmount() {
|
||||
for (const u of unsub) u();
|
||||
unsub = [];
|
||||
bidsValue = null;
|
||||
}
|
||||
|
||||
function build() {
|
||||
const text = el('textarea', {
|
||||
class: 'txt paste', rows: 9, spellcheck: 'false', autocomplete: 'off',
|
||||
placeholder: 'curl \'https://it.bidoo.com/\' -H … -b \'__stattrb=…; PHPSESSID=…\' -H \'user-agent: …\'',
|
||||
title: 'Il testo copiato da Chrome: «Copia come cURL» di una richiesta a it.bidoo.com, le intestazioni della richiesta, la riga Cookie o il solo valore di __stattrb'
|
||||
});
|
||||
const ua = el('input', {
|
||||
class: 'txt', value: navigator.userAgent, spellcheck: 'false',
|
||||
title: 'Lo User-Agent del browser da cui hai copiato la sessione: Bidoo lo lega alla sessione. Serve solo se il testo incollato non lo contiene (cURL e intestazioni lo portano già)'
|
||||
});
|
||||
const result = el('p', { class: 'help note', 'aria-live': 'polite' });
|
||||
const use = el('button', { class: 'btn primary', type: 'button', title: 'Controlla la sessione su Bidoo e, se vale, la salva cifrata e passa al tuo utente', onclick: submit }, icon('check'), ' Usa questa sessione');
|
||||
text.addEventListener('keydown', e => { if (e.key === 'Enter' && (e.ctrlKey || e.metaKey)) { e.preventDefault(); submit(); } });
|
||||
|
||||
async function submit() {
|
||||
use.disabled = true;
|
||||
result.textContent = 'Controllo la sessione su Bidoo…';
|
||||
try {
|
||||
const ack = await send({ t: 'session.paste', cookie: text.value, userAgent: ua.value }, 60000);
|
||||
result.textContent = ack.ok
|
||||
? `Sessione in uso (${ack.data?.format || 'testo incollato'}${ack.data?.userAgentFromPaste ? ', User-Agent dal testo' : ', User-Agent del campo'}).`
|
||||
: '';
|
||||
// Il testo contiene la sessione: non resta nella pagina.
|
||||
if (ack.ok) text.value = '';
|
||||
report(ack, { important: true });
|
||||
} finally {
|
||||
use.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
const paste = el('section', { class: 'section' }, el('h2', null, 'Incolla la sessione'), el('div', { class: 'in' },
|
||||
el('p', { class: 'help note' }, 'Il bot usa la sessione del tuo Chrome: copiala come spiegato qui sotto e incollala nel riquadro. L\'ultima incollata sostituisce la precedente.'),
|
||||
text,
|
||||
el('label', { class: 'help' }, 'User-Agent, se il testo non lo contiene'),
|
||||
ua,
|
||||
el('div', { class: 'row' }, use, el('span', { class: 'help' }, 'oppure Ctrl+Invio')),
|
||||
result));
|
||||
|
||||
const steps = el('section', { class: 'section' }, el('h2', null, 'Come copiarla da Chrome'), el('div', { class: 'in' },
|
||||
el('ol', { class: 'plain steps' },
|
||||
el('li', null, 'Apri ', el('code', null, 'it.bidoo.com'), ' in Chrome, con il tuo utente collegato.'),
|
||||
el('li', null, 'Premi ', el('kbd', null, 'F12'), ' e scegli la scheda ', el('b', null, 'Rete'), ' (Network).'),
|
||||
el('li', null, 'Ricarica la pagina con ', el('kbd', null, 'F5'), '.'),
|
||||
el('li', null, 'Tasto destro sulla prima riga (', el('code', null, 'it.bidoo.com'), ') ▸ ', el('b', null, 'Copia'), ' ▸ ', el('b', null, 'Copia come cURL'), ': bash o cmd vanno bene tutti e due.'),
|
||||
el('li', null, 'Incolla nel riquadro qui sopra e premi «Usa questa sessione».')),
|
||||
el('p', { class: 'help note' }, 'In alternativa: ', el('kbd', null, 'F12'), ' ▸ ', el('b', null, 'Applicazione'), ' ▸ ', el('b', null, 'Cookie'), ' ▸ ', el('code', null, 'https://it.bidoo.com'),
|
||||
', scegli ', el('code', null, '__stattrb'), ' e incolla il suo valore da solo. Vanno bene anche le intestazioni della richiesta o la sola riga Cookie.'),
|
||||
el('p', { class: 'help note' }, 'Non premere «Esci» su Bidoo da quel browser: chiude anche la sessione del bot. Chiudi solo la scheda.'),
|
||||
el('p', { class: 'help note' }, 'Il testo contiene la tua sessione: incollalo solo qui. Il bot tiene i cookie cifrati in ', el('code', null, '/config/sessione'), ' e non li scrive mai nei registri.')));
|
||||
|
||||
const status = el('section', { class: 'section' }, el('h2', null, 'Stato sessione'), el('div', { class: 'in', id: 'session-kv' }));
|
||||
|
||||
return el('div', { class: 'page' }, el('div', { id: 'session-banner' }),
|
||||
el('div', { class: 'access-grid' }, el('div', { class: 'access-main' }, paste, steps), status));
|
||||
}
|
||||
|
||||
function renderSession() {
|
||||
const s = state.session;
|
||||
const bar = document.getElementById('login-toolbar');
|
||||
if (!bar) return;
|
||||
const pill = { ok: ['ok', 'Collegato'], verifica: ['warn', 'Verifica in corso'], scaduta: ['bad', 'Sessione scaduta'], simulatore: ['warn', 'Simulatore (debug)'], assente: ['muted', 'Non collegato'] }[s.state] || ['muted', s.state || '—'];
|
||||
const logged = s.state === 'ok' || s.state === 'verifica' || s.state === 'scaduta';
|
||||
bar.replaceChildren(el('h1', null, 'Accesso a Bidoo'), el('span', { class: 'pill ' + pill[0], title: 'Stato della sessione con Bidoo' }, pill[1]), el('span', { class: 'spacer' }),
|
||||
logged ? el('button', { class: 'btn', type: 'button', title: 'Chiede a Bidoo la pagina del conto: utente, saldo, credito', onclick: async () => report(await send({ t: 'session.verify' }, 30000), { important: true }) }, 'Verifica connessione') : '',
|
||||
logged ? el('button', { class: 'btn', type: 'button', title: 'Cancella la sessione salvata: il bot continua a seguire le aste senza puntare', onclick: logout }, 'Disconnetti') : '');
|
||||
|
||||
const banner = document.getElementById('session-banner');
|
||||
const text = {
|
||||
scaduta: ['banner', `La sessione salvata non è più valida (${s.detail || 'Bidoo risponde con la pagina di login'}). Incollane una nuova qui sotto; nel frattempo le aste sono passate in Osserva.`],
|
||||
simulatore: ['banner info', 'Modalità debug: stai vedendo il simulatore. Una sessione incollata qui vale per il sito vero.'],
|
||||
assente: ['banner info', 'Nessun utente collegato: il bot segue le aste e allena il modello, ma non punta. Incolla la sessione del tuo Chrome per puntare.']
|
||||
}[s.state];
|
||||
banner.replaceChildren(text ? el('div', { class: text[0] }, text[1]) : '');
|
||||
|
||||
bidsValue = el('span');
|
||||
document.getElementById('session-kv')?.replaceChildren(kv([
|
||||
['Utente', s.user || '—', 'Utente Bidoo collegato al bot'],
|
||||
['Stato', pill[1] + (s.detail && s.state !== 'simulatore' ? ` (${s.detail})` : ''), 'Stato della sessione con Bidoo'],
|
||||
['Sessione in uso', s.source ? `${s.source}${s.since ? ', dal ' + dateTime(s.since) : ''}` : '—', 'Da dove viene la sessione in uso e da quando'],
|
||||
['Ultima verifica', s.checkedAt ? time(s.checkedAt) : '—', 'Ora dell\'ultima verifica della sessione sulla pagina del conto di Bidoo'],
|
||||
['Puntate sul conto', bidsValue, BIDS_TITLE],
|
||||
['Può puntare', s.canBid ? 'sì' : 'no', 'Serve un utente collegato: senza, il bot segue e impara soltanto']
|
||||
]));
|
||||
renderBids();
|
||||
}
|
||||
|
||||
/** Il saldo cambia a ogni puntata: si aggiorna solo il suo numero, non il riquadro. */
|
||||
function renderBids() {
|
||||
if (!bidsValue) return;
|
||||
const bids = state.account.bids;
|
||||
const text = bids != null ? num(bids) : '—';
|
||||
if (bidsValue.textContent !== text) bidsValue.textContent = text;
|
||||
}
|
||||
|
||||
async function logout() {
|
||||
const ok = await confirmDialog({ title: 'Disconnettere?', body: 'La sessione salvata si cancella: il bot continua a seguire le aste e ad allenare il modello, ma non punta finché non ne incolli un\'altra.', okText: 'Disconnetti', danger: true });
|
||||
if (ok) report(await send({ t: 'session.logout' }, 60000));
|
||||
}
|
||||
@@ -251,7 +251,7 @@ async function setAll(mode) {
|
||||
async function bidNow(id) {
|
||||
if (!state.auctions.get(id)) return;
|
||||
if (!state.mode.canBid) {
|
||||
notice('Nessun utente Bidoo collegato: il bot segue le aste ma non può puntare. Accedi dalla pagina Browser.', 'warn');
|
||||
notice('Nessun utente Bidoo collegato: il bot segue le aste ma non può puntare. Incolla la sessione in Accesso a Bidoo.', 'warn');
|
||||
return;
|
||||
}
|
||||
// Nessuna conferma: la puntata parte subito. L'esito si dice solo se non è riuscita;
|
||||
|
||||
@@ -1,223 +0,0 @@
|
||||
// Browser (come nella versione desktop): il browser del bot in streaming, per navigare dentro
|
||||
// Bidoo (indietro, avanti, ricarica, home, indirizzo), accedere con il proprio utente e
|
||||
// aggiungere al monitor l'asta aperta. Accanto: stato della sessione e cookie incollati.
|
||||
|
||||
import { el, time, dateTime, report, confirmDialog, kv, num } from '../util.js';
|
||||
import { state, subscribe, send, post } from '../state.js';
|
||||
import { icon } from '../icons.js';
|
||||
|
||||
let root, canvas, ctx, urlInput, addBtn, idle, bidsValue, frameSize = { w: 1280, h: 900 }, unsub = [], open = false, lastMove = 0, editingUrl = false;
|
||||
|
||||
// Solo il totale: la divisione fra a pagamento e gratuite serve al modello, non a chi guarda.
|
||||
const BIDS_TITLE = 'Puntate sul conto (a pagamento e gratuite insieme)';
|
||||
|
||||
const auctionUrl = /auction\.php\?a=|_\d{6,}(?:$|[/?#])/i;
|
||||
|
||||
export async function mount(host) {
|
||||
root = el('div', { class: 'page' });
|
||||
host.append(el('div', { class: 'toolbar', id: 'login-toolbar' }), root);
|
||||
build();
|
||||
unsub.push(
|
||||
subscribe('session', renderSession),
|
||||
subscribe('account', renderBids),
|
||||
subscribe('login.frame', onFrame),
|
||||
subscribe('login.state', onState));
|
||||
renderSession();
|
||||
}
|
||||
|
||||
export function unmount() {
|
||||
for (const u of unsub) u();
|
||||
unsub = [];
|
||||
bidsValue = null;
|
||||
document.removeEventListener('paste', onPaste);
|
||||
}
|
||||
|
||||
function navButton(ic, title, onclick) {
|
||||
return el('button', { class: 'icon-btn', type: 'button', title, 'aria-label': title, onclick }, icon(ic));
|
||||
}
|
||||
|
||||
function build() {
|
||||
urlInput = el('input', { class: 'addr', value: 'https://it.bidoo.com/', spellcheck: 'false', title: 'Indirizzo della pagina: scrivi un indirizzo di Bidoo (o un percorso come /auction.php?a=…) e premi Invio' });
|
||||
urlInput.addEventListener('focus', () => { editingUrl = true; urlInput.select(); });
|
||||
urlInput.addEventListener('blur', () => { editingUrl = false; });
|
||||
urlInput.addEventListener('keydown', async e => {
|
||||
if (e.key !== 'Enter') return;
|
||||
e.preventDefault();
|
||||
urlInput.blur();
|
||||
if (!open) await openBrowser();
|
||||
report(await send({ t: 'login.navigate', url: urlInput.value }));
|
||||
});
|
||||
canvas = el('canvas', { width: 1280, height: 900, tabindex: '0', 'aria-label': 'Browser del bot: clic e tasti vanno alla pagina', hidden: true });
|
||||
ctx = canvas.getContext('2d');
|
||||
idle = el('div', { class: 'idle' });
|
||||
setOpen(false);
|
||||
addBtn = el('button', { class: 'btn primary', type: 'button', disabled: true, title: 'Aggiunge al monitor l\'asta aperta nel browser, in Osserva',
|
||||
onclick: async () => report(await send({ t: 'login.add_current', mode: 'osserva' }, 45000), { important: true }) }, icon('plus'), ' Aggiungi al monitor');
|
||||
const browser = el('div', { class: 'browser' },
|
||||
el('div', { class: 'url' },
|
||||
navButton('back', 'Indietro', () => send({ t: 'login.back' })),
|
||||
navButton('forward', 'Avanti', () => send({ t: 'login.forward' })),
|
||||
navButton('refresh', 'Ricarica la pagina', () => send({ t: 'login.reload' })),
|
||||
navButton('home', 'Home di Bidoo', async () => { if (!open) await openBrowser(); send({ t: 'login.navigate', url: '' }); }),
|
||||
urlInput, addBtn,
|
||||
el('span', { class: 'pill ok', title: 'Quello che vedi gira dentro il bot, non nel tuo browser' }, 'browser del bot'),
|
||||
navButton('close', 'Chiudi il browser del bot (libera memoria; si chiude anche da solo dopo mezz\'ora senza uso)', () => send({ t: 'login.close' }))),
|
||||
el('div', { class: 'view' }, canvas, idle));
|
||||
|
||||
const cookie = el('textarea', { class: 'txt', rows: 3, placeholder: '__stattrb=…; PHPSESSID=…', style: { width: '100%', resize: 'vertical' }, title: 'La riga Cookie intera, dagli strumenti per sviluppatori del tuo browser (scheda Rete, una richiesta a bidoo.com)' });
|
||||
const ua = el('input', { class: 'txt', placeholder: 'User-Agent del tuo browser', style: { width: '100%' }, value: navigator.userAgent, title: 'Lo User-Agent del browser da cui hai copiato i cookie: Bidoo lo lega alla sessione' });
|
||||
const paste = el('button', { class: 'btn', type: 'button', onclick: async () => {
|
||||
const ack = await send({ t: 'session.paste', cookie: cookie.value, userAgent: ua.value }, 60000);
|
||||
report(ack, { important: true });
|
||||
if (ack.ok) cookie.value = '';
|
||||
} }, 'Usa questi cookie');
|
||||
|
||||
const side = el('div', { class: 'browser-side' },
|
||||
el('section', { class: 'section' }, el('h2', null, 'Stato sessione'), el('div', { class: 'in', id: 'session-kv' })),
|
||||
el('section', { class: 'section' }, el('h2', null, 'Come funziona'), el('div', { class: 'in' },
|
||||
el('ul', { class: 'plain' },
|
||||
el('li', null, 'Naviga dentro Bidoo come sul sito: clic e tasti vanno al browser del bot.'),
|
||||
el('li', null, 'Per puntare fai il login qui: i cookie si salvano cifrati in ', el('code', null, '/config/sessione'), ' e il bot passa al tuo utente.'),
|
||||
el('li', null, 'Senza utente il bot segue le aste e allena il modello, ma non punta.'),
|
||||
el('li', null, 'Su una pagina d\'asta, «Aggiungi al monitor» la mette in elenco.')),
|
||||
el('p', { class: 'help', style: { margin: 0 } }, 'Un solo account. La password di Bidoo passa dal riquadro al sito come tasti; il bot non la salva.'))),
|
||||
el('section', { class: 'section' }, el('h2', null, 'Alternativa: incolla i cookie'), el('div', { class: 'in' },
|
||||
el('p', { class: 'help', style: { margin: 0 } }, 'Copia l\'intestazione Cookie dal tuo browser (strumenti sviluppatore ▸ Rete) con lo User-Agent. L\'ultima sessione importata sostituisce la precedente.'),
|
||||
cookie, ua, el('div', { class: 'row' }, paste))));
|
||||
|
||||
root.append(el('div', { id: 'session-banner' }), el('div', { class: 'browser-grid' }, browser, side));
|
||||
wireInput();
|
||||
}
|
||||
|
||||
function renderSession() {
|
||||
const s = state.session;
|
||||
const bar = document.getElementById('login-toolbar');
|
||||
if (!bar) return;
|
||||
const pill = { ok: ['ok', 'Collegato'], verifica: ['warn', 'Verifica in corso'], scaduta: ['bad', 'Sessione scaduta'], simulatore: ['warn', 'Simulatore (debug)'], assente: ['muted', 'Non collegato'] }[s.state] || ['muted', s.state || '—'];
|
||||
const logged = s.state === 'ok' || s.state === 'verifica' || s.state === 'scaduta';
|
||||
bar.replaceChildren(el('h1', null, 'Browser'), el('span', { class: 'pill ' + pill[0] }, pill[1]), el('span', { class: 'spacer' }),
|
||||
logged ? el('button', { class: 'btn', type: 'button', title: 'Chiede a Bidoo la pagina del conto: utente, saldo, credito', onclick: async () => report(await send({ t: 'session.verify' }, 30000), { important: true }) }, 'Verifica connessione') : '',
|
||||
logged ? el('button', { class: 'btn', type: 'button', title: 'Cancella la sessione salvata: il bot continua a seguire le aste senza puntare', onclick: logout }, 'Disconnetti') : '');
|
||||
|
||||
const banner = document.getElementById('session-banner');
|
||||
const text = {
|
||||
scaduta: ['banner', `La sessione salvata non è più valida (${s.detail || 'Bidoo risponde con la pagina di login'}). Rifai l'accesso qui sotto; nel frattempo le aste sono passate in Osserva.`],
|
||||
simulatore: ['banner info', 'Modalità debug: stai vedendo il simulatore. Il Browser qui sotto apre comunque il sito vero di Bidoo.'],
|
||||
assente: ['banner info', 'Nessun utente collegato: il bot segue le aste e allena il modello, ma non punta. Apri il browser e fai il login per puntare.']
|
||||
}[s.state];
|
||||
banner.replaceChildren(text ? el('div', { class: text[0] }, text[1]) : '');
|
||||
|
||||
bidsValue = el('span');
|
||||
document.getElementById('session-kv')?.replaceChildren(kv([
|
||||
['Utente', s.user || '—', 'Utente Bidoo collegato al bot'],
|
||||
['Stato', pill[1] + (s.detail && s.state !== 'simulatore' ? ` (${s.detail})` : ''), 'Stato della sessione con Bidoo'],
|
||||
['Sessione in uso', s.source ? `${s.source}${s.since ? ', dal ' + dateTime(s.since) : ''}` : '—', 'Da dove viene la sessione in uso e da quando'],
|
||||
['Ultima verifica', s.checkedAt ? time(s.checkedAt) : '—', 'Ora dell\'ultima verifica della sessione sulla pagina del conto di Bidoo'],
|
||||
['Puntate sul conto', bidsValue, BIDS_TITLE],
|
||||
['Può puntare', s.canBid ? 'sì' : 'no', 'Serve un utente collegato: senza, il bot segue e impara soltanto'],
|
||||
['Browser del bot', open ? 'aperto' : 'chiuso', 'Se il browser del bot è aperto (si chiude da solo dopo mezz\'ora senza uso)']
|
||||
]));
|
||||
renderBids();
|
||||
}
|
||||
|
||||
/** Il saldo cambia a ogni puntata: si aggiorna solo il suo numero, non il riquadro. */
|
||||
function renderBids() {
|
||||
if (!bidsValue) return;
|
||||
const bids = state.account.bids;
|
||||
const text = bids != null ? num(bids) : '—';
|
||||
if (bidsValue.textContent !== text) bidsValue.textContent = text;
|
||||
}
|
||||
|
||||
async function logout() {
|
||||
const ok = await confirmDialog({ title: 'Disconnettere?', body: 'La sessione salvata si cancella: il bot continua a seguire le aste e ad allenare il modello, ma non punta finché non rifai l\'accesso.', okText: 'Disconnetti', danger: true });
|
||||
if (ok) report(await send({ t: 'session.logout' }, 60000));
|
||||
}
|
||||
|
||||
async function openBrowser() {
|
||||
idle.replaceChildren(el('p', null, 'Avvio il browser del bot…'));
|
||||
const ack = await send({ t: 'login.open' }, 60000);
|
||||
// L'esito si vede nel riquadro stesso (il browser compare, o il motivo per cui non parte).
|
||||
if (!ack.ok) {
|
||||
idle.replaceChildren(el('p', null, ack.msg || 'Browser non avviato.'),
|
||||
el('button', { class: 'btn primary', type: 'button', onclick: openBrowser }, 'Riprova'),
|
||||
el('p', { class: 'help' }, 'Per accedere senza browser usa «incolla i cookie» qui accanto.'));
|
||||
}
|
||||
return ack.ok;
|
||||
}
|
||||
|
||||
function onFrame(m) {
|
||||
if (!open) setOpen(true);
|
||||
frameSize = { w: m.w || 1280, h: m.h || 900 };
|
||||
if (m.url) setUrl(m.url);
|
||||
const img = new Image();
|
||||
img.onload = () => {
|
||||
if (canvas.width !== img.width || canvas.height !== img.height) { canvas.width = img.width; canvas.height = img.height; }
|
||||
ctx.drawImage(img, 0, 0);
|
||||
};
|
||||
img.src = 'data:image/jpeg;base64,' + m.jpegBase64;
|
||||
}
|
||||
|
||||
function setUrl(url) {
|
||||
if (!editingUrl && urlInput.value !== url) urlInput.value = url;
|
||||
addBtn.disabled = !auctionUrl.test(url);
|
||||
}
|
||||
|
||||
function onState(m) {
|
||||
if (m.state === 'aperto') { setOpen(true); if (m.detail) setUrl(m.detail); }
|
||||
if (m.state === 'chiuso' || m.state === 'errore') setOpen(false, m.detail);
|
||||
renderSession();
|
||||
}
|
||||
|
||||
function setOpen(v, detail) {
|
||||
open = v;
|
||||
canvas.hidden = !v;
|
||||
idle.hidden = v;
|
||||
if (v) canvas.focus();
|
||||
else {
|
||||
addBtn && (addBtn.disabled = true);
|
||||
idle.replaceChildren(el('p', null, detail || 'Il browser del bot è chiuso.'),
|
||||
el('button', { class: 'btn primary', type: 'button', onclick: openBrowser }, 'Apri il browser del bot'));
|
||||
}
|
||||
}
|
||||
|
||||
// ── clic e tasti verso il browser del bot ───────────────────────────────
|
||||
|
||||
function toPage(e) {
|
||||
const r = canvas.getBoundingClientRect();
|
||||
return { x: (e.clientX - r.left) / r.width * frameSize.w, y: (e.clientY - r.top) / r.height * frameSize.h };
|
||||
}
|
||||
|
||||
const buttonName = b => (b === 2 ? 'right' : b === 1 ? 'middle' : 'left');
|
||||
const modifiers = e => (e.altKey ? 1 : 0) | (e.ctrlKey ? 2 : 0) | (e.metaKey ? 4 : 0) | (e.shiftKey ? 8 : 0);
|
||||
|
||||
function wireInput() {
|
||||
canvas.addEventListener('mousedown', e => { e.preventDefault(); canvas.focus(); const p = toPage(e); post({ t: 'login.input', kind: 'mouse', type: 'mousePressed', ...p, button: buttonName(e.button), clickCount: e.detail || 1, modifiers: modifiers(e) }); });
|
||||
canvas.addEventListener('mouseup', e => { const p = toPage(e); post({ t: 'login.input', kind: 'mouse', type: 'mouseReleased', ...p, button: buttonName(e.button), clickCount: e.detail || 1, modifiers: modifiers(e) }); });
|
||||
canvas.addEventListener('mousemove', e => {
|
||||
const now = performance.now();
|
||||
if (now - lastMove < 40) return;
|
||||
lastMove = now;
|
||||
post({ t: 'login.input', kind: 'mouse', type: 'mouseMoved', ...toPage(e), modifiers: modifiers(e) });
|
||||
});
|
||||
canvas.addEventListener('wheel', e => { e.preventDefault(); post({ t: 'login.input', kind: 'mouse', type: 'mouseWheel', ...toPage(e), deltaX: e.deltaX, deltaY: e.deltaY }); }, { passive: false });
|
||||
canvas.addEventListener('contextmenu', e => e.preventDefault());
|
||||
canvas.addEventListener('keydown', e => {
|
||||
const printable = e.key.length === 1 && !e.ctrlKey && !e.metaKey;
|
||||
if (printable) { e.preventDefault(); post({ t: 'login.input', kind: 'text', text: e.key }); return; }
|
||||
if (e.ctrlKey && e.key === 'v') return; // l'incolla arriva dall'evento paste
|
||||
e.preventDefault();
|
||||
post({ t: 'login.input', kind: 'key', type: 'keyDown', key: e.key, code: e.code, keyCode: e.keyCode, modifiers: modifiers(e) });
|
||||
});
|
||||
canvas.addEventListener('keyup', e => {
|
||||
if (e.key.length === 1 && !e.ctrlKey && !e.metaKey) return;
|
||||
post({ t: 'login.input', kind: 'key', type: 'keyUp', key: e.key, code: e.code, keyCode: e.keyCode, modifiers: modifiers(e) });
|
||||
});
|
||||
// L'incolla arriva al documento, non alla tela: si inoltra solo se la tela ha il fuoco.
|
||||
document.addEventListener('paste', onPaste);
|
||||
}
|
||||
|
||||
function onPaste(e) {
|
||||
if (document.activeElement !== canvas) return;
|
||||
const text = e.clipboardData?.getData('text');
|
||||
if (text) { e.preventDefault(); post({ t: 'login.input', kind: 'text', text }); }
|
||||
}
|
||||
@@ -120,7 +120,7 @@ const sections = [
|
||||
['MinLogLevel', 'Livello minimo del registro', L, 'Le righe meno importanti di questo livello non si registrano', [['Debug', 'Tutto (debug)'], ['Normal', 'Normale'], ['Warning', 'Solo avvisi'], ['Error', 'Solo errori']]],
|
||||
['MaxLogLinesPerAuction', 'Righe di registro per asta', I, 'Quante righe tiene il registro di ogni asta'],
|
||||
['MaxGlobalLogLines', 'Righe del registro generale', I, 'Quante righe tiene il registro generale nell\'interfaccia'],
|
||||
['DarkMode', 'Tema scuro', B, 'Predefinito; ogni browser ricorda anche il suo'],
|
||||
['DarkMode', 'Tema scuro', B, 'Al salvataggio vale per questo browser; un browser che non ha ancora scelto segue il tema del sistema'],
|
||||
['NavCollapsed', 'Menu compresso', B, 'Predefinito; ogni browser ricorda anche il suo']
|
||||
] }
|
||||
];
|
||||
|
||||
@@ -12,8 +12,14 @@ import { store } from './util.js';
|
||||
/** La stessa soglia di @media (max-width: 1100px) in app.css. */
|
||||
const drawerQuery = window.matchMedia('(max-width: 1100px)');
|
||||
|
||||
/** La maniglia fra elenco e pannello (colonna di 6 px in .split). */
|
||||
const handlePx = 6;
|
||||
/** La maniglia fra elenco e pannello (colonna di 14 px in .split). */
|
||||
const handlePx = 14;
|
||||
|
||||
/** I margini interni di .split a sinistra e a destra (lo spazio fra i riquadri e il bordo della pagina). */
|
||||
const padding = el => {
|
||||
const s = getComputedStyle(el);
|
||||
return { left: parseFloat(s.paddingLeft) || 0, right: parseFloat(s.paddingRight) || 0 };
|
||||
};
|
||||
|
||||
/**
|
||||
* Maniglia verticale fra elenco e pannello. splitEl è il contenitore .split, handle la
|
||||
@@ -30,7 +36,8 @@ export function verticalSplit(splitEl, handle, key, { min = 320, def = 400, minL
|
||||
|
||||
/** min(max(min, w), max(min, contenitore − minList − maniglia)); nel cassetto solo il minimo. */
|
||||
const clamp = w => {
|
||||
const avail = drawerQuery.matches ? 0 : splitEl.clientWidth;
|
||||
const pad = padding(splitEl);
|
||||
const avail = drawerQuery.matches ? 0 : splitEl.clientWidth - pad.left - pad.right;
|
||||
const max = avail > 0 ? Math.max(min, avail - listMin() - handlePx) : Infinity;
|
||||
return Math.round(Math.min(max, Math.max(min, w)));
|
||||
};
|
||||
@@ -71,7 +78,7 @@ export function verticalSplit(splitEl, handle, key, { min = 320, def = 400, minL
|
||||
e.preventDefault();
|
||||
handle.setPointerCapture(e.pointerId);
|
||||
document.body.classList.add('dragging');
|
||||
const right = splitEl.getBoundingClientRect().right;
|
||||
const right = splitEl.getBoundingClientRect().right - padding(splitEl).right;
|
||||
const move = ev => {
|
||||
width = clamp(right - ev.clientX);
|
||||
apply(width);
|
||||
|
||||
@@ -108,7 +108,7 @@ conn.on('event', m => {
|
||||
publish('log', m);
|
||||
});
|
||||
|
||||
for (const t of ['auction.detail', 'learning', 'login.frame', 'login.state', 'progress', 'maintenance']) {
|
||||
for (const t of ['auction.detail', 'learning', 'progress', 'maintenance']) {
|
||||
conn.on(t, m => publish(t, m));
|
||||
}
|
||||
|
||||
|
||||
@@ -279,6 +279,31 @@ public class ArchiveDownloaderTests(DatabaseFixture fx)
|
||||
Assert.True((bool)(await none.ExecuteScalarAsync())!);
|
||||
}
|
||||
|
||||
[DbFact]
|
||||
public async Task Il_backup_notturno_delle_impostazioni_non_contiene_il_token_di_telegram()
|
||||
{
|
||||
var db = fx.Db!;
|
||||
await db.ExecuteAsync("INSERT INTO settings(id, value) VALUES (1, '{\"TelegramBotToken\": \"123:segreto\", \"TelegramChatId\": \"42\", \"MaxBids\": 5}') " +
|
||||
"ON CONFLICT (id) DO UPDATE SET value = excluded.value");
|
||||
var file = Path.Combine(Path.GetTempPath(), "mimante-backup-" + Guid.NewGuid().ToString("N") + ".csv");
|
||||
try
|
||||
{
|
||||
await using (var conn = await db.Writer.OpenConnectionAsync())
|
||||
await BulkCopy.ToFileAsync(conn, Maintenance.BackupCopySql("settings"), file);
|
||||
var text = await File.ReadAllTextAsync(file);
|
||||
Assert.StartsWith("id,value,updated_at", text);
|
||||
Assert.DoesNotContain("segreto", text);
|
||||
Assert.DoesNotContain("TelegramBotToken", text);
|
||||
Assert.Contains("MaxBids", text);
|
||||
Assert.Contains("TelegramChatId", text);
|
||||
}
|
||||
finally
|
||||
{
|
||||
File.Delete(file);
|
||||
}
|
||||
Assert.Equal("COPY bids TO STDOUT (FORMAT csv, HEADER)", Maintenance.BackupCopySql("bids"));
|
||||
}
|
||||
|
||||
[DbFact]
|
||||
public async Task La_connessione_dello_strumento_non_puo_scrivere()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,183 @@
|
||||
using System.Globalization;
|
||||
using System.Text.RegularExpressions;
|
||||
using Xunit;
|
||||
|
||||
namespace Mimante.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// I colori dell'interfaccia (ADR 0016): stanno tutti in <c>wwwroot/css/tokens.css</c>, ogni token usato esiste, e
|
||||
/// le coppie testo/fondo si leggono nei due temi (WCAG AA: 4,5:1 per il testo, 3:1 per i segni senza testo).
|
||||
/// </summary>
|
||||
public sealed partial class ContrastTests
|
||||
{
|
||||
private static readonly string Root = FindRoot();
|
||||
private static readonly string WebRoot = Path.Combine(Root, "src", "Mimante", "wwwroot");
|
||||
private static readonly Dictionary<string, (Rgb Light, Rgb Dark)> Tokens = ReadTokens();
|
||||
|
||||
/// <summary>Testo sul suo fondo: il testo di ogni livello su ogni superficie e ogni stato sul suo fondo tenue.</summary>
|
||||
public static TheoryData<string, string> TextPairs() => new()
|
||||
{
|
||||
{ "text", "bg" }, { "text", "surface" }, { "text", "surface-2" }, { "text", "surface-3" }, { "text", "hover" },
|
||||
{ "text", "accent-soft" },
|
||||
{ "muted", "bg" }, { "muted", "surface" }, { "muted", "surface-2" }, { "muted", "surface-3" }, { "muted", "hover" },
|
||||
{ "muted", "muted-soft" }, { "muted", "accent-soft" },
|
||||
{ "faint", "bg" }, { "faint", "surface" }, { "faint", "surface-2" }, { "faint", "surface-3" }, { "faint", "muted-soft" },
|
||||
{ "accent-ink", "accent" }, { "bad-ink", "bad" },
|
||||
{ "accent-text", "surface" }, { "accent-text", "accent-soft" }, { "accent-text", "surface-3" },
|
||||
{ "ok-text", "surface" }, { "ok-text", "ok-soft" },
|
||||
{ "warn-text", "surface" }, { "warn-text", "warn-soft" },
|
||||
{ "bad-text", "surface" }, { "bad-text", "bad-soft" },
|
||||
{ "gold-text", "surface" }, { "gold-text", "gold-soft" }
|
||||
};
|
||||
|
||||
/// <summary>Segni senza testo che portano significato: la stella accesa, i punti, le barre, il bordo attivo.</summary>
|
||||
public static TheoryData<string, string> MarkPairs() => new()
|
||||
{
|
||||
{ "accent", "surface" }, { "ok", "surface" }, { "bad", "surface" }, { "gold", "surface" }
|
||||
};
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(TextPairs))]
|
||||
public void TextIsReadableInBothThemes(string fore, string back)
|
||||
{
|
||||
AssertContrast(fore, back, 4.5);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(MarkPairs))]
|
||||
public void MarksAreVisibleInBothThemes(string fore, string back)
|
||||
{
|
||||
AssertContrast(fore, back, 3.0);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ThemeFollowsTheSystemUnlessChosen()
|
||||
{
|
||||
var css = File.ReadAllText(Path.Combine(WebRoot, "css", "tokens.css"));
|
||||
Assert.Matches(@":root\[data-theme=""auto""\]\s*\{\s*color-scheme:\s*light dark;", css);
|
||||
Assert.Matches(@":root\[data-theme=""light""\]\s*\{\s*color-scheme:\s*light;", css);
|
||||
Assert.Matches(@":root\[data-theme=""dark""\]\s*\{\s*color-scheme:\s*dark;", css);
|
||||
Assert.Contains("data-theme=\"auto\"", File.ReadAllText(Path.Combine(WebRoot, "index.html")));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NoColourOutsideTheTokens()
|
||||
{
|
||||
var offenders = new List<string>();
|
||||
foreach (var file in Directory.EnumerateFiles(Path.Combine(WebRoot, "css"), "*.css"))
|
||||
{
|
||||
if (Path.GetFileName(file) == "tokens.css") continue;
|
||||
var lines = File.ReadAllLines(file);
|
||||
for (var i = 0; i < lines.Length; i++)
|
||||
{
|
||||
var code = CommentRegex().Replace(lines[i], "");
|
||||
if (ColourRegex().IsMatch(code)) offenders.Add($"{Path.GetFileName(file)}:{i + 1}: {lines[i].Trim()}");
|
||||
}
|
||||
}
|
||||
Assert.True(offenders.Count == 0, "Colori scritti fuori da tokens.css:\n" + string.Join('\n', offenders));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EveryTokenUsedExists()
|
||||
{
|
||||
var defined = new HashSet<string>(StringComparer.Ordinal);
|
||||
var css = File.ReadAllText(Path.Combine(WebRoot, "css", "tokens.css"));
|
||||
foreach (Match m in DefinitionRegex().Matches(css)) defined.Add(m.Groups[1].Value);
|
||||
defined.Add("panel-w"); // la larghezza del pannello, scritta da split.js
|
||||
|
||||
var missing = new SortedSet<string>(StringComparer.Ordinal);
|
||||
foreach (var file in Directory.EnumerateFiles(WebRoot, "*.*", SearchOption.AllDirectories)
|
||||
.Where(f => f.EndsWith(".css", StringComparison.Ordinal) || f.EndsWith(".js", StringComparison.Ordinal)))
|
||||
{
|
||||
foreach (Match m in UseRegex().Matches(File.ReadAllText(file)))
|
||||
if (!defined.Contains(m.Groups[1].Value)) missing.Add($"--{m.Groups[1].Value} ({Path.GetFileName(file)})");
|
||||
}
|
||||
Assert.True(missing.Count == 0, "Token usati ma non definiti in tokens.css:\n" + string.Join('\n', missing));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FontsAreLocal()
|
||||
{
|
||||
var css = File.ReadAllText(Path.Combine(WebRoot, "css", "tokens.css"));
|
||||
foreach (Match m in Regex.Matches(css, @"url\(([^)]+)\)"))
|
||||
{
|
||||
var rel = m.Groups[1].Value.Trim('"', '\'');
|
||||
Assert.DoesNotContain("://", rel);
|
||||
Assert.True(File.Exists(Path.GetFullPath(Path.Combine(WebRoot, "css", rel))), "Carattere mancante: " + rel);
|
||||
}
|
||||
Assert.True(File.Exists(Path.Combine(WebRoot, "fonts", "Archivo-OFL.txt")), "Manca la licenza del carattere");
|
||||
}
|
||||
|
||||
private static void AssertContrast(string fore, string back, double min)
|
||||
{
|
||||
Assert.True(Tokens.ContainsKey(fore), "Token mancante: --" + fore);
|
||||
Assert.True(Tokens.ContainsKey(back), "Token mancante: --" + back);
|
||||
var light = Ratio(Tokens[fore].Light, Tokens[back].Light);
|
||||
var dark = Ratio(Tokens[fore].Dark, Tokens[back].Dark);
|
||||
Assert.True(light >= min, $"--{fore} su --{back}, tema chiaro: {light:F2}:1 (serve {min}:1)");
|
||||
Assert.True(dark >= min, $"--{fore} su --{back}, tema scuro: {dark:F2}:1 (serve {min}:1)");
|
||||
}
|
||||
|
||||
internal static double Ratio(Rgb a, Rgb b)
|
||||
{
|
||||
var la = a.Luminance;
|
||||
var lb = b.Luminance;
|
||||
return (Math.Max(la, lb) + 0.05) / (Math.Min(la, lb) + 0.05);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RatioMatchesTheWcagExamples()
|
||||
{
|
||||
Assert.Equal(21.0, Ratio(Rgb.Parse("#000000"), Rgb.Parse("#FFFFFF")), 2);
|
||||
Assert.Equal(1.0, Ratio(Rgb.Parse("#777777"), Rgb.Parse("#777777")), 2);
|
||||
Assert.Equal(4.48, Ratio(Rgb.Parse("#777777"), Rgb.Parse("#FFFFFF")), 2);
|
||||
}
|
||||
|
||||
private static Dictionary<string, (Rgb, Rgb)> ReadTokens()
|
||||
{
|
||||
var css = File.ReadAllText(Path.Combine(WebRoot, "css", "tokens.css"));
|
||||
var map = new Dictionary<string, (Rgb, Rgb)>(StringComparer.Ordinal);
|
||||
foreach (Match m in PairRegex().Matches(css)) map[m.Groups[1].Value] = (Rgb.Parse(m.Groups[2].Value), Rgb.Parse(m.Groups[3].Value));
|
||||
foreach (Match m in SingleRegex().Matches(css)) map.TryAdd(m.Groups[1].Value, (Rgb.Parse(m.Groups[2].Value), Rgb.Parse(m.Groups[2].Value)));
|
||||
return map;
|
||||
}
|
||||
|
||||
private static string FindRoot()
|
||||
{
|
||||
for (var d = new DirectoryInfo(AppContext.BaseDirectory); d != null; d = d.Parent)
|
||||
if (File.Exists(Path.Combine(d.FullName, "Mimante.slnx"))) return d.FullName;
|
||||
throw new InvalidOperationException("Mimante.slnx not found above " + AppContext.BaseDirectory);
|
||||
}
|
||||
|
||||
internal readonly record struct Rgb(double R, double G, double B)
|
||||
{
|
||||
public static Rgb Parse(string hex)
|
||||
{
|
||||
var h = hex.TrimStart('#');
|
||||
double C(int i) => int.Parse(h.AsSpan(i, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture) / 255.0;
|
||||
return new Rgb(C(0), C(2), C(4));
|
||||
}
|
||||
|
||||
public double Luminance => 0.2126 * Lin(R) + 0.7152 * Lin(G) + 0.0722 * Lin(B);
|
||||
|
||||
private static double Lin(double c) => c <= 0.04045 ? c / 12.92 : Math.Pow((c + 0.055) / 1.055, 2.4);
|
||||
}
|
||||
|
||||
[GeneratedRegex(@"--([a-z0-9-]+):\s*light-dark\(\s*(#[0-9A-Fa-f]{6})\s*,\s*(#[0-9A-Fa-f]{6})\s*\)")]
|
||||
private static partial Regex PairRegex();
|
||||
|
||||
[GeneratedRegex(@"--([a-z0-9-]+):\s*(#[0-9A-Fa-f]{6})\s*;")]
|
||||
private static partial Regex SingleRegex();
|
||||
|
||||
[GeneratedRegex(@"(?<![\w-])--([a-z0-9-]+)\s*:")]
|
||||
private static partial Regex DefinitionRegex();
|
||||
|
||||
[GeneratedRegex(@"var\(--([a-z0-9-]+)")]
|
||||
private static partial Regex UseRegex();
|
||||
|
||||
[GeneratedRegex(@"#[0-9A-Fa-f]{3,8}\b|\brgba?\(|\bhsla?\(|\blight-dark\(|:\s*(white|black)\b")]
|
||||
private static partial Regex ColourRegex();
|
||||
|
||||
[GeneratedRegex(@"/\*.*?\*/")]
|
||||
private static partial Regex CommentRegex();
|
||||
}
|
||||
@@ -207,7 +207,7 @@ public class MonitorAgainstSimulatorTests
|
||||
Assert.True(done.LastDecision!.Shadow);
|
||||
var (ok, why) = await rig.Monitor.BidNowAsync(target.Id, CancellationToken.None);
|
||||
Assert.False(ok);
|
||||
Assert.Contains("Browser", why);
|
||||
Assert.Contains("Accesso a Bidoo", why);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Channels;
|
||||
using Mimante.Bidoo;
|
||||
using Mimante.Config;
|
||||
using Mimante.Data;
|
||||
@@ -8,7 +7,6 @@ using Mimante.Logging;
|
||||
using Mimante.Ml;
|
||||
using Mimante.Net;
|
||||
using Mimante.Session;
|
||||
using Mimante.Session.Cdp;
|
||||
using Mimante.Settings;
|
||||
using Mimante.Simulator;
|
||||
using Mimante.Telegram;
|
||||
@@ -71,106 +69,134 @@ public class SessionStoreTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void I_cookie_incollati_si_normalizzano_e_serve_quello_di_sessione()
|
||||
public void Il_profilo_del_browser_della_1x_si_cancella_all_avvio()
|
||||
{
|
||||
Assert.Equal("__stattrb=1; a=2", SessionStore.NormalizePastedCookie("Cookie: __stattrb=1; a=2\r\n").Cookie);
|
||||
Assert.Contains("__stattrb", SessionStore.NormalizePastedCookie("PHPSESSID=9").Error);
|
||||
Assert.NotNull(SessionStore.NormalizePastedCookie(" ").Error);
|
||||
using var dir = new TempDir();
|
||||
var paths = new ConfigPaths(dir.Path);
|
||||
Assert.False(paths.RemoveOldBrowserProfile());
|
||||
Directory.CreateDirectory(Path.Combine(paths.OldBrowserProfile, "Default"));
|
||||
File.WriteAllText(Path.Combine(paths.OldBrowserProfile, "Default", "Cookies"), "x");
|
||||
Assert.True(paths.RemoveOldBrowserProfile());
|
||||
Assert.False(Directory.Exists(paths.OldBrowserProfile));
|
||||
paths.EnsureAll();
|
||||
Assert.False(Directory.Exists(paths.OldBrowserProfile));
|
||||
}
|
||||
}
|
||||
|
||||
public class CdpClientTests
|
||||
/// <summary>La sessione incollata (ADR 0017): ogni modo in cui Chrome la lascia copiare.</summary>
|
||||
public class SessionPasteTests
|
||||
{
|
||||
private sealed class FakeTransport : ICdpTransport
|
||||
private const string Ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36";
|
||||
|
||||
[Fact]
|
||||
public void Copy_as_cURL_per_bash_con_i_cookie_in_b()
|
||||
{
|
||||
private readonly Channel<string> _incoming = Channel.CreateUnbounded<string>();
|
||||
public List<JsonElement> Sent { get; } = new();
|
||||
public Func<JsonElement, string?>? Reply { get; set; }
|
||||
|
||||
public Task SendAsync(string json, CancellationToken ct)
|
||||
{
|
||||
var msg = JsonDocument.Parse(json).RootElement.Clone();
|
||||
lock (Sent) Sent.Add(msg);
|
||||
if (Reply?.Invoke(msg) is { } answer) Push(answer);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public async Task<string?> ReceiveAsync(CancellationToken ct)
|
||||
{
|
||||
try { return await _incoming.Reader.ReadAsync(ct); }
|
||||
catch (ChannelClosedException) { return null; }
|
||||
}
|
||||
|
||||
public void Push(string json) => _incoming.Writer.TryWrite(json);
|
||||
public void Close() => _incoming.Writer.TryComplete();
|
||||
public ValueTask DisposeAsync() { Close(); return ValueTask.CompletedTask; }
|
||||
var text = $"""
|
||||
curl 'https://it.bidoo.com/' \
|
||||
-H 'accept: text/html,application/xhtml+xml' \
|
||||
-H 'accept-language: it-IT,it;q=0.9' \
|
||||
-b '__stattrb=AbC123%3D%3D; PHPSESSID=s3ss10n; _ga=GA1.2.3' \
|
||||
-H 'priority: u=0, i' \
|
||||
-H 'user-agent: {Ua}'
|
||||
""";
|
||||
var p = SessionPaste.Parse(text);
|
||||
Assert.Null(p.Error);
|
||||
Assert.Equal("__stattrb=AbC123%3D%3D; PHPSESSID=s3ss10n; _ga=GA1.2.3", p.Cookie);
|
||||
Assert.Equal(Ua, p.UserAgent);
|
||||
Assert.Equal("cURL", p.Format);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Le_risposte_si_abbinano_per_id_e_gli_errori_diventano_eccezioni()
|
||||
public void Copy_as_cURL_con_l_intestazione_cookie_e_le_virgolette_ansi()
|
||||
{
|
||||
var t = new FakeTransport
|
||||
{
|
||||
Reply = m => m.GetProperty("method").GetString() == "Boom"
|
||||
? JsonSerializer.Serialize(new { id = m.GetProperty("id").GetInt32(), error = new { code = -32000, message = "non va" } })
|
||||
: JsonSerializer.Serialize(new { id = m.GetProperty("id").GetInt32(), result = new { echo = m.GetProperty("method").GetString() } })
|
||||
};
|
||||
await using var cdp = new CdpClient(t);
|
||||
|
||||
var a = cdp.SendAsync("Page.enable", sessionId: "S1");
|
||||
var b = cdp.SendAsync("Target.createTarget", new { url = "about:blank" });
|
||||
Assert.Equal("Page.enable", (await a).GetProperty("echo").GetString());
|
||||
Assert.Equal("Target.createTarget", (await b).GetProperty("echo").GetString());
|
||||
|
||||
var sent = t.Sent.First(x => x.GetProperty("method").GetString() == "Page.enable");
|
||||
Assert.Equal("S1", sent.GetProperty("sessionId").GetString());
|
||||
Assert.Equal("about:blank", t.Sent.First(x => x.GetProperty("method").GetString() == "Target.createTarget").GetProperty("params").GetProperty("url").GetString());
|
||||
|
||||
var ex = await Assert.ThrowsAsync<CdpException>(() => cdp.SendAsync("Boom"));
|
||||
Assert.Contains("non va", ex.Message);
|
||||
var text = "curl 'https://it.bidoo.com/data.php' -H 'Cookie: __stattrb=x1; PHPSESSID=y2' -b $'nota=l\\'altra' -A 'UA di prova' --compressed";
|
||||
var p = SessionPaste.Parse(text);
|
||||
Assert.Equal("__stattrb=x1; PHPSESSID=y2; nota=l'altra", p.Cookie);
|
||||
Assert.Equal("UA di prova", p.UserAgent);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Gli_eventi_portano_la_sessione_e_la_chiusura_sblocca_le_attese()
|
||||
public void Copy_as_cURL_per_cmd_con_gli_accenti_circonflessi()
|
||||
{
|
||||
var t = new FakeTransport();
|
||||
await using var cdp = new CdpClient(t);
|
||||
var got = new TaskCompletionSource<(string, string?, string?)>();
|
||||
cdp.Event += (m, p, s) => got.TrySetResult((m, s, p.GetProperty("url").GetString()));
|
||||
|
||||
t.Push("""{"method":"Page.frameNavigated","params":{"url":"https://it.bidoo.com/"},"sessionId":"S9"}""");
|
||||
var (method, session, url) = await got.Task.WaitAsync(TimeSpan.FromSeconds(5));
|
||||
Assert.Equal("Page.frameNavigated", method);
|
||||
Assert.Equal("S9", session);
|
||||
Assert.Equal("https://it.bidoo.com/", url);
|
||||
|
||||
var pending = cdp.SendAsync("Network.getCookies");
|
||||
t.Close();
|
||||
await Assert.ThrowsAsync<CdpException>(() => pending);
|
||||
Assert.True(cdp.IsClosed);
|
||||
var text = "curl ^\"https://it.bidoo.com/^\" ^\r\n" +
|
||||
" -H ^\"accept: text/html^\" ^\r\n" +
|
||||
" -b ^\"__stattrb=AbC123^%^3D; PHPSESSID=s3ss10n^\" ^\r\n" +
|
||||
" -H ^\"user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)^\"";
|
||||
var p = SessionPaste.Parse(text);
|
||||
Assert.Null(p.Error);
|
||||
Assert.Equal("__stattrb=AbC123%3D; PHPSESSID=s3ss10n", p.Cookie);
|
||||
Assert.Equal("Mozilla/5.0 (Windows NT 10.0; Win64; x64)", p.UserAgent);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Il_login_si_riconosce_anche_come_finestra_sulla_home()
|
||||
public void Copy_as_PowerShell()
|
||||
{
|
||||
var refs = BidooReferences.Default;
|
||||
Assert.True(AssistedLogin.IsLoginUrl("https://it.bidoo.com/login.php", refs));
|
||||
Assert.True(AssistedLogin.IsLoginUrl("https://it.bidoo.com/?login=true&redirect=index.php", refs));
|
||||
Assert.True(AssistedLogin.IsLoginUrl("", refs));
|
||||
Assert.False(AssistedLogin.IsLoginUrl("https://it.bidoo.com/index.php", refs));
|
||||
var text = """
|
||||
$session = New-Object Microsoft.PowerShell.Commands.WebRequestSession
|
||||
$session.UserAgent = "Mozilla/5.0 (Windows NT 10.0)"
|
||||
$session.Cookies.Add((New-Object System.Net.Cookie("__stattrb", "AbC123%3D%3D", "/", ".bidoo.com")))
|
||||
$session.Cookies.Add((New-Object System.Net.Cookie("PHPSESSID", "s3ss10n", "/", "it.bidoo.com")))
|
||||
Invoke-WebRequest -UseBasicParsing -Uri "https://it.bidoo.com/" `
|
||||
-WebSession $session
|
||||
""";
|
||||
var p = SessionPaste.Parse(text);
|
||||
Assert.Equal("__stattrb=AbC123%3D%3D; PHPSESSID=s3ss10n", p.Cookie);
|
||||
Assert.Equal("Mozilla/5.0 (Windows NT 10.0)", p.UserAgent);
|
||||
Assert.Equal("PowerShell", p.Format);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DevToolsActivePort_da_l_indirizzo_del_browser()
|
||||
public void Le_intestazioni_della_richiesta_in_riga_o_con_il_valore_sotto_il_nome()
|
||||
{
|
||||
using var dir = new TempDir();
|
||||
var file = Path.Combine(dir.Path, "DevToolsActivePort");
|
||||
File.WriteAllText(file, "41233\n/devtools/browser/abc-123\n");
|
||||
Assert.Equal("ws://127.0.0.1:41233/devtools/browser/abc-123", ChromiumProcess.TryReadPort(file)!.ToString());
|
||||
File.WriteAllText(file, "x\n");
|
||||
Assert.Null(ChromiumProcess.TryReadPort(file));
|
||||
Assert.Contains("--headless=new", ChromiumProcess.Arguments("/config/browser"));
|
||||
Assert.Contains("--user-data-dir=/config/browser", ChromiumProcess.Arguments("/config/browser"));
|
||||
var raw = SessionPaste.Parse("GET / HTTP/1.1\r\nHost: it.bidoo.com\r\nCookie: __stattrb=AbC; PHPSESSID=s\r\nUser-Agent: Mozilla/5.0 X\r\n");
|
||||
Assert.Equal("__stattrb=AbC; PHPSESSID=s", raw.Cookie);
|
||||
Assert.Equal("Mozilla/5.0 X", raw.UserAgent);
|
||||
|
||||
var panel = SessionPaste.Parse(":authority\nit.bidoo.com\naccept-language\nit-IT,it;q=0.9\ncookie\n__stattrb=AbC; PHPSESSID=s\nuser-agent:\nMozilla/5.0 Y\n");
|
||||
Assert.Equal("__stattrb=AbC; PHPSESSID=s", panel.Cookie);
|
||||
Assert.Equal("Mozilla/5.0 Y", panel.UserAgent);
|
||||
Assert.Equal("intestazioni", panel.Format);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void La_riga_cookie_da_sola_con_o_senza_prefisso()
|
||||
{
|
||||
Assert.Equal("__stattrb=1; a=2", SessionPaste.Parse("Cookie: __stattrb=1; a=2\r\n").Cookie);
|
||||
var line = SessionPaste.Parse("__stattrb=1; a=2");
|
||||
Assert.Equal("__stattrb=1; a=2", line.Cookie);
|
||||
Assert.Null(line.UserAgent);
|
||||
Assert.Equal("riga Cookie", line.Format);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Le_righe_della_tabella_dei_cookie_e_il_solo_valore()
|
||||
{
|
||||
var table = SessionPaste.Parse("__stattrb\tAbC123\tit.bidoo.com\t/\t2027-01-01T00:00:00.000Z\t15\t✓\n" +
|
||||
"PHPSESSID\ts3ss10n\tit.bidoo.com\t/\tSessione\t17\t✓");
|
||||
Assert.Equal("__stattrb=AbC123; PHPSESSID=s3ss10n", table.Cookie);
|
||||
|
||||
Assert.Equal("__stattrb=AbC123%3D%3D", SessionPaste.Parse(" AbC123%3D%3D \n").Cookie);
|
||||
Assert.Equal("__stattrb=QWxhZGRpbjpvcGVu==", SessionPaste.Parse("QWxhZGRpbjpvcGVu==").Cookie);
|
||||
Assert.Equal("__sess=v", SessionPaste.Parse("v", "__sess").Cookie);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Senza_il_cookie_di_accesso_la_sessione_non_si_accetta()
|
||||
{
|
||||
Assert.Contains("__stattrb", SessionPaste.Parse("PHPSESSID=9").Error);
|
||||
Assert.Contains("__stattrb", SessionPaste.Parse("__stattrb=; PHPSESSID=9").Error);
|
||||
Assert.Contains("__stattrb", SessionPaste.Parse("curl 'https://it.bidoo.com/' -b 'PHPSESSID=9' -H 'user-agent: X'").Error);
|
||||
Assert.NotNull(SessionPaste.Parse("curl 'https://it.bidoo.com/' -H 'accept: */*'").Error);
|
||||
Assert.NotNull(SessionPaste.Parse("ciao, come stai?").Error);
|
||||
Assert.NotNull(SessionPaste.Parse(" ").Error);
|
||||
Assert.NotNull(SessionPaste.Parse(null).Error);
|
||||
Assert.Null(SessionPaste.Parse("PHPSESSID=9").Cookie);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Le_parole_della_riga_di_comando()
|
||||
{
|
||||
Assert.Equal(new[] { "curl", "a b", "c\"d", "e'f", "g\nh", "ij" }, SessionPaste.ShellWords("curl 'a b' \"c\\\"d\" $'e\\'f' $'g\\nh' i\\\n\\j"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Nodes;
|
||||
|
||||
namespace Mimante.Session.Cdp;
|
||||
namespace Mimante.Schermate.Cdp;
|
||||
|
||||
/// <summary>Un errore restituito da Chromium a un comando CDP.</summary>
|
||||
public sealed class CdpException(string method, string message) : Exception($"{method}: {message}");
|
||||
@@ -19,7 +19,7 @@ public interface ICdpTransport : IAsyncDisposable
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Client del Chrome DevTools Protocol scritto a mano (specifica §6.5): JSON-RPC su
|
||||
/// Client del Chrome DevTools Protocol scritto a mano, per le schermate: JSON-RPC su
|
||||
/// WebSocket, <c>id</c> incrementale, mappa delle risposte in attesa, eventi con
|
||||
/// <c>sessionId</c> (sessioni piatte, <c>Target.attachToTarget</c> con <c>flatten: true</c>).
|
||||
/// Niente Playwright: servono una decina di comandi.
|
||||
+6
-6
@@ -1,12 +1,12 @@
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Mimante.Session.Cdp;
|
||||
namespace Mimante.Schermate.Cdp;
|
||||
|
||||
/// <summary>
|
||||
/// Chromium senza finestra per l'accesso assistito (specifica §6.5). Il profilo sta in
|
||||
/// <c>/config/browser</c> e resta fra un accesso e l'altro; l'indirizzo del protocollo si
|
||||
/// legge da <c>DevToolsActivePort</c> (porta scelta dal browser: nessun conflitto).
|
||||
/// Chromium senza finestra per le schermate. Il bot non ha più un browser (ADR 0017): Chrome, Edge o
|
||||
/// Chromium sono quelli del PC o del lavoro della CI. L'indirizzo del protocollo si legge da
|
||||
/// <c>DevToolsActivePort</c> (porta scelta dal browser: nessun conflitto).
|
||||
/// </summary>
|
||||
public sealed class ChromiumProcess : IAsyncDisposable
|
||||
{
|
||||
@@ -22,7 +22,7 @@ public sealed class ChromiumProcess : IAsyncDisposable
|
||||
|
||||
public bool HasExited => _process.HasExited;
|
||||
|
||||
/// <summary>Dove cercare il browser: l'immagine Docker ha <c>/usr/bin/chromium</c>; in sviluppo Chrome o Edge.</summary>
|
||||
/// <summary>Dove cercare il browser: su Linux il pacchetto della distribuzione, su Windows Chrome o Edge.</summary>
|
||||
public static IEnumerable<string> Candidates()
|
||||
{
|
||||
yield return "/usr/bin/chromium";
|
||||
@@ -54,7 +54,7 @@ public sealed class ChromiumProcess : IAsyncDisposable
|
||||
|
||||
public static async Task<ChromiumProcess> StartAsync(string profileDir, CancellationToken ct)
|
||||
{
|
||||
var exe = FindExecutable() ?? throw new InvalidOperationException("Chromium non trovato nell'immagine: usa «incolla i cookie»");
|
||||
var exe = FindExecutable() ?? throw new InvalidOperationException("Chrome, Edge o Chromium non trovato su questo computer");
|
||||
Directory.CreateDirectory(profileDir);
|
||||
var portFile = Path.Combine(profileDir, "DevToolsActivePort");
|
||||
try { if (File.Exists(portFile)) File.Delete(portFile); } catch (IOException) { }
|
||||
@@ -1,8 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<!--
|
||||
Schermate del README e controllo dell'interfaccia: pilota Chromium con il client CDP del
|
||||
bot (nessun pacchetto in più), fotografa ogni pagina e segnala gli errori JavaScript.
|
||||
Schermate del README e controllo dell'interfaccia: pilota Chrome, Edge o Chromium del PC con
|
||||
un client CDP scritto qui (Cdp/, nessun pacchetto in più), fotografa ogni pagina e segnala gli
|
||||
errori JavaScript. Il bot non ha più un browser (ADR 0017): il client vive solo qui.
|
||||
-->
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System.Text.Json;
|
||||
using Mimante.Session.Cdp;
|
||||
using Mimante.Schermate.Cdp;
|
||||
|
||||
// Uso: dotnet run --project tools/Mimante.Schermate -- <indirizzo> <password dell'interfaccia> <cartella>
|
||||
// Esempio: dotnet run --project tools/Mimante.Schermate -- http://localhost:8080 dev docs/schermate
|
||||
@@ -146,23 +146,8 @@ else
|
||||
await Shot("14-aste-puntate", "#/aste", "document.querySelector('.panel .tabs button[data-tab=puntate]')?.click()", 500);
|
||||
await Eval("document.querySelector('.panel .tabs button[data-tab=auto]')?.click()");
|
||||
await Shot("02-apprendimento", "#/apprendimento", null, 3500);
|
||||
await Shot("03-browser", "#/browser");
|
||||
if (args.Contains("--accesso-assistito"))
|
||||
{
|
||||
// Apre il browser del bot (Chromium dentro il bot) e aspetta il primo fotogramma.
|
||||
await Eval("document.querySelector('.browser .idle button')?.click()");
|
||||
var frame = false;
|
||||
for (var i = 0; i < 40 && !frame; i++)
|
||||
{
|
||||
await Task.Delay(500, ct);
|
||||
frame = (await Eval("!document.querySelector('.browser canvas').hidden")).ValueKind == JsonValueKind.True;
|
||||
}
|
||||
await Task.Delay(2500, ct);
|
||||
await Shot("03-browser", "#/browser", null, 200);
|
||||
Console.WriteLine(frame ? "Browser del bot: fotogrammi ricevuti" : "Browser del bot: nessun fotogramma");
|
||||
if (!frame) errors.Add("accesso assistito: nessun fotogramma dal browser del bot");
|
||||
await Eval("document.querySelector('.browser .url button[title^=\"Chiudi\"]')?.click()");
|
||||
}
|
||||
// La pagina d'accesso con un testo incollato a mano (non si invia): mostra il riquadro pieno.
|
||||
await Shot("03-accesso", "#/accesso", "document.querySelector('textarea.paste').value = \"curl 'https://it.bidoo.com/' -b '__stattrb=…; PHPSESSID=…' -H 'user-agent: …'\"", 500);
|
||||
if (args.Contains("--messaggio"))
|
||||
{
|
||||
// Il messaggio a schermo per un'informazione importante: senza token Telegram il
|
||||
|
||||
Reference in new issue
Block a user