Skip to content

Commit e6dd366

Browse files
committed
bumps
1 parent 29cfec0 commit e6dd366

2 files changed

Lines changed: 117 additions & 40 deletions

File tree

god-mode-console/CodeCorn_GodMode.user.js

Lines changed: 64 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// ==UserScript==
2-
// @name CodeCorn Console Capture (God Mode v4.17.2 - Stealth Trap & SW Blueprint)
2+
// @name CodeCorn Console Capture (God Mode v4.17.3 - Stealth Trap & SW Blueprint)
33
// @namespace https://codecorn.it/
4-
// @version 4.17.2
4+
// @version 4.17.3
55
// @description Log, Spy, Power Tools, Global Settings & Inspector! Fully Typed, Trusted Types Compliant.
66
// @match *://*/*
77
// @run-at document-start
@@ -13,7 +13,7 @@
1313
// ==/UserScript==
1414

1515
// --- AMBIENT DECLARATIONS PER VS CODE ---
16-
/* global html2canvas, GM_getValue, GM_setValue, GM_setClipboard, GM_info, unsafeWindow */
16+
/* global html2canvas */
1717
/* @ts-ignore */
1818
const _GM_getValue = typeof GM_getValue !== 'undefined' ? GM_getValue : null;
1919
/* @ts-ignore */
@@ -34,8 +34,11 @@ const _html2canvas = typeof html2canvas !== 'undefined' ? html2canvas : null;
3434

3535
(() => {
3636
'use strict';
37-
38-
if (window.location.hostname.includes('chatgpt.com')) return;
37+
const { hostname } = window.location || {};
38+
if (['chatgpt.com', 'youtube.com', 'youtube.it', 'music.youtube.com', 'music.youtube.it'].includes(hostname)) {
39+
ccLog(`Skipped CCCG: ${hostname}`);
40+
return;
41+
}
3942

4043
// --- 0. PRESET DI ESCLUSIONE (SMART HARDENING) ---
4144
/** @type {Object<string, ExclusionPreset>} */
@@ -170,12 +173,52 @@ const _html2canvas = typeof html2canvas !== 'undefined' ? html2canvas : null;
170173
}
171174
}
172175

176+
let quotaWarningShown = false;
177+
173178
/** @param {Array<Object>} logs */
174179
function saveHistoryLogs(logs) {
175-
try {
176-
targetWindow.localStorage.setItem(STORAGE_KEY, JSON.stringify(logs.slice(-userSettings.maxLogs)));
177-
} catch (e) {
178-
originalConsole.warn('[CC] History save failed', e);
180+
let logsToSave = logs.slice(-userSettings.maxLogs);
181+
let saved = false;
182+
183+
while (!saved && logsToSave.length > 0) {
184+
try {
185+
targetWindow.localStorage.setItem(STORAGE_KEY, JSON.stringify(logsToSave));
186+
saved = true;
187+
} catch (e) {
188+
// Riconosciamo l'errore di Quota Piena
189+
if (e.name === 'QuotaExceededError' || e.code === 22 || e.name === 'NS_ERROR_DOM_QUOTA_REACHED') {
190+
// Tagliamo via il 15% dei log più vecchi e riproviamo a ciclo continuo (previene i freeze)
191+
const chopSize = Math.max(1, Math.floor(logsToSave.length * 0.15));
192+
logsToSave = logsToSave.slice(chopSize);
193+
194+
// Mostriamo il "Bottone in Console" una sola volta per non spammare
195+
if (!quotaWarningShown) {
196+
quotaWarningShown = true;
197+
198+
// 🔥 LA MAGIA: Creiamo un finto bottone interattivo per la DevTools
199+
const clearBtn = {};
200+
Object.defineProperty(clearBtn, '💣 CLICCA_QUI_PER_SVUOTARE_LA_HISTORY', {
201+
get: function () {
202+
targetWindow.localStorage.removeItem(STORAGE_KEY);
203+
originalConsole.info(
204+
'%c [CC] 🧹 Storage History piallato con successo! ',
205+
'background:#ef4444; color:white; font-weight:bold; padding: 4px; border-radius: 4px;',
206+
);
207+
return 'Svuotamento completato.';
208+
},
209+
});
210+
211+
originalConsole.warn(
212+
"%c⚠️ [God Mode] LocalStorage Pieno! Auto-trimming attivato per evitare freeze.\n👉 Espandi l'oggetto qui sotto e clicca sui puntini (...) per piallare tutto:",
213+
'color: #facc15; font-size: 13px; font-weight: bold;',
214+
);
215+
originalConsole.dir(clearBtn);
216+
}
217+
} else {
218+
originalConsole.warn('[CC] History save failed (Not a quota issue)', e);
219+
break;
220+
}
221+
}
179222
}
180223
}
181224

@@ -198,9 +241,9 @@ const _html2canvas = typeof html2canvas !== 'undefined' ? html2canvas : null;
198241
if (typeof value === 'function') return `[Function: ${value.name || 'anonymous'}]`;
199242
if (value instanceof Error) return { type: 'Error', name: value.name, message: value.message };
200243
if (value instanceof Date) return value.toISOString();
201-
if (typeof targetWindow.HTMLElement !== 'undefined' && value instanceof targetWindow.HTMLElement)
244+
if (typeof targetWindow.HTMLElement !== 'undefined' && value instanceof targetWindow.HTMLElement) {
202245
return `[DOM Element: ${value.tagName}]`;
203-
246+
}
204247
if (seen.has(value)) return '[Circular]';
205248
seen.add(value);
206249

@@ -865,11 +908,11 @@ const _html2canvas = typeof html2canvas !== 'undefined' ? html2canvas : null;
865908
/*
866909
// =====================================================================
867910
// 🚧 [REQUIRES SERVICE WORKER] - ADVANCED PUSH BUTTONS & LISTENERS 🚧
868-
// I bottoni nativi ("actions") nelle notifiche web funzionano SOLO se
869-
// lanciati da un Service Worker attivo sul dominio. Se hai o inietterai
911+
// I bottoni nativi ("actions") nelle notifiche web funzionano SOLO se
912+
// lanciati da un Service Worker attivo sul dominio. Se hai o inietterai
870913
// un SW, scommenta e usa questa logica per avere i pulsanti interattivi.
871914
// =====================================================================
872-
915+
873916
// 1. La Registrazione e l'invio della notifica con i tasti
874917
// navigator.serviceWorker.ready.then(registration => {
875918
// registration.showNotification("⚠️ SISTEMA CRITICO", {
@@ -903,7 +946,7 @@ const _html2canvas = typeof html2canvas !== 'undefined' ? html2canvas : null;
903946
// // });
904947
// }
905948
// });
906-
949+
907950
// 3. Il Listener sulla pagina per ricevere il segnale dal SW e sparare audio/modal
908951
// navigator.serviceWorker.addEventListener('message', event => {
909952
// if (event.data && event.data.type === 'TRAP_RESOLVE') {
@@ -943,13 +986,14 @@ const _html2canvas = typeof html2canvas !== 'undefined' ? html2canvas : null;
943986

944987
const trapBtn = document.createElement('button');
945988
trapBtn.id = '__cc_trap_yes__';
946-
trapBtn.style.cssText = 'background:#ef4444; color:#fff; border:none; padding:15px 50px; font-size:22px; font-weight:bold; border-radius:8px; cursor:pointer; margin-top:20px; transition: all 0.2s; outline:none;';
989+
trapBtn.style.cssText =
990+
'background:#ef4444; color:#fff; border:none; padding:15px 50px; font-size:22px; font-weight:bold; border-radius:8px; cursor:pointer; margin-top:20px; transition: all 0.2s; outline:none;';
947991
trapBtn.textContent = 'YES';
948992

949993
modalBox.appendChild(trapTitle);
950994
modalBox.appendChild(trapDesc);
951995
modalBox.appendChild(trapBtn);
952-
996+
953997
trapBd.appendChild(modalBox);
954998
document.body.appendChild(trapBd);
955999

@@ -1615,7 +1659,7 @@ const _html2canvas = typeof html2canvas !== 'undefined' ? html2canvas : null;
16151659
thanos: toggleThanos,
16161660
xray: toggleXRay,
16171661
dump: exportStateDump,
1618-
version: '4.17.2',
1662+
version: '4.17.3',
16191663
settings: userSettings,
16201664
};
16211665

@@ -1783,5 +1827,5 @@ const _html2canvas = typeof html2canvas !== 'undefined' ? html2canvas : null;
17831827
startAutoHide();
17841828
});
17851829

1786-
ccLog('God Mode v4.17.2 (Stealth Trap & SW Blueprint) Inizializzato! 🚀 (Trusted Types Compliant)');
1787-
})();
1830+
ccLog('God Mode v4.17.3 (Stealth Trap & SW Blueprint) Inizializzato! 🚀 (Trusted Types Compliant)');
1831+
})();

youtube-byp/ytbyp.js

Lines changed: 53 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// ==UserScript==
22
// @name YT Music Autoclicker API (Stealth Trap Edition)
33
// @namespace https://github.com/fgirolami29
4-
// @version 2.1.1
5-
// @description Bypassa popup YT Music con Notifiche Interattive, IntersectionObserver e API di debug. Zero errori TS.
4+
// @version 2.2.0
5+
// @description Bypassa popup YT Music con Notifiche Interattive, IntersectionObserver e API di debug configurabili. Zero errori TS.
66
// @author Tu & Gemini
77
// @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACsAAAAgCAYAAACLmoEDAAABo0lEQVR4AdSXAZKDIBAEiR878zL1Zbmf5aY3txaWpqKyWCS1I4jotiMi6VLh75lSv1eFqdIKNks8qv7I9FR9JQE89mrr/KzNc5HXpOsuYgGrE0cd9eSD6n0mVauG5yKvCR7kWWdYNSoSnfxYCyU8g8C4kdcw0A6OtgD3jgHoF6x62I7KVsNe4k6umsWtUmZcA2P2W2DnYZDdQLPVHmd/AvB+A67x8RLAfuy0o8N0S0mRplTxFwVriKJlCqwGDGzoCwawpIh3GVhzJXoj2lFSxEFXg/WbF60PjeLhUR0WaICR6kXAl8AK0oMpDvn+ofISWD7pki89T7/Q1WEFyZgF9DSk218NFkhJEbdGBvb0GPI7zkvRsZzDyfBlJ7B5rtP1DBLQ4ke+BRIFi4vVIB08CvaQk578aAls0UR9NGFJf2BLzr/y3KnTZzB0NqhJ7842PxRk6miwVORIyw6bmQYr0CTgu0prVNlKYOBdbHyyl/9uaZQUCWhEZ3QFPHlc5AYS0Wb5Z2dt738jWlb5iM7opraV1J2ncVhb11IbeVzkniGVx+IPAAD///H503IAAAAGSURBVAMApvWIs8xfbPkAAAAASUVORK5CYII=
88
// @include *://music.youtube.com/**
@@ -13,17 +13,36 @@
1313
/* eslint-env browser, greasemonkey */
1414
/* global globalThis */
1515

16-
const VERSION = '2.1.1';
16+
const VERSION = '2.2.0';
1717
const ICON_BASE64 =
1818
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACsAAAAgCAYAAACLmoEDAAABo0lEQVR4AdSXAZKDIBAEiR878zL1Zbmf5aY3txaWpqKyWCS1I4jotiMi6VLh75lSv1eFqdIKNks8qv7I9FR9JQE89mrr/KzNc5HXpOsuYgGrE0cd9eSD6n0mVauG5yKvCR7kWWdYNSoSnfxYCyU8g8C4kdcw0A6OtgD3jgHoF6x62I7KVsNe4k6umsWtUmZcA2P2W2DnYZDdQLPVHmd/AvB+A67x8RLAfuy0o8N0S0mRplTxFwVriKJlCqwGDGzoCwawpIh3GVhzJXoj2lFSxEFXg/WbF60PjeLhUR0WaICR6kXAl8AK0oMpDvn+ofISWD7pki89T7/Q1WEFyZgF9DSk218NFkhJEbdGBvb0GPI7zkvRsZzDyfBlJ7B5rtP1DBLQ4ke+BRIFi4vVIB08CvaQk578aAls0UR9NGFJf2BLzr/y3KnTZzB0NqhJ7842PxRk6miwVORIyw6bmQYr0CTgu0prVNlKYOBdbHyyl/9uaZQUCWhEZ3QFPHlc5AYS0Wb5Z2dt738jWlb5iM7opraV1J2ncVhb11IbeVzkniGVx+IPAAD///H503IAAAAGSURBVAMApvWIs8xfbPkAAAAASUVORK5CYII=';
1919

20+
/**
21+
* @typedef {Object} YTBYP_Config
22+
* @property {number} checkIntervalMs - Frequenza del loop di ricerca bottone (ms).
23+
* @property {number} maxAttempts - Numero massimo di iterazioni del loop prima del timeout.
24+
* @property {number} restartDelayMs - Ritardo avvio loop dopo il click sulla notifica (ms).
25+
* @property {number} observerThreshold - Ratio di visibilità per triggerare l'observer (0.0 - 1.0).
26+
* @property {boolean} debugMode - Flag per abilitare/disabilitare l'output di debug.
27+
*/
28+
29+
/** @type {YTBYP_Config} */
30+
const CONFIG = {
31+
checkIntervalMs: 200,
32+
maxAttempts: 50,
33+
restartDelayMs: 150,
34+
observerThreshold: 0.1,
35+
debugMode: true,
36+
};
37+
2038
(function (window, globalThis) {
2139
'use strict';
2240

2341
/** @typedef {{ message: string, attempts?: number, success?: boolean }} YTBypEventDetail */
2442

2543
/**
2644
* @typedef {Object} YTBYP_API
45+
* @property {YTBYP_Config} config
2746
* @property {() => void} start
2847
* @property {() => void} stop
2948
* @property {() => void} forceCheck
@@ -42,7 +61,9 @@ const ICON_BASE64 =
4261
/** @type {Window & { cccg?: {ccLog?: (m: string) => void}, ytbyp?: YTBYP_API }} */
4362
const targetWindow = typeof _global.unsafeWindow !== 'undefined' ? _global.unsafeWindow : window;
4463

45-
/** @param {Element | null} el */
64+
/** * Valuta l'effettiva visibilità di un nodo nel DOM.
65+
* @param {Element | null} el
66+
*/
4667
const isVisible = (el) => {
4768
if (!el) return false;
4869
if (el.hasAttribute('hidden')) return false;
@@ -55,7 +76,8 @@ const ICON_BASE64 =
5576
);
5677
};
5778

58-
/** * @param {string} title
79+
/** * Genera la notifica di sistema interattiva.
80+
* @param {string} title
5981
* @param {string} body
6082
* @param {Function} [onClickCallback]
6183
*/
@@ -65,13 +87,13 @@ const ICON_BASE64 =
6587
const options = {
6688
body,
6789
icon: ICON_BASE64,
68-
requireInteraction: true, // Non scompare finché non la clicchi
90+
requireInteraction: true, // Persistenza attiva finché non interagita
6991
};
7092

7193
const spawn = () => {
7294
const n = new Notification(title, options);
7395
n.onclick = () => {
74-
window.focus(); // Evoca la finestra di YT Music in primo piano
96+
window.focus(); // Richiama il focus sulla finestra di YT Music
7597
n.close();
7698
if (onClickCallback) onClickCallback();
7799
};
@@ -85,6 +107,7 @@ const ICON_BASE64 =
85107
};
86108

87109
/**
110+
* Dispatcher centralizzato per log console ed eventi custom DOM.
88111
* @param {string} eventName
89112
* @param {string} message
90113
* @param {{ attempts?: number, success?: boolean }} [extraPayload={}]
@@ -93,7 +116,12 @@ const ICON_BASE64 =
93116
const prefix = '[YT Music Autoclicker] ';
94117
if (typeof targetWindow.cccg?.ccLog === 'function') {
95118
targetWindow.cccg.ccLog(prefix + message);
96-
} else console.log(prefix + message);
119+
} else {
120+
// Esegue il console.log standard solo se non è un messaggio di debug o se la config debugMode è attiva
121+
if (eventName !== 'ytbyp:debug' || CONFIG.debugMode) {
122+
console.log(prefix + message);
123+
}
124+
}
97125

98126
document.dispatchEvent(new CustomEvent(eventName, { detail: { message, ...extraPayload } }));
99127

@@ -106,11 +134,16 @@ const ICON_BASE64 =
106134
}
107135
};
108136

109-
/** @param {string} msg */
110-
const debug = (msg) => dispatchLog('ytbyp:debug', msg);
137+
/** * Wrapper per i messaggi di routine, filtrati dalla configurazione.
138+
* @param {string} msg
139+
*/
140+
const debug = (msg) => {
141+
if (CONFIG.debugMode) dispatchLog('ytbyp:debug', msg);
142+
};
111143

112144
/** @type {YTBYP_API} */
113145
const API = {
146+
config: CONFIG,
114147
start: () => {},
115148
stop: () => {},
116149
forceCheck: () => {},
@@ -175,17 +208,17 @@ const ICON_BASE64 =
175208
attempts++;
176209
}
177210

178-
if (attempts >= 50) {
211+
if (attempts >= CONFIG.maxAttempts) {
179212
clearInterval(API.interval);
180-
dispatchLog('ytbyp:max-attempts', 'Limite 50 tentativi raggiunto.', {
213+
dispatchLog('ytbyp:max-attempts', `Limite ${CONFIG.maxAttempts} tentativi raggiunto.`, {
181214
attempts,
182215
success: false,
183216
});
184217
}
185-
}, 200);
218+
}, CONFIG.checkIntervalMs);
186219
};
187220

188-
/** * L'Observer Stealth
221+
/** * L'Observer Stealth per l'intercettazione del popup.
189222
* @param {Element} modalElement
190223
*/
191224
const attachVisibilityObserver = (modalElement) => {
@@ -201,21 +234,21 @@ const ICON_BASE64 =
201234
if (entry.isIntersecting) {
202235
debug('⚠️ Il modal di pausa è apparso! Innesco la notifica-trappola...');
203236

204-
// LA MAGIA: Invece di cliccare subito, ti chiamo tramite notifica
237+
// Sospende l'esecuzione e attende il click sulla notifica
205238
sendInteractiveNotification(
206239
'YT Music in Pausa ⏸️',
207240
'YouTube chiede se ci sei. Clicca qui per riprendere la musica!',
208241
() => {
209242
debug("Notifica cliccata! Riprendo l'ascolto e chiudo il popup.");
210-
setTimeout(startClickLoop, 150);
243+
setTimeout(startClickLoop, CONFIG.restartDelayMs);
211244
},
212245
);
213246
}
214247
}
215248
},
216249
{
217-
root: null, // Guarda l'intera viewport del browser
218-
threshold: 0.1, // Basta che appaia il 10% del popup per attivarsi
250+
root: null, // Rilevamento sull'intera viewport
251+
threshold: CONFIG.observerThreshold, // Ratio di attivazione configurabile
219252
},
220253
);
221254

@@ -228,14 +261,14 @@ const ICON_BASE64 =
228261
if (isRunning) return;
229262
isRunning = true;
230263

231-
// 1. Cerca il modal se è già stato iniettato da YouTube
264+
// 1. Hook iniziale su modal preesistenti
232265
const existingModal = document.querySelector('ytmusic-you-there-renderer');
233266
if (existingModal) {
234267
debug("Modal trovato nel DOM all'avvio. Pre-aggancio IntersectionObserver.");
235268
attachVisibilityObserver(existingModal);
236269
}
237270

238-
// 2. Observer di sicurezza per la primissima iniezione nel body
271+
// 2. Observer di sicurezza per la mutazione del body
239272
API.bodyObserver = new MutationObserver((m) => {
240273
for (const mut of m) {
241274
for (const node of mut.addedNodes) {

0 commit comments

Comments
 (0)