Xet-GC semi-automates the cleanup of Hugging Face repositories bloated by Xet.
With the "LFS Files" modal open in your settings, this script maps each row of the table to its corresponding "Possible filename," which is hidden within a tooltip mask. By parsing the DOM to extract this information, the script retains only the most recent version of each unique filename (assuming the first occurrence from top to bottom is the latest) and automatically selects all older duplicates.
- Open the Settings of your Hugging Face repository and navigate to Storage Usage > List Large Files.
- Open your browser's Developer Tools console, then copy and paste the code below. It will automatically check the boxes for all older, duplicate large files.
(function() {
// Grab all the rows in the "LFS Files" table
const rows = document.querySelectorAll('tr.text-smd');
// Grab all tooltips, convert to an Array, and filter for the ones containing filenames
const allTooltips = Array.from(document.querySelectorAll('.tooltip-mask .tooltip'));
const fileTooltips = allTooltips.filter(tt => tt.textContent && tt.textContent.includes('Possible filename'));
// Sanity check to ensure the DOM is fully loaded and structures match
if (rows.length !== fileTooltips.length) {
console.error(`Lengths do not match. Found ${rows.length} rows and ${fileTooltips.length} file tooltips. Ensure the page is fully loaded.`);
return;
}
const seenFilenames = new Set();
let checkedCount = 0;
for (let i = 0; i < rows.length; i++) {
const rawText = fileTooltips[i].textContent || "";
const filename = rawText.replace('Possible filename:', '').trim();
const checkbox = rows[i].querySelector('input[type="checkbox"]');
if (!filename || !checkbox) continue;
if (seenFilenames.has(filename)) {
// If the filename is already in the Set, it is an older duplicate. Check the box.
if (!checkbox.checked) {
checkbox.click(); // Trigger native click to ensure framework events fire correctly
checkedCount++;
}
} else {
// First time seeing this filename (latest version), add it to the Set and skip checking.
seenFilenames.add(filename);
}
}
console.log(`Execution complete. Checked ${checkedCount} duplicate files. Ready for removal.`);
})();- Finally, click "Remove selected", enter the repository ID, and confirm the deletion.