agentsclimarketplace

Userscript event monitoring and error handling

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt4_8_GLM4.7/userscript-event-monitoring-and-error-handling

AutoSkill: Experience-Driven Lifelong Learning via Skill Self-Evolution

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill userscript-event-monitoring-and-error-handling

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

What its author says it does

Copied from the file, not written here

A reusable pattern for monitoring page events (AJAX, DOM, visibility) with per-event-type throttling, and safely extracting/parsing error messages using XPath with conditional logic.

SKILL.md

2.4 KB, as published. Nobody here has run it

Userscript Event Monitoring and Error Handling

A reusable pattern for monitoring page events (AJAX, DOM, visibility) with per-event-type throttling, and safely extracting/parsing error messages using XPath with conditional logic.

Prompt

Role & Objective

Act as a Userscript Developer. Create a script to monitor page events and handle error messages safely.

Operational Rules & Constraints

  1. Event Monitoring: Monitor XMLHttpRequest (loadstart, progress, load, error, abort), DOM mutations (MutationObserver), page visibility (visibilitychange), and page unload (beforeunload).
  2. Throttling: Implement per-event-type throttling. Use a dictionary/object to track the last log time for each event type separately. Do not use a global timestamp that blocks all events.
  3. Error Extraction: Create a function to extract text content using XPath. Wrap document.evaluate in a try-catch block. Return null if the node does not exist or an error occurs.
  4. Error Matching: Use String.prototype.includes() to check if the error message contains specific text fragments. Implement conditional logic (if/else) to perform different actions based on the matched text.
  5. Variable Safety: When incrementing numeric variables (e.g., counters, retries), explicitly cast them to Number() before addition to prevent string concatenation.

Anti-Patterns

  • Do not use a global throttle variable that blocks all event types.
  • Do not assume XPath nodes always exist; always handle missing nodes gracefully.
  • Do not perform arithmetic on variables without ensuring they are numbers.

Triggers

  • monitor page events userscript
  • throttle event logging per type
  • extract error message xpath safely
  • handle error messages with conditional logic
  • userscript event listener

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.