Uncaught SyntaxError and Uncaught TypeError on my chrome extension code

Viewed 36

I have several errors with the code of a chrome extension " Uncaught SyntaxError: Identifier 'select1' has already been declared" and "Uncaught TypeError: Cannot read property 'addEventListener' of null" and I have to refresh the page each time for the code to work correctly here is the code if you have any suggestions?

const select1 = document.getElementById('categorisation_1');
const select2 = document.getElementById('categorisation_2');
const select3 = document.getElementById('categorisation_3');
const select4 = document.getElementById('categorisation_4');

select1.addEventListener('change', () => {
    select2.removeAttribute('disabled');
    select3.removeAttribute('disabled');
    select4.removeAttribute('disabled');
});

setTimeout(() => {
    select1.value = '7: Object';
    select1.dispatchEvent(new Event("change"));
}, 1E3);

setTimeout(() => {
    select2.value = '6: Object';
    select2.dispatchEvent(new Event("change"));
}, 2E3);

setTimeout(() => {
    select3.value = '25: Object';
    select3.dispatchEvent(new Event("change"));
}, 3E3);

setTimeout(() => {
    select4.value = '1: Object';
    select4.dispatchEvent(new Event("change"));
}, 4E3);

document.getElementById('champContactClient').value = '1: Object';
document.getElementById('champGravite').value = '2: Object';
document.getElementsByClassName("btn btn-file-upload")[0].click();
document.getElementById('champCommentaire').value += "ok";
0 Answers
Related