MLB Proxy Val

This Val Town val serves as a proxy to https://mlb.com/, transforming responses to ensure all links continue through the proxy and adding a help widget to each page.

Features

  • Proxies all requests to mlb.com
  • Transforms HTML responses to rewrite links (both absolute and relative)
  • Adds a help widget to the lower right corner of each page
  • Maintains original headers and status codes
  • Passes through non-HTML content unchanged

Help Widget

The help widget appears as a blue button in the lower right corner of each page. Currently, it displays an alert when clicked, but it's designed to be easily modified for more advanced functionality.

Modifying the Help Widget

The help widget is implemented in a modular way through the getHelpWidgetHtml() function. To change its appearance or functionality:

  1. Locate the getHelpWidgetHtml() function in the code
  2. Modify the HTML, CSS, or JavaScript as needed
  3. The widget's functionality is contained within the embedded script tag

Implementation Details

  • The proxy uses standard fetch API to forward requests
  • URL transformation handles both absolute and relative URLs
  • The widget is injected before the closing </body> tag when possible