2067
2067
"brokerProtection",
2068
2068
"performanceMetrics",
2069
2069
"breakageReporting",
2070
- "autofillPasswordImport ",
2070
+ "autofillImport ",
2071
2071
"favicon",
2072
2072
"webTelemetry",
2073
2073
"pageContext"
2086
2086
],
2087
2087
android: [...baseFeatures, "webCompat", "breakageReporting", "duckPlayer", "messageBridge"],
2088
2088
"android-broker-protection": ["brokerProtection"],
2089
- "android-autofill-password- import": ["autofillPasswordImport "],
2089
+ "android-autofill-import": ["autofillImport "],
2090
2090
"android-adsjs": [
2091
2091
"apiManipulation",
2092
2092
"webCompat",
@@ -12072,6 +12072,15 @@ ul.messages {
12072
12072
return new SuccessResponse({ actionID: action.id, actionType: action.actionType, response: { actions: [] } });
12073
12073
}
12074
12074
12075
+ // src/features/broker-protection/actions/scroll.js
12076
+ init_define_import_meta_trackerLookup();
12077
+ function scroll(action, root = document) {
12078
+ const element = getElement(root, action.selector);
12079
+ if (!element) return new ErrorResponse({ actionID: action.id, message: "missing element" });
12080
+ element.scrollIntoView({ behavior: "smooth", block: "center", inline: "center" });
12081
+ return new SuccessResponse({ actionID: action.id, actionType: action.actionType, response: null });
12082
+ }
12083
+
12075
12084
// src/features/broker-protection/execute.js
12076
12085
async function execute(action, inputData, root = document) {
12077
12086
try {
@@ -12092,6 +12101,8 @@ ul.messages {
12092
12101
return solveCaptcha2(action, data(action, inputData, "token"), root);
12093
12102
case "condition":
12094
12103
return condition(action, root);
12104
+ case "scroll":
12105
+ return scroll(action, root);
12095
12106
default: {
12096
12107
return new ErrorResponse({
12097
12108
actionID: action.id,
@@ -12139,36 +12150,36 @@ ul.messages {
12139
12150
}
12140
12151
12141
12152
// src/features/broker-protection.js
12142
- var BrokerProtection = class extends ContentFeature {
12143
- init() {
12144
- this.messaging.subscribe("onActionReceived", async (params) => {
12145
- try {
12146
- const action = params.state.action;
12147
- const data2 = params.state.data;
12148
- if (!action) {
12149
- return this.messaging.notify("actionError", { error: "No action found." });
12150
- }
12151
- const { results, exceptions } = await this.exec(action, data2);
12152
- if (results) {
12153
- const parent = results[0];
12154
- const errors = results.filter((x2) => "error" in x2);
12155
- if (results.length === 1 || errors.length === 0) {
12156
- return this.messaging.notify("actionCompleted", { result: parent });
12157
- }
12158
- const joinedErrors = errors.map((x2) => x2.error.message).join(", ");
12159
- const response = new ErrorResponse({
12160
- actionID: action.id,
12161
- message: "Secondary actions failed: " + joinedErrors
12162
- });
12163
- return this.messaging.notify("actionCompleted", { result: response });
12164
- } else {
12165
- return this.messaging.notify("actionError", { error: "No response found, exceptions: " + exceptions.join(", ") });
12153
+ var ActionExecutorBase = class extends ContentFeature {
12154
+ /**
12155
+ * @param {any} action
12156
+ * @param {Record<string, any>} data
12157
+ */
12158
+ async processActionAndNotify(action, data2) {
12159
+ try {
12160
+ if (!action) {
12161
+ return this.messaging.notify("actionError", { error: "No action found." });
12162
+ }
12163
+ const { results, exceptions } = await this.exec(action, data2);
12164
+ if (results) {
12165
+ const parent = results[0];
12166
+ const errors = results.filter((x2) => "error" in x2);
12167
+ if (results.length === 1 || errors.length === 0) {
12168
+ return this.messaging.notify("actionCompleted", { result: parent });
12166
12169
}
12167
- } catch (e) {
12168
- console.log("unhandled exception: ", e);
12169
- this.messaging.notify("actionError", { error: e.toString() });
12170
+ const joinedErrors = errors.map((x2) => x2.error.message).join(", ");
12171
+ const response = new ErrorResponse({
12172
+ actionID: action.id,
12173
+ message: "Secondary actions failed: " + joinedErrors
12174
+ });
12175
+ return this.messaging.notify("actionCompleted", { result: response });
12176
+ } else {
12177
+ return this.messaging.notify("actionError", { error: "No response found, exceptions: " + exceptions.join(", ") });
12170
12178
}
12171
- });
12179
+ } catch (e) {
12180
+ console.log("unhandled exception: ", e);
12181
+ return this.messaging.notify("actionError", { error: e.toString() });
12182
+ }
12172
12183
}
12173
12184
/**
12174
12185
* Recursively execute actions with the same dataset, collecting all results/exceptions for
@@ -12195,6 +12206,20 @@ ul.messages {
12195
12206
}
12196
12207
return { results: [], exceptions };
12197
12208
}
12209
+ /**
12210
+ * @returns {any}
12211
+ */
12212
+ retryConfigFor(action) {
12213
+ this.log.error("unimplemented method: retryConfigFor:", action);
12214
+ }
12215
+ };
12216
+ var BrokerProtection = class extends ActionExecutorBase {
12217
+ init() {
12218
+ this.messaging.subscribe("onActionReceived", async (params) => {
12219
+ const { action, data: data2 } = params.state;
12220
+ return await this.processActionAndNotify(action, data2);
12221
+ });
12222
+ }
12198
12223
/**
12199
12224
* Define default retry configurations for certain actions
12200
12225
*
0 commit comments