-
Notifications
You must be signed in to change notification settings - Fork 143
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Currently, many JavaScript evaluations call methods in __pulsar_utils__, such as __pulsar_utils__.check(selector). The __pulsar_utils__ object is injected using CDP's protocol addScriptToEvaluateOnNewDocument.
To modernize and make these evaluations safer and more maintainable, we propose migrating to Immediately Invoked Function Expressions (IIFE) to replace direct __pulsar_utils__ injection.
Migration Plan
- Extract Method Code at Runtime: In Kotlin code, extract the source code for each
__pulsar_utils__method at runtime. - Dynamic IIFE Evaluation: On encountering a call to
__pulsar_utils__.check(selector)(or other methods), locate the corresponding method's code, wrap it as an IIFE, and evaluate it on demand.
This approach provides better encapsulation and avoids potential naming collisions or pollution of the global scope.
Acceptance Criteria:
- Each usage of
__pulsar_utils__in JS evaluations is safely migrated to an IIFE approach. - Extraction and dynamic wrapping is handled within the Kotlin code base.
- Old injection of
__pulsar_utils__is removed. - Existing functionality remains unaffected and tests remain green.
Example (before):
__pulsar_utils__.check(selector)Example (after, conceptual):
((params) => { /* extracted check code */ })(selector)Copilot
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request