Clear logs in DB

This commit is contained in:
redphx 2024-01-06 16:04:07 +07:00
parent 281787d955
commit 989634b52e

View File

@ -8241,17 +8241,38 @@ function updateIceCandidates(candidates, options) {
}
function clearDbLogs(dbName, table) {
const request = window.indexedDB.open(dbName);
request.onsuccess = e => {
const db = e.target.result;
const objectStore = db.transaction(table, 'readwrite').objectStore(table);
const objectStoreRequest = objectStore.clear();
objectStoreRequest.onsuccess = function(event) {
console.log(`[Better xCloud] Cleared ${dbName}.${table}`);
};
}
}
function clearApplicationInsightsBuffers() {
window.sessionStorage.removeItem('AI_buffer');
window.sessionStorage.removeItem('AI_sentBuffer');
}
function clearAllLogs() {
clearApplicationInsightsBuffers();
clearDbLogs('StreamClientLogHandler', 'logs');
clearDbLogs('XCloudAppLogs', 'logs');
}
function interceptHttpRequests() {
var BLOCKED_URLS = [];
if (PREFS.get(Preferences.BLOCK_TRACKING)) {
// Clear Applications Insight buffers
clearApplicationInsightsBuffers();
clearAllLogs();
BLOCKED_URLS = BLOCKED_URLS.concat([
'https://arc.msn.com',
@ -8283,7 +8304,7 @@ function interceptHttpRequests() {
for (let blocked of BLOCKED_URLS) {
if (this._url.startsWith(blocked)) {
if (blocked === 'https://dc.services.visualstudio.com') {
setTimeout(clearApplicationInsightsBuffers, 1000);
setTimeout(clearAllLogs, 1000);
}
return false;
}