cavi-au / Consent-O-Matic

Browser extension that automatically fills out cookie popups based on your preferences
Other
2.71k stars 132 forks source link

TypeError: Cannot read properties of undefined (reading 'trim') #471

Open benyaa opened 1 month ago

benyaa commented 1 month ago

tldr: orange.fr makes the extension throw Error during consent handling: TypeError: Cannot read properties of undefined (reading 'trim')

So, I was trying to enter orange.fr when I noticed that the extension doesn't go over all of the settings and because of this the consent popup won't let it submit. I tried adding the 2 additional actions to didomi.io rule:

{
                                        "type": "ifcss",
                                        "target": {
                                            "selector": ".didomi-components-accordion",
                                            "textFilter": [
                                                "Expérience enrichie"
                                            ]
                                        },
                                        "trueAction": {
                                            "type": "consent",
                                            "consents": [
                                                {
                                                    "trueAction": {
                                                        "type": "click",
                                                        "target": {
                                                            "selector": ".didomi-consent-popup-data-processing__buttons .didomi-components-radio__option:nth-child(2)"
                                                        }
                                                    },
                                                    "falseAction": {
                                                        "type": "click",
                                                        "target": {
                                                            "selector": ".didomi-consent-popup-data-processing__buttons .didomi-components-radio__option:nth-child(1)"
                                                        }
                                                    },
                                                    "type": "X"
                                                }
                                            ]
                                        }
                                    },
                                    {
                                        "type": "ifcss",
                                        "target": {
                                            "selector": ".didomi-components-accordion",
                                            "textFilter": [
                                                "Publicité ciblée"
                                            ]
                                        },
                                        "trueAction": {
                                            "type": "consent",
                                            "consents": [
                                                {
                                                    "trueAction": {
                                                        "type": "click",
                                                        "target": {
                                                            "selector": ".didomi-consent-popup-data-processing__buttons .didomi-components-radio__option:nth-child(2)"
                                                        }
                                                    },
                                                    "falseAction": {
                                                        "type": "click",
                                                        "target": {
                                                            "selector": ".didomi-consent-popup-data-processing__buttons .didomi-components-radio__option:nth-child(1)"
                                                        }
                                                    },
                                                    "type": "X"
                                                }
                                            ]
                                        }
                                    },

but now, instead of saving it, it fails with:

Error during consent handling: TypeError: Cannot read properties of undefined (reading 'trim')
    at t.findElement (content.js:1:4824)
    at t.find (content.js:1:7054)
    at f.execute (content.js:1:15919)
    at u.execute (content.js:1:13953)
    at async y.execute (content.js:1:17347)
    at async u.execute (content.js:1:13945)
    at async A.runMethod (content.js:1:24650)
    at async content.js:1:29697

it fails on if (":scope" === e.selector.trim()). That's the value of e when it fails:

{"textFilter":["Create a personalised ads profile","Apply market research to generate audience insights","Measure ad performance","Select basic ads","Select personalised ads","Storage and access to geolocation information for targeted advertising purposes","Offer personalised advertising","Publicité personnalisée","Sélectionner des publicités personnalisées","Créer un profil pour afficher un contenu personnalisé","Promotions de nos contenus, produits et services","Publicité ciblée par profilage (collecte, profilage et partage de données entre éditeurs partenaires)","Cookies för anpassad marknadsföring och innehåll","Mäta annonsprestanda","Skapa en personanpassad annonsprofil","Välja personanpassade annonser","Cookies for custom marketing and content","Opprett en personlig annonseprofil","Måle annonseprestasjon","Mainonta- ja kohdistusevästeet","Mainonnan ja sen tehokkuuden mittaaminen","Personoidun mainosprofiilin muodostaminen","Tavallisten mainosten valinta","Personoitujen mainosten valinta","Cookies Publicitaires et de personnalisation","Promotion de nos contenus, produits et services","Conservation et accès aux informations de géolocalisation à des fins de publicité ciblée","Publicités personnalisées de l'éditeur","Applicare ricerche di mercato per generare approfondimenti sul pubblico","Selezionare annunci personalizzati","Creare un profilo di annunci personalizzati","Selezionare annunci basici (basic ads)","Marketing e targeting","Archiviazione e accesso alle informazioni di geolocalizzazione per scopi pubblicitari mirati","Prestaties van advertenties meten","Gepersonaliseerde advertenties selecteren","Basisadvertenties selecteren","Een gepersonaliseerd advertentieprofiel aanmaken","Opslag en toegang tot geolocatie-informatie voor gerichte reclamedoeleinden","Social Media","Advertenties online kansspelen","Utiliser des données limitées pour sélectionner la publicité","Beperkte gegevens gebruiken om advertenties te selecteren","Profielen gebruiken voor de selectie van gepersonaliseerde advertenties","Create profiles for personalised advertising","Measure advertising performance","Use limited data to select advertising","Use profiles to select personalised advertising","Storage and access to geolocation information to carry out marketing studies","Analyses commerciales et marketing sur la base de la géolocalisation"]}

spec:

Thanks

benyaa commented 1 month ago

Ok, so the fix in for this is to change: if(options.selector.trim() === ":scope") to if(options.selector === undefined || options.selector.trim() === ":scope") in Tools.js.