Steam Delete Comments By XZZ. 001
xzz
plain_text
7 months ago
2.8 kB
28
Indexable
DeleteComments
// Create div for progress info
const progressDiv = document.createElement('div');
progressDiv.style.cssText = 'position: fixed; top: 10px; right: 10px; background: #1b2838; color: white; padding: 15px; z-index: 9999; border-radius: 5px;';
document.body.prepend(progressDiv);
// Helper function to convert Deferred to Promise
function jQueryPromiseToNative(promise) {
return new Promise((resolve, reject) => {
promise.done(resolve).fail(reject);
});
}
jQueryPromiseToNative($J.post('//steamcommunity.com/comment/Profile/render/' + g_steamID + '/-1/', {
'count': Number.POSITIVE_INFINITY,
'sessionid': g_sessionID
}))
.then(function(data) {
const comments = $J('<div></div>').append(data.comments_html).find('.commentthread_comment');
const totalComments = comments.length;
let deletedCount = 0;
let errorCount = 0;
function updateProgress() {
progressDiv.innerHTML = `
Total: ${totalComments}<br>
Deleted: ${deletedCount}<br>
Errors: ${errorCount}<br>
Remaining: ${totalComments - deletedCount - errorCount}
`;
}
const promises = [];
comments.each(function() {
const comment = $J(this);
const comment_id = comment.attr('id').replace('comment_', '');
const promise = new Promise((resolve, reject) => {
$J.post('//steamcommunity.com/comment/Profile/delete/' + g_steamID + '/-1/', {
'gidcomment': comment_id,
'sessionid': g_sessionID
})
.done(() => {
deletedCount++;
updateProgress();
resolve();
})
.fail(() => {
errorCount++;
updateProgress();
reject();
});
});
promises.push(promise);
});
return Promise.allSettled(promises);
})
.then(function(results) {
const successCount = results.filter(r => r.status === 'fulfilled').length;
const errorCount = results.filter(r => r.status === 'rejected').length;
const resultMsg = `
Process Completed!<br>
Total Comments: ${results.length}<br>
Successfully Deleted: ${successCount}<br>
Failed to Delete: ${errorCount}
`;
ShowAlertDialog('Comment Deletion Result', resultMsg, 'Reload Page').then(function() {
window.location.reload();
});
progressDiv.remove();
})
.catch(function(error) {
ShowAlertDialog('Error', 'Error loading comments: ' + error, 'OK');
progressDiv.remove();
});Editor is loading...