User:Polygnotus/Scripts/SortByEditcount.js: Difference between revisions

Content deleted Content added
Created page with '// Wikipedia User Edit Count Checker for common.js // Gets edit counts for users with maxlag support, HTTP error handling, exponential backoff retry, deduplication // Uses OOUI for modern interface async function checkUserEditCounts() { showEditCountDialog(); } function showEditCountDialog() { // Create input field for usernames const inputField = new OO.ui.MultilineTextInputWidget({ placeholder: 'Enter usernames (one per line)\nSuppor...'
 
No edit summary
 
(12 intermediate revisions by the same user not shown)
Line 54:
});
 
// Create simple layout without FieldLayout wrappers
const fieldsetLayout = new OO.ui.FieldsetLayout({
label: 'User Edit Count Checker',
items: [
new OO.ui.FieldLayoutLabelWidget(inputField, { label: 'Input usernames:' }),
label: 'Input usernames:'inputField,
new OO.ui.Widget({ content: [new alignOO.ui.LabelWidget({ label: 'topStatus:' })] }),
})statusMessage,
new OO.ui.FieldLayoutWidget(statusMessage,{ content: [new OO.ui.LabelWidget({ label: 'Progress:' })] }),
label: 'Status:'progressBar,
new OO.ui.Widget({ content: [new alignOO.ui.LabelWidget({ label: 'topResults:' })] }),
})outputField,
new OO.ui.FieldLayoutWidget(progressBar,{ content: [new OO.ui.LabelWidget({ label: 'Actions:' })] }),
new label: 'Progress:',OO.ui.HorizontalLayout({
alignitems: 'top'[checkButton, clearButton, copyButton]
}),
new OO.ui.FieldLayout(outputField, {
label: 'Results:',
align: 'top'
}),
new OO.ui.FieldLayout(
new OO.ui.HorizontalLayout({
items: [checkButton, clearButton, copyButton]
}),
{
label: 'Actions:',
align: 'top'
}
)
]
});
 
// Create a proper dialog class
function EditCountDialog(config) {
const dialog = new OO.ui.Dialog({
EditCountDialog.parent.call(this, config);
size: 'large',
});
classes: ['editcount-dialog']
OO.inheritClass(EditCountDialog, OO.ui.Dialog);
});
EditCountDialog.static.name = 'editCountDialog';
EditCountDialog.static.title = 'User Edit Count Checker';
EditCountDialog.static.size = 'large';
 
dialogEditCountDialog.prototype.initialize = function() {
OOEditCountDialog.ui.Dialogparent.prototype.initialize.call(this);
this.content = new OO.ui.PanelLayout({
padded: true,
Line 102 ⟶ 92:
};
 
dialogEditCountDialog.prototype.getSetupProcess = function(data) {
return OOEditCountDialog.ui.Dialogparent.prototype.getSetupProcess.call(this, data)
.next(function() {
inputField.focus();
});
};
 
EditCountDialog.prototype.getActionProcess = function(action) {
if (action === 'close') {
return new OO.ui.FieldLayoutProcess(function(outputField,) {
this.close({ action: action });
}, {this);
}
return EditCountDialog.parent.prototype.getActionProcess.call(this, action);
};
 
EditCountDialog.static.actions = [
){
size action: 'largeclose',
label: 'Results:Close',
flags: ['safe', 'close']
}
];
 
const dialog = new OO.ui.DialogEditCountDialog({
classes: ['editcount-dialog']
});
 
// Button event handlers
Line 142 ⟶ 153:
const windowManager = new OO.ui.WindowManager();
$(document.body).append(windowManager.$element);
windowManager.addWindows([{ editCountDialog: dialog] });
 
// Open dialog
windowManager.openWindow(dialog'editCountDialog');
}
 
Line 172 ⟶ 183:
checkButton.setLabel('Checking...');
 
const resultsuserResults = [];
const errors = [];
 
Line 188 ⟶ 199:
try {
const editCount = await getUserEditCount(userInfo.username);
resultsuserResults.push(`${userInfo.original}: ${editCount.toLocaleString()} edits`);
original: userInfo.original,
username: userInfo.username,
aligneditCount: 'top'editCount
}),;
console.log(`✓ ${userInfo.username}: ${editCount.toLocaleString()} edits`);
} catch (error) {
console.error(`Failed to get edit count for ${userInfo.username}:`, error);
resultsuserResults.push(`${userInfo.original}: ERROR - ${error.message}`);
original: userInfo.original,
username: userInfo.username,
labeleditCount: 'Actions:'0,
alignerror: 'top'true
}),;
errors.push(userInfo.username);
}
Line 201 ⟶ 221:
}
}
 
// Sort by edit count (highest first)
userResults.sort((a, b) => b.editCount - a.editCount);
 
// Update UI with completion
Line 209 ⟶ 232:
copyButton.setDisabled(false);
 
// Display results (just usernames, but ordered by edit count)
const sortedUsernames = userResults.map(result => result.original);
outputField.setValue(resultssortedUsernames.join('\n'));
 
console.log("\n=== EDIT COUNT RESULTS (sorted by edit count) ===");
resultsuserResults.forEach(result => console.log(result));{
if (result.error) {
console.log(`${result.original}: ERROR`);
} else {
console.log(`${result.original}: ${result.editCount.toLocaleString()} edits`);
}
});
if (errors.length > 0) {
Line 396 ⟶ 426:
.editcount-dialog .oo-ui-window-body {
font-family: sans-serif;
height: 680px !important;
}
.editcount-dialog .oo-ui-window-frame {
height: 680px !important;
}
.editcount-input textarea,