Run Quick Action via script/plugin
I want to make a plugin with a button that triggers a quick action “remove background”, ChatGPT spits me this code, but it does not work.
document.getElementById("remove-bg-btn").addEventListener("click", async () => {
try {
await executeAsModal(async () => {
await batchPlay([
{
"_obj": "invokeCommand",
"commandID": 3315,
"_isCommand": true
}
], {});
});
console.log("✅ Background removed successfully!");
} catch (error) {
console.error("❌ Error removing background:", error);
displayMessage("Failed to remove background: " + (error.message || "Unknown error"));
}
});
