creating-bookmarklets
Creates browser-executable JavaScript bookmarklets with strict formatting requirements. Use when users mention bookmarklets, browser utilities, dragging code to bookmarks bar, or need JavaScript that runs when clicked in the browser toolbar.
What this skill does
# Bookmarklet Creation
## Critical Requirements
### Comment Style - ABSOLUTE
**Use ONLY `/* */` comments. NEVER use `//` comments.**
Bookmark execution contexts fail with `//` style. Every comment must use block format.
```javascript
/* ✓ Correct */
const x = 5; /* inline */
/* ✗ Wrong - breaks bookmarklets */
// const x = 5;
const y = 10; // inline
```
### IIFE Wrapper
All bookmarklets must wrap in IIFE:
```javascript
(function() {
/* bookmarklet code */
})();
```
### Protocol Prefix
All delivered bookmarklets must begin with `javascript:` protocol:
```javascript
javascript:(function() {
/* bookmarklet code */
})();
```
This makes the code immediately usable without requiring manual modification during installation.
## Workflow
### 1. Generate Pretty-Printed Code
Create readable source with:
- 2-space indentation
- Descriptive variable names
- Block comments for key sections
- Logical organization
- **Prepend `javascript:` protocol to the code**
**This version with `javascript:` prefix gets stored in GitHub and shown to users, making it ready for installation without manual modification.**
### 2. Provide Installation
**Default approach - reference installer:**
```
Install: https://austegard.com/web-utilities/bookmarklet-installer.html
```
Installer handles:
- Minification with Terser
- URL encoding
- Draggable link generation
- GitHub repo integration
**Alternative - generate link programmatically:**
Use Terser.js to create installable link if requested:
```javascript
async function createBookmarkletLink(code, title) {
const minified = await Terser.minify(code);
const encoded = encodeURIComponent(minified.code).replace(/'/g, "%27");
return `<a href="javascript:${encoded}">${title}</a>`;
}
```
Requires: `<script src="https://cdn.jsdelivr.net/npm/terser/dist/bundle.min.js"></script>`
### 3. Deliverables
Always provide:
1. Pretty-printed source code **with `javascript:` protocol prepended**
2. Installation method (installer link or generated link)
3. Brief description of functionality
4. Usage instructions
The code should be delivered in a format ready for direct use - users should be able to copy the entire code block (including `javascript:`) without modification.
## Code Standards
### Error Handling
```javascript
(function() {
try {
/* main logic */
} catch (error) {
console.error('Bookmarklet error:', error);
alert('Operation failed: ' + error.message);
}
})();
```
### Console Logging
Include debug traces by default:
```javascript
console.log('Bookmarklet: Starting');
/* operations */
console.log('Bookmarklet: Complete');
```
### User Feedback
```javascript
/* Success */
alert('✓ Content copied to clipboard');
/* Error */
alert('✗ Failed to access clipboard');
```
## Common Patterns
### DOM Manipulation
```javascript
(function() {
const element = document.querySelector('.target');
if (!element) {
alert('Element not found');
return;
}
/* manipulate element */
})();
```
### Data Extraction
```javascript
(function() {
const data = Array.from(document.querySelectorAll('.item'))
.map(item => ({
title: item.querySelector('.title')?.textContent.trim(),
value: item.querySelector('.value')?.textContent.trim()
}));
console.log('Extracted:', data);
})();
```
### Clipboard Operations
```javascript
(function() {
const text = 'content to copy';
navigator.clipboard.writeText(text)
.then(() => alert('✓ Copied'))
.catch(err => {
console.error('Clipboard error:', err);
alert('✗ Copy failed');
});
})();
```
### Dynamic Library Loading
```javascript
(function() {
if (typeof someLibrary === 'undefined') {
const script = document.createElement('script');
script.src = 'https://cdn.example.com/library.js';
script.onload = function() {
/* proceed with logic */
};
document.head.appendChild(script);
}
})();
```
## Browser Compatibility
Provide fallbacks for unsupported features:
```javascript
if (!navigator.clipboard) {
alert('Clipboard API not supported');
return;
}
```
## Constraints
**Cannot use:**
- External files (CSS, images) without embedding
- Build tools or preprocessing
- `//` style comments
**Can use:**
- Fetch API
- localStorage/sessionStorage
- Modern browser APIs
- CDN libraries (loaded dynamically)
## Testing
Before delivering:
1. Verify no `//` comments exist
2. Test in browser console wrapped in IIFE
3. Check error handling with missing DOM elements
4. Verify user feedback for all paths
## Example Output
```
javascript:(function() {
/* Pretty-printed bookmarklet code */
})();
Install: https://austegard.com/web-utilities/bookmarklet-installer.html
Extracts all links from current page and copies to clipboard as markdown list. Works on any webpage.
```
## GitHub Storage
User repository: https://github.com/oaustegard/bookmarklets
Pretty-printed format matches storage requirements. Installer loads directly from this repo.
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.