79 lines
1.9 KiB
Markdown
79 lines
1.9 KiB
Markdown
# Code Section
|
|
|
|
Development workspace for bookmarklets, experiments, and scratch code.
|
|
|
|
## 🔖 Bookmarklets
|
|
|
|
Browser-based JavaScript utilities. **See [bookmarklets/README.md](bookmarklets/README.md) for full documentation.**
|
|
|
|
### Quick Start
|
|
|
|
1. Write regular JavaScript in `bookmarklets/` (use comments, modern syntax)
|
|
2. Run: `npm run bookmarklet -- code/bookmarklets/your-file.js`
|
|
3. Paste clipboard contents into browser bookmark URL
|
|
|
|
### Example
|
|
|
|
```javascript
|
|
/**
|
|
* My Bookmarklet
|
|
* Does something cool
|
|
*/
|
|
|
|
const elements = document.querySelectorAll("a");
|
|
elements.forEach((el) => {
|
|
el.style.backgroundColor = "yellow";
|
|
});
|
|
|
|
alert(`Highlighted ${elements.length} links!`);
|
|
```
|
|
|
|
The generator automatically removes comments, minifies, and wraps in IIFE format.
|
|
|
|
## 🛠️ Utils
|
|
|
|
Build tools and generators:
|
|
|
|
- **bookmarkletMaker.js** - Converts JS files to bookmarklets
|
|
- Removes comments
|
|
- Minifies code
|
|
- Wraps in `javascript:(function(){...})();` format
|
|
- Copies to clipboard
|
|
|
|
## 🧪 Scratchpad
|
|
|
|
Experiment with code organized by language. Use this for:
|
|
|
|
- Testing new ideas
|
|
- Prototyping features
|
|
- Learning new concepts
|
|
- Code snippets for other projects
|
|
|
|
### Running Code
|
|
|
|
- **Python:** `Cmd+Shift+P` → "Code Runner: Run Code"
|
|
- **JavaScript:** Same as above (uses Node.js)
|
|
- **TypeScript:** Install `ts-node` globally first
|
|
|
|
## 📄 Templates
|
|
|
|
Reusable code templates and boilerplate:
|
|
|
|
- **function-template.js** - Function with ES module exports
|
|
- **class-template.js** - Class definition with methods
|
|
- **module-template.js** - Multi-export module pattern
|
|
- Common patterns and structures
|
|
|
|
**Note:** All templates use ES modules (import/export). See `package.json` with `"type": "module"`.
|
|
|
|
## 💡 Tips
|
|
|
|
- Use `// TODO:` comments for tracking work
|
|
- Bookmark important code sections
|
|
- Test in scratchpad before moving to bookmarklets
|
|
- Keep snippets small and focused
|
|
|
|
---
|
|
|
|
**Remember:** This is your experimental playground. Break things, learn, iterate!
|