mlbdotcom
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
index.ts
https://curtcox--91125b9eeba74077b06817ee212c620e.web.val.run
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.
- 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
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.
The help widget is implemented in a modular way through the getHelpWidgetHtml()
function. To change its appearance or functionality:
- Locate the
getHelpWidgetHtml()
function in the code - Modify the HTML, CSS, or JavaScript as needed
- The widget's functionality is contained within the embedded script tag
- 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