Skip to content

Instantly share code, notes, and snippets.

@robjstanley
Last active September 25, 2025 08:57
Show Gist options
  • Save robjstanley/27d62cb363f68a6be86b67d13c8b992b to your computer and use it in GitHub Desktop.
Save robjstanley/27d62cb363f68a6be86b67d13c8b992b to your computer and use it in GitHub Desktop.
Accept all suggested Alt Tags for Shopify > Content > Files
async function processRows() {
const rows = Array.from(document.querySelectorAll('.Polaris-Table-TableRow')).filter(row => {
const altCell = row.querySelector(
'.Polaris-Table-TableCell[aria-colindex="4"] .Polaris-Table-TableCell__TableCellContent'
);
return altCell && altCell.textContent.trim() === "";
});
console.log(`Found ${rows.length} rows with empty alt text.`);
for (const row of rows) {
// Click row
row.click();
await new Promise(r => setTimeout(r, 2000));
// Look for "Apply suggested alt text" button
const applyBtn = document.querySelector('button[aria-label="Apply suggested alt text"]');
if (applyBtn) {
applyBtn.click();
await new Promise(r => setTimeout(r, 2000));
const saveBtn = Array.from(document.querySelectorAll('button.Polaris-Button--variantPrimary')).find(btn => btn.textContent.trim() === "Save");
if (saveBtn) {
saveBtn.click();
await new Promise(r => setTimeout(r, 2000));
}
}
// Click Exit
const exitBtn = document.querySelector('button[aria-label="Exit"]');
if (exitBtn) {
exitBtn.click();
await new Promise(r => setTimeout(r, 2000));
}
}
console.log('✅ Finished processing rows with empty alt text');
const nextBtn = document.querySelector('button[aria-label="Next"]');
if (nextBtn) {
console.log('Loading next page')
nextBtn.click();
await new Promise(r => setTimeout(r, 5000));
processRows();
}
}
processRows();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment