minimalistic_scanner / select_back_camera.js
Glainez's picture
Update select_back_camera.js
dcae7fb verified
raw
history blame
898 Bytes
window.addEventListener('load', (event) => {
// Wait for Gradio interface to fully load
const gradioAppLoaded = setInterval(() => {
const webcamButton = document.querySelector('button[aria-label="select input source"]');
if (webcamButton) {
clearInterval(gradioAppLoaded);
webcamButton.click();
setTimeout(() => {
const backCameraOption = Array.from(document.querySelectorAll('select option')).find(option => option.text.toLowerCase().includes('0'));
if (backCameraOption) {
backCameraOption.selected = true;
const event = new Event('change', { bubbles: true });
backCameraOption.parentElement.dispatchEvent(event);
}
}, 500); // Adjust timeout as necessary to ensure dropdown is populated
}
}, 1000);
});