@duckduckgo/autoconsent 2.2.1 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/.github/workflows/release.yml +29 -0
  2. package/CHANGELOG.md +275 -0
  3. package/Jenkinsfile +2 -2
  4. package/dist/addon-firefox/background.bundle.js +1 -1
  5. package/dist/addon-firefox/content.bundle.js +1 -1
  6. package/dist/addon-firefox/manifest.json +1 -1
  7. package/dist/addon-firefox/rules.json +396 -25
  8. package/dist/addon-mv3/background.bundle.js +1 -1
  9. package/dist/addon-mv3/content.bundle.js +1 -1
  10. package/dist/addon-mv3/manifest.json +2 -1
  11. package/dist/addon-mv3/popup.bundle.js +1 -0
  12. package/dist/addon-mv3/popup.html +67 -0
  13. package/dist/addon-mv3/rules.json +396 -25
  14. package/dist/autoconsent.cjs.js +1 -1
  15. package/dist/autoconsent.esm.js +1 -1
  16. package/dist/autoconsent.playwright.js +1 -1
  17. package/lib/cmps/airbnb.ts +57 -0
  18. package/lib/cmps/all.ts +4 -0
  19. package/lib/cmps/base.ts +2 -2
  20. package/lib/cmps/consentmanager.ts +3 -0
  21. package/lib/cmps/tiktok.ts +73 -0
  22. package/lib/cmps/trustarc-frame.ts +1 -1
  23. package/lib/rule-executors.ts +15 -15
  24. package/lib/rules.ts +1 -1
  25. package/package.json +15 -4
  26. package/playwright/runner.ts +8 -2
  27. package/playwright.config.ts +9 -0
  28. package/readme.md +5 -1
  29. package/rollup.config.js +16 -2
  30. package/rules/autoconsent/amazon.json +20 -0
  31. package/rules/autoconsent/dailymotion.json +22 -0
  32. package/rules/autoconsent/dmgmedia.json +19 -0
  33. package/rules/autoconsent/facebook.json +21 -0
  34. package/rules/autoconsent/google-consent-standalone.json +17 -0
  35. package/rules/autoconsent/google.json +22 -0
  36. package/rules/autoconsent/linkedin.json +23 -0
  37. package/rules/autoconsent/monzo-com.json +1 -6
  38. package/rules/autoconsent/privacymanager.json +1 -1
  39. package/rules/autoconsent/reddit.json +22 -0
  40. package/rules/autoconsent/twitter.json +22 -0
  41. package/rules/autoconsent/vodafone-de.json +1 -1
  42. package/rules/autoconsent/youtube-desktop.json +23 -0
  43. package/rules/autoconsent/youtube-mobile.json +22 -0
  44. package/rules/rules.json +396 -25
  45. package/tests/airbnb.spec.ts +8 -0
  46. package/tests/amazon.spec.ts +17 -0
  47. package/tests/complianz-categories.spec.ts +1 -1
  48. package/tests/dailymotion.spec.ts +14 -0
  49. package/tests/dmgmedia.spec.ts +16 -0
  50. package/tests/facebook.spec.ts +14 -0
  51. package/tests/google.spec.ts +7 -0
  52. package/tests/linkedin.spec.ts +7 -0
  53. package/tests/reddit.spec.ts +8 -0
  54. package/tests/sibbo.spec.ts +0 -1
  55. package/tests/tiktok.spec.ts +14 -0
  56. package/tests/twitter.spec.ts +16 -0
  57. package/tests/wp-cookie-notice.spec.ts +1 -1
  58. package/tests/youtube-desktop.spec.ts +7 -0
  59. package/tests/youtube-mobile.spec.ts +8 -0
  60. package/.vscode/.idea/.vscode.iml +0 -9
  61. package/.vscode/.idea/modules.xml +0 -8
  62. package/.vscode/.idea/workspace.xml +0 -28
  63. package/.vscode/settings.json +0 -7
  64. package/lib/web/consentomatic/index.js +0 -188
  65. package/lib/web/consentomatic/tools.js +0 -177
  66. package/rules/autoconsent/asus.json +0 -7
@@ -107,54 +107,66 @@
107
107
  ]
108
108
  },
109
109
  {
110
- "name": "arzt-auskunft.de",
110
+ "name": "amazon.com",
111
111
  "prehideSelectors": [
112
- "#cookiescript_injected"
112
+ "span[data-action=\"sp-cc\"][data-sp-cc*=\"rejectAllAction\"]"
113
113
  ],
114
114
  "detectCmp": [
115
115
  {
116
- "exists": "#cookiescript_injected"
116
+ "exists": "span[data-action=\"sp-cc\"][data-sp-cc*=\"rejectAllAction\"]"
117
117
  }
118
118
  ],
119
119
  "detectPopup": [
120
120
  {
121
- "visible": "#cookiescript_injected"
121
+ "visible": "span[data-action=\"sp-cc\"][data-sp-cc*=\"rejectAllAction\"]"
122
122
  }
123
123
  ],
124
- "optOut": [
124
+ "optIn": [
125
125
  {
126
- "click": "#cookiescript_reject"
126
+ "waitForVisible": "#sp-cc-accept"
127
+ },
128
+ {
129
+ "wait": 500
130
+ },
131
+ {
132
+ "click": "#sp-cc-accept"
127
133
  }
128
134
  ],
129
- "optIn": [
135
+ "optOut": [
130
136
  {
131
- "click": "#cookiescript_accept"
137
+ "waitForVisible": "#sp-cc-rejectall-link"
138
+ },
139
+ {
140
+ "wait": 500
141
+ },
142
+ {
143
+ "click": "#sp-cc-rejectall-link"
132
144
  }
133
145
  ]
134
146
  },
135
147
  {
136
- "name": "asus",
148
+ "name": "arzt-auskunft.de",
149
+ "prehideSelectors": [
150
+ "#cookiescript_injected"
151
+ ],
137
152
  "detectCmp": [
138
153
  {
139
- "exists": "#cookie-policy-info"
154
+ "exists": "#cookiescript_injected"
140
155
  }
141
156
  ],
142
157
  "detectPopup": [
143
158
  {
144
- "visible": "#cookie-policy-info"
159
+ "visible": "#cookiescript_injected"
145
160
  }
146
161
  ],
147
- "optIn": [
162
+ "optOut": [
148
163
  {
149
- "click": ".btn-read-ck"
164
+ "click": "#cookiescript_reject"
150
165
  }
151
166
  ],
152
- "optOut": [
153
- {
154
- "click": ".btn-setting"
155
- },
167
+ "optIn": [
156
168
  {
157
- "click": ".btn-save"
169
+ "click": "#cookiescript_accept"
158
170
  }
159
171
  ]
160
172
  },
@@ -756,6 +768,40 @@
756
768
  }
757
769
  ]
758
770
  },
771
+ {
772
+ "name": "dailymotion.com",
773
+ "runContext": {
774
+ "urlPattern": "^https://(www\\.)?dailymotion\\.com/"
775
+ },
776
+ "prehideSelectors": [
777
+ "div[class*=\"Overlay__container\"]:has(div[class*=\"TCF2Popup\"])"
778
+ ],
779
+ "detectCmp": [
780
+ {
781
+ "exists": "div[class*=\"TCF2Popup\"]"
782
+ }
783
+ ],
784
+ "detectPopup": [
785
+ {
786
+ "visible": "[class*=\"TCF2Popup\"] a[href^=\"https://www.dailymotion.com/legal/cookiemanagement\"]"
787
+ }
788
+ ],
789
+ "optIn": [
790
+ {
791
+ "waitForThenClick": "button[class*=\"TCF2Popup__button\"]:not([class*=\"TCF2Popup__personalize\"])"
792
+ }
793
+ ],
794
+ "optOut": [
795
+ {
796
+ "waitForThenClick": "button[class*=\"TCF2ContinueWithoutAcceptingButton\"]"
797
+ }
798
+ ],
799
+ "test": [
800
+ {
801
+ "eval": "!!document.cookie.match('dm-euconsent-v2')"
802
+ }
803
+ ]
804
+ },
759
805
  {
760
806
  "name": "deepl.com",
761
807
  "prehideSelectors": [
@@ -782,6 +828,42 @@
782
828
  }
783
829
  ]
784
830
  },
831
+ {
832
+ "name": "dmgmedia",
833
+ "prehideSelectors": [
834
+ "[data-project=\"mol-fe-cmp\"]"
835
+ ],
836
+ "detectCmp": [
837
+ {
838
+ "exists": "[data-project=\"mol-fe-cmp\"]"
839
+ }
840
+ ],
841
+ "detectPopup": [
842
+ {
843
+ "visible": "[data-project=\"mol-fe-cmp\"]"
844
+ }
845
+ ],
846
+ "optIn": [
847
+ {
848
+ "waitForThenClick": "[data-project=\"mol-fe-cmp\"] button[class*=primary]"
849
+ }
850
+ ],
851
+ "optOut": [
852
+ {
853
+ "waitForThenClick": "[data-project=\"mol-fe-cmp\"] button[class*=basic]"
854
+ },
855
+ {
856
+ "waitForVisible": "[data-project=\"mol-fe-cmp\"] div[class*=\"tabContent\"]"
857
+ },
858
+ {
859
+ "waitForThenClick": "[data-project=\"mol-fe-cmp\"] div[class*=\"toggle\"][class*=\"enabled\"]",
860
+ "all": true
861
+ },
862
+ {
863
+ "waitForThenClick": "[data-project=\"mol-fe-cmp\"] button[class*=white]"
864
+ }
865
+ ]
866
+ },
785
867
  {
786
868
  "name": "Drupal",
787
869
  "detectCmp": [
@@ -1032,6 +1114,43 @@
1032
1114
  }
1033
1115
  ]
1034
1116
  },
1117
+ {
1118
+ "name": "facebook",
1119
+ "runContext": {
1120
+ "urlPattern": "^https://([a-z0-9-]+\\.)?facebook\\.com/"
1121
+ },
1122
+ "prehideSelectors": [
1123
+ "div[data-testid=\"cookie-policy-manage-dialog\"]"
1124
+ ],
1125
+ "detectCmp": [
1126
+ {
1127
+ "exists": "div[data-testid=\"cookie-policy-manage-dialog\"]"
1128
+ }
1129
+ ],
1130
+ "detectPopup": [
1131
+ {
1132
+ "visible": "div[data-testid=\"cookie-policy-manage-dialog\"]"
1133
+ }
1134
+ ],
1135
+ "optIn": [
1136
+ {
1137
+ "waitForThenClick": "button[data-cookiebanner=\"accept_button\"]"
1138
+ },
1139
+ {
1140
+ "waitForVisible": "div[data-testid=\"cookie-policy-manage-dialog\"]",
1141
+ "check": "none"
1142
+ }
1143
+ ],
1144
+ "optOut": [
1145
+ {
1146
+ "waitForThenClick": "button[data-cookiebanner=\"accept_only_essential_button\"]"
1147
+ },
1148
+ {
1149
+ "waitForVisible": "div[data-testid=\"cookie-policy-manage-dialog\"]",
1150
+ "check": "none"
1151
+ }
1152
+ ]
1153
+ },
1035
1154
  {
1036
1155
  "name": "funding-choices",
1037
1156
  "prehideSelectors": [
@@ -1067,6 +1186,67 @@
1067
1186
  }
1068
1187
  ]
1069
1188
  },
1189
+ {
1190
+ "name": "google-consent-standalone",
1191
+ "prehideSelectors": [],
1192
+ "detectCmp": [
1193
+ {
1194
+ "exists": "a[href^=\"https://policies.google.com/technologies/cookies\""
1195
+ },
1196
+ {
1197
+ "exists": "form[action^=\"https://consent.\"][action$=\".com/save\"]"
1198
+ }
1199
+ ],
1200
+ "detectPopup": [
1201
+ {
1202
+ "visible": "a[href^=\"https://policies.google.com/technologies/cookies\""
1203
+ }
1204
+ ],
1205
+ "optIn": [
1206
+ {
1207
+ "waitForThenClick": "form[action^=\"https://consent.\"][action$=\".com/save\"]:has(input[name=set_eom][value=false]) button"
1208
+ }
1209
+ ],
1210
+ "optOut": [
1211
+ {
1212
+ "waitForThenClick": "form[action^=\"https://consent.\"][action$=\".com/save\"]:has(input[name=set_eom][value=true]) button"
1213
+ }
1214
+ ]
1215
+ },
1216
+ {
1217
+ "name": "google.com",
1218
+ "prehideSelectors": [
1219
+ ".HTjtHe#xe7COe"
1220
+ ],
1221
+ "detectCmp": [
1222
+ {
1223
+ "exists": ".HTjtHe#xe7COe"
1224
+ },
1225
+ {
1226
+ "exists": ".HTjtHe#xe7COe a[href^=\"https://policies.google.com/technologies/cookies\"]"
1227
+ }
1228
+ ],
1229
+ "detectPopup": [
1230
+ {
1231
+ "visible": ".HTjtHe#xe7COe button#W0wltc"
1232
+ }
1233
+ ],
1234
+ "optIn": [
1235
+ {
1236
+ "waitForThenClick": ".HTjtHe#xe7COe button#L2AGLb"
1237
+ }
1238
+ ],
1239
+ "optOut": [
1240
+ {
1241
+ "waitForThenClick": ".HTjtHe#xe7COe button#W0wltc"
1242
+ }
1243
+ ],
1244
+ "test": [
1245
+ {
1246
+ "eval": "!!document.cookie.match(/SOCS=CAE/)"
1247
+ }
1248
+ ]
1249
+ },
1070
1250
  {
1071
1251
  "name": "gov.uk",
1072
1252
  "detectCmp": [
@@ -1308,6 +1488,50 @@
1308
1488
  }
1309
1489
  ]
1310
1490
  },
1491
+ {
1492
+ "name": "linkedin.com",
1493
+ "prehideSelectors": [
1494
+ ".artdeco-global-alert[type=COOKIE_CONSENT]"
1495
+ ],
1496
+ "detectCmp": [
1497
+ {
1498
+ "exists": ".artdeco-global-alert[type=COOKIE_CONSENT]"
1499
+ }
1500
+ ],
1501
+ "detectPopup": [
1502
+ {
1503
+ "visible": ".artdeco-global-alert[type=COOKIE_CONSENT]"
1504
+ }
1505
+ ],
1506
+ "optIn": [
1507
+ {
1508
+ "waitForVisible": ".artdeco-global-alert[type=COOKIE_CONSENT] button[action-type=ACCEPT]"
1509
+ },
1510
+ {
1511
+ "wait": 500
1512
+ },
1513
+ {
1514
+ "waitForThenClick": ".artdeco-global-alert[type=COOKIE_CONSENT] button[action-type=ACCEPT]"
1515
+ }
1516
+ ],
1517
+ "optOut": [
1518
+ {
1519
+ "waitForVisible": ".artdeco-global-alert[type=COOKIE_CONSENT] button[action-type=DENY]"
1520
+ },
1521
+ {
1522
+ "wait": 500
1523
+ },
1524
+ {
1525
+ "waitForThenClick": ".artdeco-global-alert[type=COOKIE_CONSENT] button[action-type=DENY]"
1526
+ }
1527
+ ],
1528
+ "test": [
1529
+ {
1530
+ "waitForVisible": ".artdeco-global-alert[type=COOKIE_CONSENT]",
1531
+ "check": "none"
1532
+ }
1533
+ ]
1534
+ },
1311
1535
  {
1312
1536
  "name": "marksandspencer.com",
1313
1537
  "isHidingRule": true,
@@ -1512,11 +1736,6 @@
1512
1736
  {
1513
1737
  "click": ".js-decline-cookie-policy"
1514
1738
  }
1515
- ],
1516
- "test": [
1517
- {
1518
- "eval": "document.cookie.includes('_cookies_banner_dismissed=true') && !document.cookie.includes('_cookie_advertising_accepted')"
1519
- }
1520
1739
  ]
1521
1740
  },
1522
1741
  {
@@ -1876,7 +2095,7 @@
1876
2095
  "iframe[src^=\"https://cmp-consent-tool.privacymanager.io\"]"
1877
2096
  ],
1878
2097
  "runContext": {
1879
- "url": "https://cmp-consent-tool.privacymanager.io",
2098
+ "urlPattern": "^https://cmp-consent-tool\\.privacymanager\\.io/",
1880
2099
  "main": false,
1881
2100
  "frame": true
1882
2101
  },
@@ -2015,6 +2234,40 @@
2015
2234
  }
2016
2235
  ]
2017
2236
  },
2237
+ {
2238
+ "name": "reddit.com",
2239
+ "runContext": {
2240
+ "urlPattern": "^https://www\\.reddit\\.com/"
2241
+ },
2242
+ "prehideSelectors": [
2243
+ "section:has(section > span > a[href^=\"https://www.reddit.com/policies/cookies\"])"
2244
+ ],
2245
+ "detectCmp": [
2246
+ {
2247
+ "exists": "section:has(> span > a[href^=\"https://www.reddit.com/policies/cookies\"])"
2248
+ }
2249
+ ],
2250
+ "detectPopup": [
2251
+ {
2252
+ "visible": "section:has(> span > a[href^=\"https://www.reddit.com/policies/cookies\"])"
2253
+ }
2254
+ ],
2255
+ "optIn": [
2256
+ {
2257
+ "waitForThenClick": "section:has(> span > a[href^=\"https://www.reddit.com/policies/cookies\"]) section form:last-child button"
2258
+ }
2259
+ ],
2260
+ "optOut": [
2261
+ {
2262
+ "waitForThenClick": "section:has(> span > a[href^=\"https://www.reddit.com/policies/cookies\"]) section form:first-child button"
2263
+ }
2264
+ ],
2265
+ "test": [
2266
+ {
2267
+ "eval": "document.cookie.includes('eu_cookie={%22opted%22:true%2C%22nonessential%22:false}')"
2268
+ }
2269
+ ]
2270
+ },
2018
2271
  {
2019
2272
  "name": "sibbo",
2020
2273
  "prehideSelectors": [
@@ -2393,6 +2646,40 @@
2393
2646
  }
2394
2647
  ]
2395
2648
  },
2649
+ {
2650
+ "name": "twitter",
2651
+ "runContext": {
2652
+ "urlPattern": "^https://([a-z0-9-]+\\.)?twitter\\.com/"
2653
+ },
2654
+ "prehideSelectors": [
2655
+ "[data-testid=\"BottomBar\"]"
2656
+ ],
2657
+ "detectCmp": [
2658
+ {
2659
+ "exists": "[data-testid=\"BottomBar\"] div"
2660
+ }
2661
+ ],
2662
+ "detectPopup": [
2663
+ {
2664
+ "visible": "[data-testid=\"BottomBar\"] div"
2665
+ }
2666
+ ],
2667
+ "optIn": [
2668
+ {
2669
+ "waitForThenClick": "[data-testid=\"BottomBar\"] > div:has(>div:first-child>div:last-child>span[role=button]) > div:last-child > div[role=button]:first-child"
2670
+ }
2671
+ ],
2672
+ "optOut": [
2673
+ {
2674
+ "waitForThenClick": "[data-testid=\"BottomBar\"] > div:has(>div:first-child>div:last-child>span[role=button]) > div:last-child > div[role=button]:last-child"
2675
+ }
2676
+ ],
2677
+ "TODOtest": [
2678
+ {
2679
+ "eval": "document.cookie.includes('d_prefs=MjoxLGNvbnNlbnRfdmVyc2lvbjoy')"
2680
+ }
2681
+ ]
2682
+ },
2396
2683
  {
2397
2684
  "name": "UK Cookie Consent",
2398
2685
  "prehideSelectors": [
@@ -2520,7 +2807,7 @@
2520
2807
  {
2521
2808
  "name": "vodafone.de",
2522
2809
  "runContext": {
2523
- "url": "https://www.vodafone.de/"
2810
+ "urlPattern": "^https://www\\.vodafone\\.de/"
2524
2811
  },
2525
2812
  "prehideSelectors": [
2526
2813
  ".dip-consent,.dip-consent-container"
@@ -2673,6 +2960,90 @@
2673
2960
  "eval": "document.cookie.includes('userConsent=%7B%22marketing%22%3Afalse')"
2674
2961
  }
2675
2962
  ]
2963
+ },
2964
+ {
2965
+ "name": "youtube-desktop",
2966
+ "prehideSelectors": [
2967
+ "tp-yt-iron-overlay-backdrop.opened",
2968
+ "ytd-consent-bump-v2-lightbox"
2969
+ ],
2970
+ "detectCmp": [
2971
+ {
2972
+ "exists": "ytd-consent-bump-v2-lightbox tp-yt-paper-dialog"
2973
+ },
2974
+ {
2975
+ "exists": "ytd-consent-bump-v2-lightbox tp-yt-paper-dialog a[href^=\"https://consent.youtube.com/\"]"
2976
+ }
2977
+ ],
2978
+ "detectPopup": [
2979
+ {
2980
+ "visible": "ytd-consent-bump-v2-lightbox tp-yt-paper-dialog"
2981
+ }
2982
+ ],
2983
+ "optIn": [
2984
+ {
2985
+ "waitForThenClick": "ytd-consent-bump-v2-lightbox .eom-buttons .eom-button-row:first-child ytd-button-renderer:last-child #button,ytd-consent-bump-v2-lightbox .eom-buttons .eom-button-row:first-child ytd-button-renderer:last-child button"
2986
+ },
2987
+ {
2988
+ "wait": 500
2989
+ }
2990
+ ],
2991
+ "optOut": [
2992
+ {
2993
+ "waitForThenClick": "ytd-consent-bump-v2-lightbox .eom-buttons .eom-button-row:first-child ytd-button-renderer:first-child #button,ytd-consent-bump-v2-lightbox .eom-buttons .eom-button-row:first-child ytd-button-renderer:first-child button"
2994
+ },
2995
+ {
2996
+ "wait": 500
2997
+ }
2998
+ ],
2999
+ "test": [
3000
+ {
3001
+ "wait": 500
3002
+ },
3003
+ {
3004
+ "eval": "!!document.cookie.match(/SOCS=CAE/)"
3005
+ }
3006
+ ]
3007
+ },
3008
+ {
3009
+ "name": "youtube-mobile",
3010
+ "prehideSelectors": [
3011
+ ".consent-bump-v2-lightbox"
3012
+ ],
3013
+ "detectCmp": [
3014
+ {
3015
+ "exists": "ytm-consent-bump-v2-renderer"
3016
+ }
3017
+ ],
3018
+ "detectPopup": [
3019
+ {
3020
+ "visible": "ytm-consent-bump-v2-renderer"
3021
+ }
3022
+ ],
3023
+ "optIn": [
3024
+ {
3025
+ "waitForThenClick": "ytm-consent-bump-v2-renderer .privacy-terms + .one-col-dialog-buttons c3-material-button:first-child button, ytm-consent-bump-v2-renderer .privacy-terms + .one-col-dialog-buttons ytm-button-renderer:first-child button"
3026
+ },
3027
+ {
3028
+ "wait": 500
3029
+ }
3030
+ ],
3031
+ "optOut": [
3032
+ {
3033
+ "waitForThenClick": "ytm-consent-bump-v2-renderer .privacy-terms + .one-col-dialog-buttons c3-material-button:nth-child(2) button, ytm-consent-bump-v2-renderer .privacy-terms + .one-col-dialog-buttons ytm-button-renderer:nth-child(2) button"
3034
+ },
3035
+ {
3036
+ "wait": 500
3037
+ }
3038
+ ],
3039
+ "test": [
3040
+ {
3041
+ "wait": 500
3042
+ },
3043
+ {
3044
+ "eval": "!!document.cookie.match(/SOCS=CAE/)"
3045
+ }
3046
+ ]
2676
3047
  }
2677
3048
  ],
2678
3049
  "consentomatic": {
@@ -1 +1 @@
1
- !function(){"use strict";const e=chrome.runtime.getManifest().manifest_version,t={enabled:!0,autoAction:"optOut",disabledCmps:[],enablePrehide:!0,detectRetries:20},o={};async function s(t){if(2!==e)return chrome.storage.local.set(t);Object.assign(o,t)}async function c(t){return 2===e?o:chrome.storage.local.get(t)}async function n(){const e=await fetch("./rules.json");s({rules:await e.json()})}function r(e,t,o=""){let s="",c="icons/cookie-idle.png";"success"===t?(s=`Opt out successful! (${o})`,c="icons/party.png"):"complete"===t?(s=`Opt out complete! (${o})`,c="icons/tick.png"):"working"===t?(s=`Processing... (${o})`,c="icons/cog.png"):"verified"===t?(s=`Verified (${o})`,c="icons/verified.png"):"idle"===t?(s="Idle",c="icons/cookie-idle.png"):"available"===t&&(s=`Click to opt out (${o})`,c="icons/cookie.png");const n=chrome.action||chrome.pageAction;chrome.pageAction&&chrome.pageAction.show(e),n.setTitle({tabId:e,title:s}),n.setIcon({tabId:e,path:c})}chrome.runtime.onInstalled.addListener((()=>{n()})),2===e&&n(),chrome.runtime.onMessage.addListener((async(n,a)=>{const i=a.tab.id,l=a.frameId,d=(await c("rules")).rules;switch(n.type){case"init":0===l&&r(i,"idle"),chrome.tabs.sendMessage(i,{type:"initResp",rules:d,config:t},{frameId:l});break;case"eval":(async function(t,o,s){return 2===e?new Promise((e=>{chrome.tabs.executeScript(t,{frameId:o,code:`!!window.eval(decodeURIComponent("${encodeURIComponent(s)}"))`},(t=>{e([{result:t,frameId:o}])}))})):chrome.scripting.executeScript({target:{tabId:t,frameIds:[o]},world:"MAIN",args:[s],func:e=>{try{return window.eval(e)}catch(t){return void console.warn("eval error",e,t)}}})})(i,l,n.code).then((([e])=>{chrome.tabs.sendMessage(i,{id:n.id,type:"evalResp",result:e.result},{frameId:l})}));break;case"popupFound":r(i,"available",n.cmp),s({[`detected${i}`]:l});break;case"optOutResult":case"optInResult":n.result&&(r(i,"working",n.cmp),n.scheduleSelfTest&&await s({[`selfTest${i}`]:l}));break;case"selfTestResult":n.result&&r(i,"verified",n.cmp);break;case"autoconsentDone":{r(i,"success",n.cmp);const t=`selfTest${i}`,s=(await chrome.storage.local.get(t))?.[t];"number"==typeof s&&(!async function(t){if(2!==e)return chrome.storage.local.remove(t);delete o[t]}(t),chrome.tabs.sendMessage(i,{type:"selfTest"},{frameId:s}));break}case"autoconsentError":console.error("Error:",n.details)}})),(chrome.action||chrome.pageAction).onClicked.addListener((async e=>{const t=e.id,o=`detected${t}`,s=(await c(o))?.[o];"number"==typeof s&&(chrome.storage.local.remove(o),r(t,"working"),chrome.tabs.sendMessage(t,{type:"optOut"},{frameId:s}))}))}();
1
+ !function(){"use strict";const e=chrome.runtime.getManifest().manifest_version,t={};async function o(o){if(2!==e)return chrome.storage.local.set(o);Object.assign(t,o)}async function a(o){return null===o?2===e?t:await chrome.storage.local.get(null):2===e?t[o]:(await chrome.storage.local.get(o))?.[o]}async function s(o){if(2!==e)return chrome.storage.local.remove(o);delete t[o]}async function n(e,t,o=""){let a="",s="icons/cookie-idle.png";"success"===t?(a=`Opt out successful! (${o})`,s="icons/party.png"):"complete"===t?(a=`Opt out complete! (${o})`,s="icons/tick.png"):"working"===t?(a=`Processing... (${o})`,s="icons/cog.png"):"verified"===t?(a=`Verified (${o})`,s="icons/verified.png"):"idle"===t?(a="Idle",s="icons/cookie-idle.png"):"available"===t&&(a=`Click to opt out (${o})`,s="icons/cookie.png");const n=chrome.action||chrome.pageAction;chrome.pageAction&&chrome.pageAction.show(e),await n.setTitle({tabId:e,title:a}),await n.setIcon({tabId:e,path:s})}async function c(){const e=await fetch("./rules.json");o({rules:await e.json()})}async function i(){console.log("init sw");const e=await a("config");if(console.log("storedConfig",e),!e){console.log("init config");const e={enabled:!0,autoAction:"optOut",disabledCmps:[],enablePrehide:!0,detectRetries:20};await o({config:e})}}chrome.runtime.onInstalled.addListener((()=>{c(),i()})),2===e&&(c(),i()),chrome.tabs.onRemoved.addListener((e=>{s(`detected${e}`)})),chrome.runtime.onMessage.addListener((async(t,c)=>{const i=c.tab.id,r=c.frameId,l=await a("rules"),d=await a("config");switch(t.type){case"init":0===r&&await n(i,"idle"),chrome.tabs.sendMessage(i,{type:"initResp",rules:l,config:d},{frameId:r});break;case"eval":(async function(t,o,a){return 2===e?new Promise((e=>{chrome.tabs.executeScript(t,{frameId:o,code:`!!window.eval(decodeURIComponent("${encodeURIComponent(a)}"))`},(t=>{e([{result:t[0],frameId:o}])}))})):chrome.scripting.executeScript({target:{tabId:t,frameIds:[o]},world:"MAIN",args:[a],func:e=>{try{return window.eval(e)}catch(t){return void console.warn("eval error",e,t)}}})})(i,r,t.code).then((([e])=>{chrome.tabs.sendMessage(i,{id:t.id,type:"evalResp",result:e.result},{frameId:r})}));break;case"popupFound":await n(i,"available",t.cmp),o({[`detected${i}`]:r});break;case"optOutResult":case"optInResult":t.result&&(await n(i,"working",t.cmp),t.scheduleSelfTest&&await o({[`selfTest${i}`]:r}));break;case"selfTestResult":t.result&&await n(i,"verified",t.cmp);break;case"autoconsentDone":{await n(i,"success",t.cmp);const e=`selfTest${i}`,o=(await chrome.storage.local.get(e))?.[e];"number"==typeof o&&(s(e),chrome.tabs.sendMessage(i,{type:"selfTest"},{frameId:o}));break}case"autoconsentError":console.error("Error:",t.details)}})),2===e&&chrome.pageAction.onClicked.addListener((async e=>{const t=e.id,o=`detected${t}`,c=await a(o);"number"==typeof c&&(s(o),await n(t,"working"),chrome.tabs.sendMessage(t,{type:"optOut"},{frameId:c}))}))}();