|
| 1 | +# GitHub Copilot Instructions |
| 2 | + |
| 3 | +This document provides guidance for GitHub Copilot when working with this JavaScript project. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +This repository contains Tampermonkey scripts written in JavaScript. These scripts enhance user experience on various websites by adding custom functionality through browser extensions. |
| 8 | + |
| 9 | +## Coding Standards |
| 10 | + |
| 11 | +- Use modern JavaScript (ES6+) features where appropriate |
| 12 | +- Follow strict mode with `"use strict"` in all scripts |
| 13 | +- Use camelCase for variable and function names |
| 14 | +- Use meaningful variable and function names that describe their purpose |
| 15 | +- Keep functions small and focused on a single responsibility |
| 16 | +- Add proper error handling with try/catch blocks for operations that might fail |
| 17 | +- Avoid global variables; use closures and IIFEs to prevent namespace pollution |
| 18 | + |
| 19 | +## Documentation |
| 20 | + |
| 21 | +- Always include comprehensive JSDoc comments for functions |
| 22 | +- Document parameters and return values |
| 23 | +- Include examples where helpful |
| 24 | +- Maintain the UserScript headers with appropriate @match directives |
| 25 | +- Document DOM selectors used and why they were chosen |
| 26 | + |
| 27 | +## Best Practices |
| 28 | + |
| 29 | +- Prioritize performance with efficient DOM operations (minimize reflows and repaints) |
| 30 | +- Use querySelector/querySelectorAll instead of older DOM selection methods |
| 31 | +- Add descriptive console logs for debugging but comment them out in production |
| 32 | +- Use event delegation where appropriate |
| 33 | +- Clean up event listeners and observers when no longer needed |
| 34 | +- Test scripts across different browsers and versions |
| 35 | + |
| 36 | +## Project-Specific Guidelines |
| 37 | + |
| 38 | +- All scripts should follow the Tampermonkey metadata block format |
| 39 | +- Scripts should be self-contained and not rely on external libraries when possible |
| 40 | +- Always provide visual feedback to users when actions are performed (like copying to clipboard) |
| 41 | +- Consider adding user configuration options for flexible scripts |
| 42 | + |
| 43 | +## Testing |
| 44 | + |
| 45 | +- Test scripts manually on the target websites |
| 46 | +- Verify scripts work with different site layouts and states |
| 47 | +- Consider adding version checking to handle website structure changes |
| 48 | + |
| 49 | +## Security Considerations |
| 50 | + |
| 51 | +- Don't store sensitive information in localStorage or sessionStorage |
| 52 | +- Sanitize any user input |
| 53 | +- Be cautious when injecting HTML content to avoid XSS vulnerabilities |
| 54 | +- Don't expose private API tokens or credentials in your scripts |
0 commit comments