Files
nova-dev-extension/lock-version-history.js
Josias Castro 790e67d5d7 Initial commit
2026-06-18 17:12:16 -03:00

50 lines
1.2 KiB
JavaScript

(async () => {
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
const getAllDocuments = () => {
const docs = [document];
const scan = doc => {
[...doc.querySelectorAll("iframe, frame")].forEach(frame => {
try {
if (frame.contentDocument) {
docs.push(frame.contentDocument);
scan(frame.contentDocument);
}
} catch (e) {}
});
};
scan(document);
return docs;
};
const waitForElement = async (selector, timeout = 15000) => {
const start = Date.now();
while (Date.now() - start < timeout) {
for (const doc of getAllDocuments()) {
const el = doc.querySelector(selector);
if (el) return el;
}
await sleep(300);
}
throw new Error(`No se encontró: ${selector}`);
};
const clickElement = async selector => {
const el = await waitForElement(selector);
el.scrollIntoView({ block: "center", inline: "center" });
await sleep(300);
el.click();
return el;
};
await clickElement("#id_menu_prj_version_increment");
await sleep(1000);
await clickElement('input[name="incrementar"][value="Increment"]');
})();