@duckduckgo/autoconsent 1.0.8 → 2.1.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 (182) hide show
  1. package/.eslintrc.cjs +14 -0
  2. package/.vscode/.idea/.vscode.iml +9 -0
  3. package/.vscode/.idea/modules.xml +8 -0
  4. package/.vscode/.idea/workspace.xml +28 -0
  5. package/.vscode/settings.json +7 -0
  6. package/Jenkinsfile +68 -39
  7. package/api.md +104 -0
  8. package/dist/addon-firefox/background.bundle.js +1 -0
  9. package/dist/addon-firefox/content.bundle.js +1 -0
  10. package/dist/addon-firefox/icons/cog.png +0 -0
  11. package/dist/addon-firefox/icons/cookie-idle.png +0 -0
  12. package/dist/addon-firefox/icons/cookie.png +0 -0
  13. package/dist/addon-firefox/icons/party.png +0 -0
  14. package/dist/addon-firefox/icons/tick.png +0 -0
  15. package/dist/addon-firefox/icons/verified.png +0 -0
  16. package/dist/addon-firefox/manifest.json +32 -0
  17. package/dist/addon-firefox/rules.json +4167 -0
  18. package/dist/addon-mv3/background.bundle.js +1 -0
  19. package/dist/addon-mv3/content.bundle.js +1 -0
  20. package/dist/addon-mv3/icons/cog.png +0 -0
  21. package/dist/addon-mv3/icons/cookie-idle.png +0 -0
  22. package/dist/addon-mv3/icons/cookie.png +0 -0
  23. package/dist/addon-mv3/icons/party.png +0 -0
  24. package/dist/addon-mv3/icons/tick.png +0 -0
  25. package/dist/addon-mv3/icons/verified.png +0 -0
  26. package/dist/addon-mv3/manifest.json +34 -0
  27. package/dist/addon-mv3/rules.json +4167 -0
  28. package/dist/autoconsent.cjs.js +1 -1387
  29. package/dist/autoconsent.esm.js +1 -1379
  30. package/dist/autoconsent.playwright.js +1 -0
  31. package/lib/cmps/all.ts +15 -10
  32. package/lib/cmps/base.ts +95 -90
  33. package/lib/cmps/consentmanager.ts +31 -19
  34. package/lib/cmps/consentomatic.ts +89 -0
  35. package/lib/cmps/cookiebot.ts +58 -55
  36. package/lib/cmps/evidon.ts +29 -18
  37. package/lib/cmps/onetrust.ts +32 -20
  38. package/lib/cmps/sourcepoint-frame.ts +104 -0
  39. package/lib/cmps/sourcepoint-top.ts +47 -0
  40. package/lib/cmps/trustarc-frame.ts +115 -0
  41. package/lib/cmps/trustarc-top.ts +97 -0
  42. package/lib/consentomatic/index.ts +233 -70
  43. package/lib/{web/consentomatic → consentomatic}/tools.ts +0 -0
  44. package/lib/eval-handler.ts +58 -0
  45. package/lib/index.ts +0 -2
  46. package/lib/messages.ts +100 -0
  47. package/lib/rule-executors.ts +108 -0
  48. package/lib/rules.ts +82 -0
  49. package/lib/types.ts +35 -0
  50. package/lib/utils.ts +64 -0
  51. package/lib/web.ts +288 -74
  52. package/package.json +20 -16
  53. package/playwright/content.ts +21 -0
  54. package/playwright/runner.ts +162 -0
  55. package/playwright.config.ts +7 -0
  56. package/readme.md +61 -47
  57. package/rollup.config.js +38 -16
  58. package/rules/autoconsent/ausopen.json +2 -1
  59. package/rules/autoconsent/baden-wuerttemberg-de.json +7 -3
  60. package/rules/autoconsent/bundesregierung-de.json +5 -1
  61. package/rules/autoconsent/cc-banner.json +0 -1
  62. package/rules/autoconsent/cookie-law-info.json +1 -1
  63. package/rules/autoconsent/cookie-notice.json +1 -2
  64. package/rules/autoconsent/cookieconsent.json +5 -6
  65. package/rules/autoconsent/destatis-de.json +2 -2
  66. package/rules/autoconsent/dunelm.json +1 -1
  67. package/rules/autoconsent/etsy.json +4 -3
  68. package/rules/autoconsent/eu-cookie-compliance.json +0 -1
  69. package/rules/autoconsent/hl-co-uk.json +8 -9
  70. package/rules/autoconsent/johnlewis.json +5 -2
  71. package/rules/autoconsent/marksandspencer.json +2 -1
  72. package/rules/autoconsent/mediamarkt-de.json +1 -1
  73. package/rules/autoconsent/microsoft.json +1 -1
  74. package/rules/autoconsent/notice-cookie.json +0 -1
  75. package/rules/autoconsent/osano.json +4 -2
  76. package/rules/autoconsent/snigel.json +2 -1
  77. package/rules/autoconsent/tealium.json +4 -5
  78. package/rules/autoconsent/thefreedictionary.json +1 -1
  79. package/rules/rules.json +79 -45
  80. package/tests/192.spec.ts +1 -1
  81. package/tests/arzt-auskunft.spec.ts +1 -1
  82. package/tests/asus.spec.ts +1 -1
  83. package/tests/ausopen.spec.ts +1 -1
  84. package/tests/aws.amazon.spec.ts +1 -1
  85. package/tests/baden-wuerttemberg.spec.ts +1 -1
  86. package/tests/borlabs.spec.ts +1 -1
  87. package/tests/bundesregierung.spec.ts +5 -2
  88. package/tests/ccbanner.spec.ts +1 -1
  89. package/tests/consentmanager.spec.ts +3 -3
  90. package/tests/cookiebot.spec.ts +8 -2
  91. package/tests/cookieconsent.spec.ts +1 -1
  92. package/tests/cookielawinfo.spec.ts +1 -1
  93. package/tests/cookienotice.spec.ts +1 -1
  94. package/tests/corona-in-zahlen.spec.ts +1 -1
  95. package/tests/deepl.spec.ts +1 -1
  96. package/tests/destatis.spec.ts +1 -1
  97. package/tests/didomi.spec.ts +7 -3
  98. package/tests/drupal.spec.ts +8 -0
  99. package/tests/dunelm.spec.ts +1 -1
  100. package/tests/etsy.spec.ts +1 -1
  101. package/tests/eu-cookie-compliance-banner.spec.ts +1 -1
  102. package/tests/evidon.spec.ts +7 -2
  103. package/tests/fundingchoices.spec.ts +2 -1
  104. package/tests/gov-uk.spec.ts +1 -1
  105. package/tests/hl-co-uk.spec.ts +1 -1
  106. package/tests/hubspot.spec.ts +1 -1
  107. package/tests/ionos.spec.ts +1 -1
  108. package/tests/johnlewis.spec.ts +2 -2
  109. package/tests/klaro.spec.ts +1 -1
  110. package/tests/marksandspencer.spec.ts +1 -1
  111. package/tests/mediamarkt.spec.ts +1 -1
  112. package/tests/metoffice-gov-uk.spec.ts +1 -1
  113. package/tests/microsoft.spec.ts +1 -1
  114. package/tests/moneysavingexpert.spec.ts +1 -1
  115. package/tests/motor-talk.spec.ts +1 -1
  116. package/tests/national-lottery.spec.ts +1 -1
  117. package/tests/netflix.spec.ts +1 -1
  118. package/tests/nhs.spec.ts +1 -1
  119. package/tests/notice-cookie.spec.ts +1 -1
  120. package/tests/obi.spec.ts +1 -1
  121. package/tests/oil.spec.ts +2 -2
  122. package/tests/onetrust.spec.ts +27 -2
  123. package/tests/osano.spec.ts +1 -1
  124. package/tests/otto.spec.ts +1 -1
  125. package/tests/paypal.spec.ts +1 -1
  126. package/tests/quantcast.spec.ts +5 -2
  127. package/tests/snigel.spec.ts +1 -1
  128. package/tests/sourcepoint.spec.ts +8 -8
  129. package/tests/springer.spec.ts +2 -2
  130. package/tests/steampowered.spec.ts +1 -1
  131. package/tests/tealium.spec.ts +1 -1
  132. package/tests/testcmp.spec.ts +1 -1
  133. package/tests/thalia.spec.ts +1 -1
  134. package/tests/thefreedictionary.spec.ts +1 -1
  135. package/tests/trustarc.spec.ts +26 -4
  136. package/tests/usercentrics-1.spec.ts +1 -1
  137. package/tests/uswitch.spec.ts +1 -1
  138. package/tests/vodafone.spec.ts +1 -1
  139. package/tests/waitrose.spec.ts +1 -1
  140. package/tests/wetransfer.spec.ts +1 -1
  141. package/tests/wordpressgdpr.spec.ts +2 -2
  142. package/tests/xing.spec.ts +1 -1
  143. package/tsconfig.json +2 -2
  144. package/update_version.js +10 -6
  145. package/.eslintrc +0 -12
  146. package/cosmetics/rules.json +0 -110
  147. package/dist/autoconsent.puppet.js +0 -1078
  148. package/lib/cmps/all.js +0 -19
  149. package/lib/cmps/base.js +0 -174
  150. package/lib/cmps/consentmanager.js +0 -31
  151. package/lib/cmps/cookiebot.js +0 -77
  152. package/lib/cmps/evidon.js +0 -26
  153. package/lib/cmps/onetrust.js +0 -34
  154. package/lib/cmps/sourcepoint.js +0 -82
  155. package/lib/cmps/sourcepoint.ts +0 -95
  156. package/lib/cmps/trustarc.js +0 -106
  157. package/lib/cmps/trustarc.ts +0 -147
  158. package/lib/config.js +0 -1
  159. package/lib/consentomatic/index.js +0 -52
  160. package/lib/detector.js +0 -33
  161. package/lib/detector.ts +0 -34
  162. package/lib/hider.js +0 -13
  163. package/lib/hider.ts +0 -16
  164. package/lib/index.js +0 -4
  165. package/lib/messages.d.ts +0 -61
  166. package/lib/node.js +0 -35
  167. package/lib/node.ts +0 -43
  168. package/lib/puppet/tab.js +0 -121
  169. package/lib/puppet/tab.ts +0 -146
  170. package/lib/rules.d.ts +0 -80
  171. package/lib/tabwrapper.js +0 -67
  172. package/lib/tabwrapper.ts +0 -74
  173. package/lib/types.d.ts +0 -61
  174. package/lib/web/consentomatic/index.ts +0 -249
  175. package/lib/web/content-utils.js +0 -29
  176. package/lib/web/content-utils.ts +0 -31
  177. package/lib/web/content.js +0 -89
  178. package/lib/web/content.ts +0 -80
  179. package/lib/web/tab.js +0 -112
  180. package/lib/web/tab.ts +0 -178
  181. package/lib/web.js +0 -95
  182. package/tests/runner.ts +0 -61
package/.eslintrc.cjs ADDED
@@ -0,0 +1,14 @@
1
+ module.exports = {
2
+ root: true,
3
+ parser: '@typescript-eslint/parser',
4
+ plugins: [
5
+ '@typescript-eslint',
6
+ ],
7
+ extends: [
8
+ 'eslint:recommended',
9
+ 'plugin:@typescript-eslint/recommended',
10
+ ],
11
+ rules: {
12
+ "@typescript-eslint/no-explicit-any": 0,
13
+ }
14
+ }
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="JAVA_MODULE" version="4">
3
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
4
+ <exclude-output />
5
+ <content url="file://$MODULE_DIR$" />
6
+ <orderEntry type="inheritedJdk" />
7
+ <orderEntry type="sourceFolder" forTests="false" />
8
+ </component>
9
+ </module>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/.vscode.iml" filepath="$PROJECT_DIR$/.idea/.vscode.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
@@ -0,0 +1,28 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ChangeListManager">
4
+ <list default="true" id="99ee5571-0798-405c-aadc-38787e5ffeae" name="Changes" comment="" />
5
+ <option name="SHOW_DIALOG" value="false" />
6
+ <option name="HIGHLIGHT_CONFLICTS" value="true" />
7
+ <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
8
+ <option name="LAST_RESOLUTION" value="IGNORE" />
9
+ </component>
10
+ <component name="ComposerSettings">
11
+ <execution />
12
+ </component>
13
+ <component name="ProjectId" id="2BnSmTbTSSSfKVNp3H2qm1ykPtn" />
14
+ <component name="PropertiesComponent"><![CDATA[{
15
+ "keyToString": {
16
+ "RunOnceActivity.go.formatter.settings.were.checked": "true",
17
+ "RunOnceActivity.go.migrated.go.modules.settings": "true",
18
+ "go.import.settings.migrated": "true"
19
+ }
20
+ }]]></component>
21
+ <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
22
+ <component name="TypeScriptGeneratedFilesManager">
23
+ <option name="version" value="3" />
24
+ </component>
25
+ <component name="VgoProject">
26
+ <settings-migrated>true</settings-migrated>
27
+ </component>
28
+ </project>
@@ -0,0 +1,7 @@
1
+ {
2
+ "eslint.format.enable": true,
3
+ "eslint.validate": [
4
+ "typescript"
5
+ ],
6
+ "editor.tabSize": 2,
7
+ }
package/Jenkinsfile CHANGED
@@ -1,50 +1,79 @@
1
- properties([
2
- parameters([
3
- choice(name: 'CHANNEL', defaultValue: 'staging', choices: 'staging\nproduction')
4
- ]),
5
- ])
6
-
7
- node('docker && !gpu') {
8
-
9
- def img
10
- def commitHash
1
+ def runPlaywrightTests(resultDir) {
2
+ sh 'mkdir -p ./test-results'
3
+ sh """
4
+ PLAYWRIGHT_JUNIT_OUTPUT_NAME=results.xml npx playwright test --project webkit --reporter=junit || true
5
+ """
6
+ junit 'results.xml'
7
+ sh """
8
+ mkdir -p ${resultDir}/results/${BRANCH_NAME}/${BUILD_NUMBER}/$REGION/
9
+ mkdir -p ./test-results
10
+ mv ./test-results/ ${resultDir}/results/${BRANCH_NAME}/${BUILD_NUMBER}/$REGION/
11
+ """
12
+ }
11
13
 
12
- stage('Checkout') {
13
- checkout scm
14
- commitHash = sh(returnStdout: true, script: 'git log --pretty=format:\'%h\' -n 1').trim()
15
- currentBuild.description = "${commitHash}-${params.CHANNEL}"
14
+ def withEnvFile(envfile, Closure cb) {
15
+ def props = readProperties(file: envfile)
16
+ withEnv(props.collect{ entry -> "${entry.key}=${entry.value}" }) {
17
+ cb()
16
18
  }
19
+ }
17
20
 
18
- stage('Build Docker Image') {
19
- img = docker.build('autoconsent/build')
21
+ pipeline {
22
+ agent { label 'crawler-worker' }
23
+ parameters {
24
+ string(name: 'TEST_RESULT_ROOT', defaultValue: '/mnt/efs/users/smacbeth/autoconsent/ci', description: 'Where test results and configuration are stored')
20
25
  }
21
-
22
- img.inside() {
23
-
26
+ environment {
27
+ NODENV_VERSION = "14.15.4"
28
+ NODENV_ROOT = "/opt/nodeenv"
29
+ PATH = "/opt/nodenv/shims:/opt/nodenv/bin:$PATH"
30
+ }
31
+ stages {
32
+ stage('Checkout') {
33
+ steps {
34
+ checkout scm
35
+ }
36
+ }
37
+
24
38
  stage('Build') {
25
- sh 'cp -r /app/node_modules ./'
26
- sh 'npm run bundle'
39
+ steps {
40
+ sh '''
41
+ npm ci
42
+ npx playwright install webkit
43
+ '''
44
+ }
27
45
  }
28
-
29
- stage('Build rules') {
30
- sh 'node rules/build.js'
31
- sh 'rm -f rules/rules.min.*'
32
- sh "jq -c '. + { version: \"${commitHash}\" }' rules/rules.json > rules/rules.min.json"
33
- sh 'brotli --input rules/rules.min.json --output rules/rules.min.json.br'
34
- sh "gzip -9 rules/rules.min.json"
46
+
47
+ stage('Test: DE') {
48
+ steps {
49
+ withEnvFile("${params.TEST_RESULT_ROOT}/de.env") {
50
+ runPlaywrightTests(params.TEST_RESULT_ROOT)
51
+ }
52
+ }
35
53
  }
36
- }
37
-
38
- if (env.BRANCH_NAME == 'master') {
39
- stage('Publish') {
40
- sh "aws s3 cp rules/rules.min.json.br s3://cdn.cliqz.com/autoconsent/rules/${commitHash}.json.br --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-encoding br --content-type application/json --cache-control \"immutable\""
41
- sh "aws s3 cp rules/rules.min.json.gz s3://cdn.cliqz.com/autoconsent/rules/${commitHash}.json.gz --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-encoding gzip --content-type application/json --cache-control \"immutable\""
42
- sh "echo '{\"ruleVersion\":\"${commitHash}\",\"disabled\":[]}' > config.json"
43
- def fileName = 'config.json'
44
- if (params.CHANNEL == 'staging') {
45
- fileName = 'staging-config.json'
54
+
55
+ stage('Test: US') {
56
+ steps {
57
+ withEnvFile("${params.TEST_RESULT_ROOT}/us.env") {
58
+ runPlaywrightTests(params.TEST_RESULT_ROOT)
59
+ }
60
+ }
61
+ }
62
+
63
+ stage('Test: GB') {
64
+ steps {
65
+ withEnvFile("${params.TEST_RESULT_ROOT}/gb.env") {
66
+ runPlaywrightTests(params.TEST_RESULT_ROOT)
67
+ }
68
+ }
69
+ }
70
+
71
+ stage('Test: FR') {
72
+ steps {
73
+ withEnvFile("${params.TEST_RESULT_ROOT}/fr.env") {
74
+ runPlaywrightTests(params.TEST_RESULT_ROOT)
75
+ }
46
76
  }
47
- sh "aws s3 cp config.json s3://cdn.cliqz.com/autoconsent/${fileName} --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-type application/json --cache-control \"max-age=3600\""
48
77
  }
49
78
  }
50
79
  }
package/api.md ADDED
@@ -0,0 +1,104 @@
1
+ # API
2
+
3
+ ## Content script
4
+ Most of autoconsent logic is contained in a content script that should be injected into every page. However, the high-level orchestration is controlled externally by a background service worker (in case of a web extension), or a native browser integration. Autoconsent sends and receives messages to the background worker using provided callables which mimic postMessage API:
5
+
6
+ ```typescript
7
+ const consent = new AutoConsent( // make sure not to leak anything to the page globals
8
+ chrome.runtime.sendMessage, // pass a function to send messages to the background worker
9
+ { // optionally, pass a config object
10
+ enabled: true,
11
+ autoAction: 'optOut',
12
+ disabledCmps: [],
13
+ enablePrehide: true,
14
+ detectRetries: 20,
15
+ },
16
+ { // optionally, pass JSON rules
17
+ autoconsent: [ ... ],
18
+ consentomatic: [ ... ],
19
+ }
20
+ );
21
+
22
+ // connect .receiveMessageCallback() to a platform-specific message receiver
23
+ chrome.runtime.onMessage.addListener((message: BackgroundMessage) => {
24
+ return Promise.resolve(
25
+ consent.receiveMessageCallback(message)
26
+ );
27
+ });
28
+ ```
29
+
30
+ ## Messaging API
31
+
32
+ For concrete message format, refer to [messages.ts](/lib/messages.ts).
33
+
34
+ The overall workflow is described below:
35
+
36
+ ```mermaid
37
+
38
+ sequenceDiagram
39
+ participant BG as Browser (e.g. background service worker)
40
+ participant CS as Autoconsent content script in page (isolated) world
41
+
42
+ Note over BG: Fetch declarative JSON rules and user settings
43
+ Note over CS: Autoconsent class is instantiated.<br/>Optionally, initConfig is passed to constructor
44
+
45
+ CS -->>+ BG: (if initConfig is not passed already)<br/>init
46
+ BG -->>- CS: initResp<br/>(contains user settings and JSON rules)
47
+
48
+ activate CS
49
+ Note right of CS: Parse rules and initialize autoconsent code
50
+ Note right of CS: apply prehideSelectors
51
+ Note right of CS: wait for DOMContentLoaded
52
+ Note right of CS: detect a CMP presence (not necessarily visible)
53
+
54
+ CS ->> BG: cmpDetected
55
+ Note right of CS: detect a visible cookie popup
56
+ CS ->> BG: popupFound
57
+ deactivate CS
58
+ activate BG
59
+ alt if config.autoAction is NOT defined
60
+ Note left of BG: decide when to trigger opt-in / opt-out
61
+ BG -->> CS: optIn / optOut
62
+ else if config.autoAction IS defined
63
+ Note right of CS: <br/>proceed immediately
64
+ end
65
+
66
+ deactivate BG
67
+
68
+ Note right of CS: execute opt-in / opt-out rules
69
+ CS ->> BG: optOutResult / optInResult
70
+
71
+ opt if not intermediate ruleset
72
+ CS ->> BG: autoconsentDone
73
+ end
74
+
75
+ opt optional
76
+ BG -->>+ CS: (optional) selfTest
77
+ Note right of CS: execute self-test rules
78
+ CS -->>- BG: selfTestResult
79
+ end
80
+ ```
81
+
82
+ ### Asynchronous eval rules
83
+
84
+ Some rulesets rely on [eval rules](/readme.md#eval) executed in page main context. Since the content script lives in an isolated world, it passes those calls to the more powerful background worker.
85
+
86
+ **Warning**: eval rules are potentially dangerous and should be avoided when possible.
87
+
88
+ ```mermaid
89
+ sequenceDiagram
90
+ participant P as Page main world
91
+ participant BG as Browser (e.g. background service worker)
92
+ participant CS as Autoconsent content script in page (isolated) world
93
+
94
+ Note over CS: Needs to evaluate <PAYLOAD> in the main world (e.g. interact with API)
95
+
96
+ CS ->> BG: { type: "eval", id: <UUID>, code: <PAYLOAD> }
97
+ activate BG
98
+ BG ->>+ P: evaluate <PAYLOAD> using platform-specific APIs<br/>e.g. chrome.scripting.executeScript()
99
+ P ->>- BG: evaluation <RESULT>
100
+ BG ->> CS: { type: "evalResp", id: <UUID>, result: <RESULT> }
101
+ deactivate BG
102
+
103
+ Note over CS: Continue rule execution (or fail with timeout)
104
+ ```
@@ -0,0 +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){let o="",s="icons/cookie-idle.png";"success"===t?(o="Opt out successful!",s="icons/party.png"):"complete"===t?(o="Opt out complete!",s="icons/tick.png"):"working"===t?(o="Processing...",s="icons/cog.png"):"verified"===t?(o="Verified",s="icons/verified.png"):"idle"===t?(o="Idle",s="icons/cookie-idle.png"):"available"===t&&(o="Click to opt out",s="icons/cookie.png");const c=chrome.action||chrome.pageAction;chrome.pageAction&&chrome.pageAction.show(e),c.setTitle({tabId:e,title:o}),c.setIcon({tabId:e,path:s})}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(e){return}}})})(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"),s({[`detected${i}`]:l});break;case"optOutResult":case"optInResult":n.result&&(r(i,"working"),n.scheduleSelfTest&&await s({[`selfTest${i}`]:l}));break;case"selfTestResult":n.result&&r(i,"verified");break;case"autoconsentDone":{r(i,"success");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}))}))}();
@@ -0,0 +1 @@
1
+ !function(){"use strict";class e{constructor(e,t=1e3){this.id=e,this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t})),this.timer=window.setTimeout((()=>{this.reject(new Error("timeout"))}),t)}}const t={pending:new Map,sendContentMessage:null};function n(e="autoconsent-css-rules"){const t=`style#${e}`,n=document.querySelector(t);if(n&&n instanceof HTMLStyleElement)return n;{const t=document.head||document.getElementsByTagName("head")[0]||document.documentElement,n=document.createElement("style");return n.id=e,t.appendChild(n),n}}function o(e,t,n="display"){const o="opacity"===n?"opacity: 0":"display: none",s=`${t.join(",")} { ${o} !important; z-index: -1 !important; pointer-events: none !important; } `;return e instanceof HTMLStyleElement&&(e.innerText+=s,t.length>0)}async function s(e,t,n){const o=await e();return!o&&t>0?new Promise((o=>{setTimeout((async()=>{o(s(e,t-1,n))}),n)})):Promise.resolve(o)}function i(n){return function(n){let o;o=crypto&&void 0!==crypto.randomUUID?crypto.randomUUID():Math.random().toString(),t.sendContentMessage({type:"eval",id:o,code:n});const s=new e(o);return t.pending.set(s.id,s),s.promise}(n).catch((e=>!1))}function r(e,t=!1){const n=document.querySelectorAll(e);return n.length>0&&(t?n.forEach((e=>e.click())):n[0].click()),n.length>0}function a(e){return null!==document.querySelector(e)}function c(e,t){const n=document.querySelectorAll(e),o=new Array(n.length);return n.forEach(((e,t)=>{o[t]=function(e){if(!e)return!1;if(null!==e.offsetParent)return!0;{const t=window.getComputedStyle(e);if("fixed"===t.position&&"none"!==t.display)return!0}return!1}(e)})),0!==o.length&&("any"===t?o.some((e=>e)):"none"===t?o.every((e=>!e)):o.every((e=>e)))}function u(e,t=1e4){return s((()=>null!==document.querySelector(e)),Math.ceil(t/200),200)}function l(e){return new Promise((t=>{setTimeout((()=>{t(!0)}),e)}))}function d(){const e=n("autoconsent-prehide");return e&&e.remove(),!!e}const p={main:!0,frame:!1,url:""};class h{constructor(e){this.runContext=p,this.name=e}get hasSelfTest(){throw new Error("Not Implemented")}get isIntermediate(){throw new Error("Not Implemented")}checkRunContext(){const e={...p,...this.runContext},t=window.top===window;return!(t&&!e.main)&&(!(!t&&!e.frame)&&!(e.url&&!window.location.href.startsWith(e.url)))}detectCmp(){throw new Error("Not Implemented")}async detectPopup(){return!1}optOut(){throw new Error("Not Implemented")}optIn(){throw new Error("Not Implemented")}openCmp(){throw new Error("Not Implemented")}async test(){return Promise.resolve(!0)}}async function m(e){const t=[];if(e.exists&&t.push(a(e.exists)),e.visible&&t.push(c(e.visible,e.check)),e.eval){const n=i(e.eval);t.push(n)}var d,p;if(e.waitFor&&t.push(u(e.waitFor,e.timeout)),e.waitForVisible&&t.push(function(e,t=1e4,n="any"){return s((()=>c(e,n)),Math.ceil(t/200),200)}(e.waitForVisible,e.timeout,e.check)),e.click&&t.push(r(e.click,e.all)),e.waitForThenClick&&t.push(async function(e,t=1e4,n=!1){return await u(e,t),r(e,n)}(e.waitForThenClick,e.timeout,e.all)),e.wait&&t.push(l(e.wait)),e.hide&&t.push((d=e.hide,p=e.method,o(n(),d,p))),0===t.length)return!1;return(await Promise.all(t)).reduce(((e,t)=>e&&t),!0)}class f extends h{constructor(e){super(e.name),this.config=e,this.runContext=e.runContext||p}get hasSelfTest(){return!!this.config.test}get isIntermediate(){return!!this.config.intermediate}get prehideSelectors(){return this.config.prehideSelectors}async _runRulesParallel(e){const t=e.map((e=>m(e)));return(await Promise.all(t)).every((e=>!!e))}async _runRulesSequentially(e){for(const t of e){if(!await m(t)&&!t.optional)return!1}return!0}async detectCmp(){return!!this.config.detectCmp&&this._runRulesParallel(this.config.detectCmp)}async detectPopup(){return!!this.config.detectPopup&&this._runRulesParallel(this.config.detectPopup)}async optOut(){return!!this.config.optOut&&this._runRulesSequentially(this.config.optOut)}async optIn(){return!!this.config.optIn&&this._runRulesSequentially(this.config.optIn)}async openCmp(){return!!this.config.openCmp&&this._runRulesSequentially(this.config.openCmp)}async test(){return this.hasSelfTest?this._runRulesSequentially(this.config.test):super.test()}}const w="#truste-show-consent",y="#truste-consent-track";const g=[new class extends h{constructor(){super("TrustArc-top"),this.prehideSelectors=[".trustarc-banner-container",`.truste_popframe,.truste_overlay,.truste_box_overlay,${y}`],this.runContext={main:!0,frame:!1},this._shortcutButton=null,this._optInDone=!1}get hasSelfTest(){return!1}get isIntermediate(){return!this._optInDone&&!this._shortcutButton}async detectCmp(){const e=a(`#truste-show-consent,${y}`);return e&&(this._shortcutButton=document.querySelector("#truste-consent-required")),e}async detectPopup(){return c(`#truste-consent-content,#trustarc-banner-overlay,${y}`,"all")}openFrame(){r(w)}async optOut(){return this._shortcutButton?(this._shortcutButton.click(),!0):(o(n(),[".truste_popframe",".truste_overlay",".truste_box_overlay",y]),r(w),setTimeout((()=>{n().remove()}),1e4),!0)}async optIn(){return this._optInDone=!0,r("#truste-consent-button")}async openCmp(){return!0}async test(){return!0}},new class extends h{constructor(){super("TrustArc-frame"),this.runContext={main:!1,frame:!0,url:"https://consent-pref.trustarc.com/?"}}get hasSelfTest(){return!1}get isIntermediate(){return!1}async detectCmp(){return!0}async detectPopup(){return c("#defaultpreferencemanager","any")&&c(".mainContent","any")}async navigateToSettings(){return await s((async()=>a(".shp")||c(".advance","any")||a(".switch span:first-child")),10,500),a(".shp")&&r(".shp"),await u(".prefPanel",5e3),c(".advance","any")&&r(".advance"),await s((()=>c(".switch span:first-child","any")),5,1e3)}async optOut(){return await s((()=>"complete"===document.readyState),20,100),await u(".mainContent[aria-hidden=false]",5e3),!!r(".rejectAll")||(a(".prefPanel")&&await u('.prefPanel[style="visibility: visible;"]',3e3),r("#catDetails0")?(r(".submit"),!0):(r(".required")||(await this.navigateToSettings(),r(".switch span:nth-child(1):not(.active)",!0),r(".submit"),u("#gwt-debug-close_id",3e5).then((()=>{r("#gwt-debug-close_id")}))),!0))}async optIn(){return await this.navigateToSettings(),r(".switch span:nth-child(2)",!0),r(".submit"),u("#gwt-debug-close_id",3e5).then((()=>{r("#gwt-debug-close_id")})),!0}},new class extends h{constructor(){super("Cybotcookiebot"),this.prehideSelectors=["#CybotCookiebotDialog,#dtcookie-container,#cookiebanner,#cb-cookieoverlay"]}get hasSelfTest(){return!0}get isIntermediate(){return!1}async detectCmp(){return a("#CybotCookiebotDialogBodyLevelButtonPreferences")}async detectPopup(){return a("#CybotCookiebotDialog,#dtcookie-container,#cookiebanner,#cb-cookiebanner")}async optOut(){return r(".cookie-alert-extended-detail-link")?(await u(".cookie-alert-configuration",2e3),r(".cookie-alert-configuration-input:checked",!0),r(".cookie-alert-extended-button-secondary"),!0):a("#dtcookie-container")?r(".h-dtcookie-decline"):(r(".cookiebot__button--settings")||r("#CybotCookiebotDialogBodyButtonDecline")||(r(".cookiebanner__link--details"),r('.CybotCookiebotDialogBodyLevelButton:checked:enabled,input[id*="CybotCookiebotDialogBodyLevelButton"]:checked:enabled',!0),r("#CybotCookiebotDialogBodyButtonDecline"),r("input[id^=CybotCookiebotDialogBodyLevelButton]:checked",!0),a("#CybotCookiebotDialogBodyButtonAcceptSelected")?r("#CybotCookiebotDialogBodyButtonAcceptSelected"):r("#CybotCookiebotDialogBodyLevelButtonAccept,#CybotCookiebotDialogBodyButtonAccept,#CybotCookiebotDialogBodyLevelButtonLevelOptinAllowallSelection",!0),await i("window.CookieConsent.hasResponse !== true")&&(await i("window.Cookiebot.dialog.submitConsent()"),await l(500)),a("#cb-confirmedSettings")&&await i("endCookieProcess()")),!0)}async optIn(){return a("#dtcookie-container")?r(".h-dtcookie-accept"):(r(".CybotCookiebotDialogBodyLevelButton:not(:checked):enabled",!0),r("#CybotCookiebotDialogBodyLevelButtonAccept"),r("#CybotCookiebotDialogBodyButtonAccept"),!0)}async test(){return i("window.CookieConsent.declined === true")}},new class extends h{constructor(){super("Sourcepoint-top"),this.prehideSelectors=["div[id^='sp_message_container_'],.message-overlay"],this.runContext={main:!0,frame:!1}}get hasSelfTest(){return!0}get isIntermediate(){return!0}async detectCmp(){return a("div[id^='sp_message_container_']")}async detectPopup(){return c("div[id^='sp_message_container_']","all")}async optIn(){return!0}async optOut(){return!0}async test(){return await i("__tcfapi('getTCData', 2, r => window.__rcsResult = r)"),await i("Object.values(window.__rcsResult.purpose.consents).every(c => !c)")}},new class extends h{constructor(){super("Sourcepoint-frame"),this.ccpaMode=!1,this.runContext={main:!1,frame:!0}}get hasSelfTest(){return!1}get isIntermediate(){return!1}async detectCmp(){const e=new URL(location.href);return e.searchParams.has("message_id")&&"ccpa-notice.sp-prod.net"===e.hostname?(this.ccpaMode=!0,!0):("/index.html"===e.pathname||"/privacy-manager/index.html"===e.pathname)&&e.searchParams.has("message_id")&&e.searchParams.has("requestUUID")}async detectPopup(){return!0}async optIn(){return await u(".sp_choice_type_11,.sp_choice_type_ACCEPT_ALL",2e3),!!r(".sp_choice_type_11")||!!r(".sp_choice_type_ACCEPT_ALL")}isManagerOpen(){return"/privacy-manager/index.html"===new URL(location.href).pathname}async optOut(){if(!this.isManagerOpen()){if(!await u("button.sp_choice_type_12,button.sp_choice_type_13"))return!1;if(!a("button.sp_choice_type_12"))return r("button.sp_choice_type_13");r("button.sp_choice_type_12"),await s((()=>"/privacy-manager/index.html"===location.pathname),200,100)}await u(".type-modal",2e4);try{const e=".sp_choice_type_REJECT_ALL",t=".reject-toggle",n=await Promise.race([u(e,2e3).then((e=>e?0:-1)),u(t,2e3).then((e=>e?1:-1)),u(".pm-features",2e3).then((e=>e?2:-1))]);if(0===n)return await l(1e3),r(e);if(1===n)return r(t);2===n&&(await u(".pm-features",1e4),r(".checked > span",!0),r(".chevron"))}catch(e){}return r(".sp_choice_type_SAVE_AND_EXIT")}},new class extends h{constructor(){super("consentmanager.net"),this.prehideSelectors=["#cmpbox,#cmpbox2"]}get hasSelfTest(){return!1}get isIntermediate(){return!1}async detectCmp(){return a("#cmpbox")}async detectPopup(){return c("#cmpbox .cmpmore","any")}async optOut(){return!!r(".cmpboxbtnno")||(a(".cmpwelcomeprpsbtn")?(r(".cmpwelcomeprpsbtn > a[aria-checked=true]",!0),r(".cmpboxbtnsave"),!0):(r(".cmpboxbtncustom"),await u(".cmptblbox",2e3),r(".cmptdchoice > a[aria-checked=true]",!0),r(".cmpboxbtnyescustomchoices"),!0))}async optIn(){return r(".cmpboxbtnyes")}},new class extends h{constructor(){super("Evidon")}get hasSelfTest(){return!1}get isIntermediate(){return!1}async detectCmp(){return a("#_evidon_banner")}async detectPopup(){return c("#_evidon_banner","any")}async optOut(){return r("#_evidon-decline-button")||(o(n(),["#evidon-prefdiag-overlay","#evidon-prefdiag-background"]),r("#_evidon-option-button"),await u("#evidon-prefdiag-overlay",5e3),r("#evidon-prefdiag-decline")),!0}async optIn(){return r("#_evidon-accept-button")}},new class extends h{constructor(){super("Onetrust"),this.prehideSelectors=["#onetrust-banner-sdk,#onetrust-consent-sdk,.optanon-alert-box-wrapper,.onetrust-pc-dark-filter,.js-consent-banner"]}get hasSelfTest(){return!0}get isIntermediate(){return!1}async detectCmp(){return a("#onetrust-banner-sdk,.optanon-alert-box-wrapper")}async detectPopup(){return c("#onetrust-banner-sdk,.optanon-alert-box-wrapper","all")}async optOut(){return a("#onetrust-pc-btn-handler")?r("#onetrust-pc-btn-handler"):r(".ot-sdk-show-settings,button.js-cookie-settings"),await u("#onetrust-consent-sdk",2e3),await l(1e3),r("#onetrust-consent-sdk input.category-switch-handler:checked,.js-editor-toggle-state:checked",!0),await u(".save-preference-btn-handler,.js-consent-save",2e3),r(".save-preference-btn-handler,.js-consent-save"),await s((()=>c("#onetrust-banner-sdk","none")),10,500),!0}async optIn(){return r("#onetrust-accept-btn-handler,.js-accept-cookies")}async test(){return await i("window.OnetrustActiveGroups.split(',').filter(s => s.length > 0).length <= 1")}}];class C{static setBase(e){C.base=e}static findElement(e,t=null,n=!1){let o=null;return o=null!=t?Array.from(t.querySelectorAll(e.selector)):null!=C.base?Array.from(C.base.querySelectorAll(e.selector)):Array.from(document.querySelectorAll(e.selector)),null!=e.textFilter&&(o=o.filter((t=>{let n=t.textContent.toLowerCase();if(Array.isArray(e.textFilter)){let t=!1;for(let o of e.textFilter)if(-1!==n.indexOf(o.toLowerCase())){t=!0;break}return t}if(null!=e.textFilter)return-1!==n.indexOf(e.textFilter.toLowerCase())}))),null!=e.styleFilters&&(o=o.filter((t=>{let n=window.getComputedStyle(t),o=!0;for(let t of e.styleFilters){let e=n[t.option];o=t.negated?o&&e!==t.value:o&&e===t.value}return o}))),null!=e.displayFilter&&(o=o.filter((t=>e.displayFilter?0!==t.offsetHeight:0===t.offsetHeight))),null!=e.iframeFilter&&(o=o.filter((t=>e.iframeFilter?window.location!==window.parent.location:window.location===window.parent.location))),null!=e.childFilter&&(o=o.filter((t=>{let n=C.base;C.setBase(t);let o=C.find(e.childFilter);return C.setBase(n),null!=o.target}))),n?o:(o.length>1&&console.warn("Multiple possible targets: ",o,e,t),o[0])}static find(e,t=!1){let n=[];if(null!=e.parent){let o=C.findElement(e.parent,null,t);if(null!=o){if(o instanceof Array)return o.forEach((o=>{let s=C.findElement(e.target,o,t);s instanceof Array?s.forEach((e=>{n.push({parent:o,target:e})})):n.push({parent:o,target:s})})),n;{let s=C.findElement(e.target,o,t);s instanceof Array?s.forEach((e=>{n.push({parent:o,target:e})})):n.push({parent:o,target:s})}}}else{let o=C.findElement(e.target,null,t);o instanceof Array?o.forEach((e=>{n.push({parent:null,target:e})})):n.push({parent:null,target:o})}return 0===n.length&&n.push({parent:null,target:null}),t?n:(1!==n.length&&console.warn("Multiple results found, even though multiple false",n),n[0])}}function b(e){const t=C.find(e);return"css"===e.type?!!t.target:"checkbox"===e.type?!!t.target&&t.target.checked:void 0}async function _(e,t){switch(e.type){case"click":return async function(e){const t=C.find(e);null!=t.target&&t.target.click();return v(0)}(e);case"list":return async function(e,t){for(let n of e.actions)await _(n,t)}(e,t);case"consent":return async function(e,t){for(const n of e.consents){const e=-1!==t.indexOf(n.type);if(n.matcher&&n.toggleAction){b(n.matcher)!==e&&await _(n.toggleAction)}else e?await _(n.trueAction):await _(n.falseAction)}}(e,t);case"ifcss":return async function(e,t){C.find(e).target?e.falseAction&&await _(e.falseAction,t):e.trueAction&&await _(e.trueAction,t)}(e,t);case"waitcss":return async function(e){await new Promise((t=>{let n=e.retries||10;const o=e.waitTime||250,s=()=>{const i=C.find(e);(e.negated&&i.target||!e.negated&&!i.target)&&n>0?(n-=1,setTimeout(s,o)):t()};s()}))}(e);case"foreach":return async function(e,t){const n=C.find(e,!0),o=C.base;for(const o of n)o.target&&(C.setBase(o.target),await _(e.action,t));C.setBase(o)}(e,t);case"hide":return async function(e){const t=C.find(e);t.target&&t.target.classList.add("Autoconsent-Hidden")}(e);case"slide":return async function(e){const t=C.find(e),n=C.find(e.dragTarget);if(t.target){let e=t.target.getBoundingClientRect(),o=n.target.getBoundingClientRect(),s=o.top-e.top,i=o.left-e.left;"y"===this.config.axis.toLowerCase()&&(i=0),"x"===this.config.axis.toLowerCase()&&(s=0);let r=window.screenX+e.left+e.width/2,a=window.screenY+e.top+e.height/2,c=e.left+e.width/2,u=e.top+e.height/2,l=document.createEvent("MouseEvents");l.initMouseEvent("mousedown",!0,!0,window,0,r,a,c,u,!1,!1,!1,!1,0,t.target);let d=document.createEvent("MouseEvents");d.initMouseEvent("mousemove",!0,!0,window,0,r+i,a+s,c+i,u+s,!1,!1,!1,!1,0,t.target);let p=document.createEvent("MouseEvents");p.initMouseEvent("mouseup",!0,!0,window,0,r+i,a+s,c+i,u+s,!1,!1,!1,!1,0,t.target),t.target.dispatchEvent(l),await this.waitTimeout(10),t.target.dispatchEvent(d),await this.waitTimeout(10),t.target.dispatchEvent(p)}}(e);case"close":return async function(e){window.close()}();case"wait":return async function(e){await v(e.waitTime)}(e);case"eval":return async function(e){return console.log("eval!",e.code),new Promise((t=>{try{e.async?(window.eval(e.code),setTimeout((()=>{t(window.eval("window.__consentCheckResult"))}),e.timeout||250)):t(window.eval(e.code))}catch(n){console.warn("eval error",n,e.code),t(!1)}}))}(e);default:throw"Unknown action type: "+e.type}}C.base=null;function v(e){return new Promise((t=>{setTimeout((()=>{t()}),e)}))}class k{constructor(e,t){this.name=e,this.config=t,this.methods=new Map,this.runContext=p,t.methods.forEach((e=>{e.action&&this.methods.set(e.name,e.action)})),this.hasSelfTest=!1}get isIntermediate(){return!1}checkRunContext(){return!0}async detectCmp(){return this.config.detectors.map((e=>b(e.presentMatcher))).some((e=>!!e))}async detectPopup(){return this.config.detectors.map((e=>b(e.showingMatcher))).some((e=>!!e))}async executeAction(e,t){return!this.methods.has(e)||_(this.methods.get(e),t)}async optOut(){return await this.executeAction("HIDE_CMP"),await this.executeAction("OPEN_OPTIONS"),await this.executeAction("HIDE_CMP"),await this.executeAction("DO_CONSENT",[]),await this.executeAction("SAVE_CONSENT"),!0}async optIn(){return await this.executeAction("HIDE_CMP"),await this.executeAction("OPEN_OPTIONS"),await this.executeAction("HIDE_CMP"),await this.executeAction("DO_CONSENT",["D","A","B","E","F","X"]),await this.executeAction("SAVE_CONSENT"),!0}async openCmp(){return await this.executeAction("HIDE_CMP"),await this.executeAction("OPEN_OPTIONS"),!0}async test(){return!0}}const x=new class{constructor(e,n=null,o=null){if(this.rules=[],this.foundCmp=null,t.sendContentMessage=e,this.sendContentMessage=e,this.rules=[...g],n)this.initialize(n,o);else{o&&this.parseRules(o);e({type:"init",url:window.location.href})}}initialize(e,t){if(this.config=e,e.enabled){if(t&&this.parseRules(t),e.disabledCmps?.length>0&&this.disableCMPs(e.disabledCmps),e.enablePrehide)if(document.documentElement)this.prehideElements();else{const e=()=>{window.removeEventListener("DOMContentLoaded",e),this.prehideElements()};window.addEventListener("DOMContentLoaded",e)}if("loading"===document.readyState){const e=()=>{window.removeEventListener("DOMContentLoaded",e),this.start()};window.addEventListener("DOMContentLoaded",e)}else this.start()}}parseRules(e){Object.keys(e.consentomatic).forEach((t=>{this.addConsentomaticCMP(t,e.consentomatic[t])})),e.autoconsent.forEach((e=>{this.addCMP(e)}))}addCMP(e){this.rules.push(function(e){return new f(e)}(e))}disableCMPs(e){this.rules=this.rules.filter((t=>!e.includes(t.name)))}addConsentomaticCMP(e,t){this.rules.push(new k(`com_${e}`,t))}start(){window.requestIdleCallback?window.requestIdleCallback((()=>this._start()),{timeout:500}):this._start()}async _start(){const e=await this.findCmp(this.config.detectRetries);if(e){this.sendContentMessage({type:"cmpDetected",url:location.href,cmp:e.name});return await this.waitForPopup(e)?(this.foundCmp=e,this.sendContentMessage({type:"popupFound",cmp:e.name,url:location.href}),"optOut"===this.config.autoAction?await this.doOptOut():"optIn"!==this.config.autoAction||await this.doOptIn()):(this.config.enablePrehide&&d(),!1)}return this.config.enablePrehide&&d(),!1}async findCmp(e){let t=null;const n=[];for(const e of this.rules)try{if(!e.checkRunContext())continue;await e.detectCmp()&&(n.push(e),t||(t=e))}catch(e){}if(n.length>1){const e={msg:"Found multiple CMPs, check the detection rules.",cmps:n.map((e=>e.name))};this.sendContentMessage({type:"autoconsentError",details:e})}return!t&&e>0?new Promise((t=>{setTimeout((async()=>{const n=this.findCmp(e-1);t(n)}),500)})):t}async doOptOut(){let e;return e=!!this.foundCmp&&await this.foundCmp.optOut(),this.config.enablePrehide&&d(),this.sendContentMessage({type:"optOutResult",cmp:this.foundCmp?this.foundCmp.name:"none",result:e,scheduleSelfTest:this.foundCmp&&this.foundCmp.hasSelfTest,url:location.href}),e&&!this.foundCmp.isIntermediate&&this.sendContentMessage({type:"autoconsentDone",cmp:this.foundCmp.name,url:location.href}),e}async doOptIn(){let e;return e=!!this.foundCmp&&await this.foundCmp.optIn(),this.config.enablePrehide&&d(),this.sendContentMessage({type:"optInResult",cmp:this.foundCmp?this.foundCmp.name:"none",result:e,scheduleSelfTest:!1,url:location.href}),e&&!this.foundCmp.isIntermediate&&this.sendContentMessage({type:"autoconsentDone",cmp:this.foundCmp.name,url:location.href}),e}async doSelfTest(){let e;return e=!!this.foundCmp&&await this.foundCmp.test(),this.sendContentMessage({type:"selfTestResult",cmp:this.foundCmp?this.foundCmp.name:"none",result:e,url:location.href}),e}async waitForPopup(e,t=5,n=500){const o=await e.detectPopup();return!o&&t>0?new Promise((o=>setTimeout((()=>o(this.waitForPopup(e,t-1,n))),n))):o}prehideElements(){return function(e){return o(n("autoconsent-prehide"),e,"opacity")}(this.rules.reduce(((e,t)=>t.prehideSelectors?[...e,...t.prehideSelectors]:e),["#didomi-popup,.didomi-popup-container,.didomi-popup-notice,.didomi-consent-popup-preferences,#didomi-notice,.didomi-popup-backdrop,.didomi-screen-medium"]))}async receiveMessageCallback(e){switch(e.type){case"initResp":this.initialize(e.config,e.rules);break;case"optOut":await this.doOptOut();break;case"selfTest":await this.doSelfTest();break;case"evalResp":!function(e,n){const o=t.pending.get(e);o?(t.pending.delete(e),o.timer&&window.clearTimeout(o.timer),o.resolve(n)):console.warn("no eval #",e)}(e.id,e.result)}}}(chrome.runtime.sendMessage);chrome.runtime.onMessage.addListener((e=>Promise.resolve(x.receiveMessageCallback(e))))}();
Binary file
@@ -0,0 +1,32 @@
1
+ {
2
+ "manifest_version": 2,
3
+ "name": "Autoconsent",
4
+ "version": "2022.7.21",
5
+ "background": {
6
+ "scripts": [
7
+ "background.bundle.js"
8
+ ]
9
+ },
10
+ "content_scripts": [
11
+ {
12
+ "matches": [
13
+ "*://*/*"
14
+ ],
15
+ "js": [
16
+ "content.bundle.js"
17
+ ],
18
+ "run_at": "document_start",
19
+ "all_frames": true
20
+ }
21
+ ],
22
+ "permissions": [
23
+ "*://*/*",
24
+ "tabs",
25
+ "storage",
26
+ "webNavigation"
27
+ ],
28
+ "page_action": {
29
+ "browser_style": true,
30
+ "default_title": "Autoconsent"
31
+ }
32
+ }