Last active
March 27, 2025 12:54
-
-
Save robjstanley/d2a8110479702c76e3667f1ded667e99 to your computer and use it in GitHub Desktop.
Shopify Bulk Edit - Accept suggested Category
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Shopify provides no way to accept all Product Category suggestions from the admin, or via matrixify import. | |
* Select all products via Product admin, Bulk Edit, open dev tools and paste in the below JS to click accept | |
* on each suggestion, and keep scrolling the page to reveal more suggestions and keep accepting. | |
* Once done, hit Save. | |
*/ | |
async function clickAndScroll() { | |
const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms)); | |
const scrollContainer = document.querySelector('._ScrollContainer_vnhhx_5._RightPadding_vnhhx_15'); | |
if (!scrollContainer) { | |
console.error('Scroll container not found.'); | |
return; | |
} | |
let prevScrollTop = -1; | |
while (prevScrollTop !== scrollContainer.scrollTop) { | |
prevScrollTop = scrollContainer.scrollTop; | |
document.querySelectorAll('[type="check-circle"]').forEach(el => { | |
const rect = el.getBoundingClientRect(); | |
if (rect.top >= 0 && rect.bottom <= window.innerHeight) { | |
el.click(); | |
console.log('Saving...'); | |
} | |
}); | |
scrollContainer.scrollBy(0, scrollContainer.clientHeight / 2); | |
await delay(500); // Adjust delay as needed | |
} | |
console.log('Finished processing all elements.'); | |
} | |
clickAndScroll(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment