Skip to content

Add bookmarklets collection page with View Anchors and View Source#207

Merged
simonw merged 2 commits intomainfrom
claude/add-bookmarklets-page-VFtjZ
Jan 18, 2026
Merged

Add bookmarklets collection page with View Anchors and View Source#207
simonw merged 2 commits intomainfrom
claude/add-bookmarklets-page-VFtjZ

Conversation

@simonw
Copy link
Owner

@simonw simonw commented Jan 18, 2026

Look at how the lobsters bookmarklet page works, then start a new bookmarklets.html page that uses the same install mechanism but is designed to support multiple bookmarklets going forward

Add two bookmarklets there:

  • View reference anchors: finds all elements with an id=”” or a <a name=”…” and adds a visible # link as the first thing inside that element to help people link to otherwise invisible reference targets
  • View source - opens an HTML model with a textarea containing document.innerHTML - with a “pretty print” button that pretty prints it and a copy to clipboard button

Creates a new bookmarklets.html page designed to host multiple bookmarklets:

- View Reference Anchors: finds elements with id="" or <a name="..."> and
  adds visible # links that copy the anchor URL when clicked
- View Source: opens a modal with document.documentElement.outerHTML,
  featuring pretty print and copy to clipboard buttons

Uses the same drag-to-install mechanism as the lobsters bookmarklet page,
with a card-based layout for easy expansion with additional bookmarklets.
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jan 18, 2026

Deploying tools with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6902915
Status: ✅  Deploy successful!
Preview URL: https://f9f1d10b.tools-b1q.pages.dev
Branch Preview URL: https://claude-add-bookmarklets-page.tools-b1q.pages.dev

View logs

@claude
Copy link
Contributor

claude bot commented Jan 18, 2026

Claude finished @simonw's task —— View job


Code Review Complete ✅

Todo List:

  • Read repository guidelines (CLAUDE.md)
  • Read and analyze the new bookmarklets.html file
  • Review code quality and best practices
  • Check for potential bugs or issues
  • Assess performance considerations
  • Evaluate security concerns
  • Check test coverage requirements
  • Provide comprehensive review feedback

Code Review Summary

This is a well-implemented bookmarklets collection page that follows good practices and maintains consistency with the existing lobsters-bookmarklet.html page. The implementation is solid overall with only minor areas for improvement.

✅ Strengths

Code Quality & Best Practices

  • Consistent styling: Follows the same design patterns as lobsters-bookmarklet.html with appropriate color scheme adaptation
  • Clean HTML structure: Semantic markup with proper heading hierarchy and accessibility considerations
  • Responsive design: Uses viewport meta tag and flexible layouts that work across devices
  • Modern CSS: Uses CSS Grid/Flexbox, custom properties would be beneficial but current approach is solid
  • Clear code organization: Logical separation of styles, content, and functionality

Security

  • Safe bookmarklet implementation: Both bookmarklets use defensive coding practices:
    • Checks for existing elements before adding (__anchor_styles, __viewsource_modal)
    • Uses unique prefixed IDs to avoid conflicts (__anchor_, __viewsource_)
    • Proper event handling with preventDefault() and stopPropagation()
    • No external script loading or XSS vulnerabilities detected

User Experience

  • Comprehensive instructions: Clear installation steps for desktop and mobile browsers
  • Drag-to-install functionality: Consistent with existing bookmarklet pages
  • Copy buttons: Good fallback for mobile users, with visual feedback
  • Source code visibility: Expandable <details> sections for transparency

⚠️ Areas for Improvement

Code Quality Issues

  1. bookmarklets.html:203,312 - Minified bookmarklet URLs: The JavaScript in the href attributes is heavily minified and difficult to audit. Consider:

    • Adding line breaks after semicolons for better readability in the URL
    • Using a build process to generate minified versions from readable source
  2. bookmarklets.html:448,455,462 - HTML entity escaping inconsistency: In the pretty-print function source code display, HTML entities are inconsistently escaped (some &lt; and &gt;, some not). This should be standardized.

Performance Considerations

  1. bookmarklets.html:203,312 - Large inline JavaScript: The bookmarklet URLs contain substantial JavaScript code. While this is necessary for bookmarklets, consider:
    • Warning users about the size for slower connections
    • Ensuring the code is optimized (current implementation appears efficient)

Minor UX Issues

  1. bookmarklets.html:291,468 - Alert() usage: Uses alert() for feedback in the View Anchors bookmarklet. Consider:

    • Using a custom styled notification instead of browser alert for better UX
    • Making it optional or less intrusive
  2. bookmarklets.html:434 - Fallback clipboard method: Uses deprecated document.execCommand('copy') as fallback. While necessary for older browsers, consider:

    • Adding a comment explaining why it's needed
    • Potentially detecting support and showing appropriate instructions

🔍 Security Assessment

The bookmarklets are secure and follow defensive coding practices:

  • No direct DOM insertion of unvalidated content
  • Proper namespace isolation with prefixed IDs
  • No external resource loading
  • Safe clipboard API usage with fallbacks

📋 Test Coverage

No automated tests detected - This is typical for static HTML pages with bookmarklets. Consider adding:

  • Basic HTML validation tests
  • JavaScript syntax validation for the bookmarklet code
  • Cross-browser compatibility testing for the installation instructions

🎯 Recommendations

  1. Consistency: Consider extracting shared CSS into a common stylesheet used by both bookmarklet pages
  2. Documentation: Add JSDoc comments to the pretty-print algorithm for better maintainability
  3. Accessibility: Add ARIA labels to the copy buttons for screen readers
  4. Performance: Consider lazy-loading the source code in the <details> sections

Final Assessment

This is a high-quality implementation that effectively extends the existing bookmarklet infrastructure. The code is secure, functional, and maintains consistency with existing patterns. The identified issues are minor and don't impact the core functionality.

Recommendation: ✅ Approve - Ready to merge with optional follow-up improvements.


@claude
Copy link
Contributor

claude bot commented Jan 18, 2026

Claude finished @simonw's task —— View job


I'll analyze this pull request and provide comprehensive review feedback.

Todo List:

  • Read repository guidelines (CLAUDE.md)
  • Read and analyze the new bookmarklets.html file
  • Review code quality and best practices
  • Check for potential bugs or issues
  • Assess performance considerations
  • Evaluate security concerns
  • Check test coverage requirements
  • Provide comprehensive review feedback

Code Review Complete ✅

I've completed a thorough review of the new bookmarklets.html file. This is a well-implemented collection page that effectively extends the existing bookmarklet infrastructure with two useful new bookmarklets.

✅ Strengths

Code Quality & Best Practices:

  • Consistent styling: Follows similar design patterns as lobsters-bookmarklet.html with appropriate color scheme changes (blue theme vs red)
  • Responsive design: Uses proper viewport meta tag and flexible layouts
  • Clean HTML structure: Semantic markup with good heading hierarchy
  • Modern CSS: Effective use of Flexbox, proper border-radius, and hover states
  • Code organization: Logical separation between styles, content, and functionality

Security:

  • Safe bookmarklet implementation: Both bookmarklets use defensive coding practices:
    • Checks for existing elements before adding (__anchor_styles, __viewsource_modal)
    • Uses unique namespaced IDs to prevent conflicts
    • Proper event handling with preventDefault() and stopPropagation()
    • No external script loading or XSS vulnerabilities

User Experience:

  • Comprehensive instructions: Clear installation steps for desktop and mobile browsers
  • Drag-to-install functionality: Consistent with existing bookmarklet pages
  • Copy buttons: Good fallback for mobile users with visual feedback
  • Source code visibility: Expandable <details> sections for transparency

⚠️ Areas for Improvement

Minor Code Quality Issues:

  1. bookmarklets.html:206,317 - Minified bookmarklet URLs: The JavaScript in href attributes is heavily minified, making code auditing difficult. While necessary for bookmarklets, consider adding line breaks after semicolons in development versions.

  2. bookmarklets.html:448,455,462 - HTML entity escaping inconsistency: In the pretty-print function source code, some HTML entities are escaped (&gt;, &lt;) while others aren't. This should be standardized throughout.

  3. bookmarklets.html:295 - Alert usage: Uses alert() for user feedback which provides poor UX. Consider a custom styled notification.

Performance Considerations:

  1. Large inline JavaScript: The bookmarklet URLs contain substantial JavaScript. While unavoidable, the code appears well-optimized for size vs functionality trade-off.

Minor UX Issues:

  1. bookmarklets.html:440 - Deprecated fallback: Uses document.execCommand('copy') as fallback for older browsers. While necessary, consider adding explanatory comments.

🔍 Security Assessment

The bookmarklets are secure and follow defensive coding practices:

  • No direct DOM insertion of unvalidated content
  • Proper namespace isolation with prefixed IDs (__anchor_, __viewsource_)
  • Safe clipboard API usage with appropriate fallbacks
  • No external resource loading

📋 Test Coverage

No automated tests detected - This is typical for static HTML pages with bookmarklets. Consider adding:

  • HTML validation tests
  • JavaScript syntax validation for bookmarklet code
  • Cross-browser compatibility testing

🎯 Recommendations

  1. Consistency: Consider extracting shared CSS into a common stylesheet for both bookmarklet pages
  2. Documentation: Add JSDoc comments to the pretty-print algorithm
  3. Accessibility: Add ARIA labels to copy buttons for screen readers
  4. Maintainability: Consider keeping readable source versions separate from minified bookmarklet URLs

Final Assessment

This is a high-quality implementation that successfully extends the bookmarklet infrastructure. The code is secure, functional, and maintains consistency with existing patterns. All identified issues are minor and don't impact core functionality.

Recommendation: ✅ Approve - Ready to merge with optional follow-up improvements.


@simonw simonw merged commit 0804a5a into main Jan 18, 2026
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants