HeadlinesBriefing favicon HeadlinesBriefing.com

Extract Box Share Link from Login Page with JS

DEV Community •
×

Opening a Box file link on Windows often lands you on the service’s login page instead of the shared document. The URL typically carries a redirect_url query parameter that holds the original destination. Extracting that value lets you recover the shareable link without navigating through the authentication flow.

The posted JavaScript snippet runs in the browser, first confirming the host ends with box.com. It creates a URLSearchParams object from location.search, pulls the redirect_url, strips the account subdomain from the host, and concatenates “https://” with the cleaned host and path. Finally it writes the result to a temporary textarea, selects it, and issues a copy command to the clipboard.

Developers can save the code as a bookmarklet and invoke it whenever a Box login redirect appears, instantly copying the proper URL to share with teammates or paste into another browser. The approach mirrors common SaaS patterns where authentication wrappers hide the target link, making this lightweight tool a practical time‑saver for everyday collaboration.