Skip to content

Commit e8d1398

Browse files
authored
Fix imports in the CPM automation (#144)
1 parent 660d7c1 commit e8d1398

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

post-processing/generate-autoconsent-rules/detection.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ Examples of NON-cookie popup text:
145145
* @param {import('openai').OpenAI} openai
146146
* @returns {Promise<import('./main').ProcessedCookiePopup | null>}
147147
*/
148-
export async function applyDetectionHeuristics(popup, openai) {
148+
async function applyDetectionHeuristics(popup, openai) {
149149
const popupText = popup.text?.trim();
150150
if (!popupText) {
151151
return null;
@@ -175,3 +175,6 @@ export async function applyDetectionHeuristics(popup, openai) {
175175
};
176176
}
177177

178+
module.exports = {
179+
applyDetectionHeuristics,
180+
};

post-processing/generate-autoconsent-rules/generation.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,17 @@ function generateAutoconsentRule({ region }, url, popup, button) {
7575
detectCmp: [{ exists: button.selector }],
7676
detectPopup: [{ visible: button.selector }],
7777
optIn: [],
78-
optOut: [{ waitForThenClick: button.selector, comment: button.text }],
78+
optOut: [
79+
{ wait: 500 },
80+
{ waitForThenClick: button.selector, comment: button.text },
81+
],
82+
test: [
83+
{
84+
waitForVisible: button.selector,
85+
timeout: 1000,
86+
check: 'none',
87+
},
88+
],
7989
};
8090
}
8191

@@ -88,7 +98,7 @@ function generateAutoconsentRule({ region }, url, popup, button) {
8898
* @param {import('./main').AutoConsentCMPRule[]} matchingRules - Array of existing rules.
8999
* @returns {{newRules: import('./main').AutoConsentCMPRule[], rulesToOverride: import('./main').AutoConsentCMPRule[], reviewNotes: import('./main').ReviewNote[], keptCount: number}}
90100
*/
91-
export function generateRulesForSite(globalParams, url, cookiePopups, matchingRules) {
101+
function generateRulesForSite(globalParams, url, cookiePopups, matchingRules) {
92102
const { region } = globalParams;
93103
/** @type {import('./main').AutoConsentCMPRule[]} */
94104
const newRules = [];
@@ -194,3 +204,7 @@ export function generateRulesForSite(globalParams, url, cookiePopups, matchingRu
194204
}
195205
return { newRules, rulesToOverride, reviewNotes, keptCount };
196206
}
207+
208+
module.exports = {
209+
generateRulesForSite,
210+
};

post-processing/generate-autoconsent-rules/verification.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const fs = require('fs');
66
* Run LLM to detect potential false positives and false negatives in button detection.
77
* @param {import('./main').GlobalParams} globalParams
88
*/
9-
export async function verifyButtonTexts(globalParams) {
9+
async function verifyButtonTexts(globalParams) {
1010
const { openai, rejectButtonTextsFile, otherButtonTextsFile } = globalParams;
1111
const FalsePositiveSuggestions = z.object({
1212
potentiallyIncorrectRejectButtons: z.array(z.string()),
@@ -67,3 +67,7 @@ export async function verifyButtonTexts(globalParams) {
6767
console.error('Error classifying false negatives:', error);
6868
}
6969
}
70+
71+
module.exports = {
72+
verifyButtonTexts,
73+
};

0 commit comments

Comments
 (0)