Poniższy kod jest odpowiedzialny za automatyczne dodanie adresów url do reguł w Google Optimize,

const partNumbers = ['DELL-P2422H', 'DELL-E2220H', '62B0MAT2EU'];
const urlElement = 'https://www.senetic.pl/product/';

const keyboardEvent = new KeyboardEvent('keydown', {
    code: 'Enter',
    key: 'Enter',
    charKode: 13,
    keyCode: 13,
    view: window
});

const changeEvent = document.createEvent("HTMLEvents");
changeEvent.initEvent("change", false, true);

const addValue = (inputElement, value) => {
    inputElement.dispatchEvent(new Event('focus'));
    inputElement.dispatchEvent(changeEvent);
    inputElement.value = value
    inputElement.dispatchEvent(keyboardEvent);
    inputElement.dispatchEvent(changeEvent);
    inputElement.dispatchEvent(keyboardEvent);
}

const optimizeInputField = document.querySelector(".opt-predicate-value-input")

if (optimizeInputField !== null) {
    let link = ""

    for (const partNumber of partNumbers) {
        link = urlElement + partNumber;

        addValue(optimizeInputField, link)
    }
    
}