This script is a JavaScript code snippet that captures Bearer tokens from HTTP requests made using fetch
or XMLHttpRequest
. It intercepts the requests and extracts the Bearer token from the Authorization
header. The captured token is then stored in the window.capturedToken
variable, which can be accessed using the window.getCapturedToken()
function.
The script is designed to be executed in a browser environment and can be useful for debugging or testing purposes, especially when working with authenticated APIs that require Bearer tokens.
To use this script, simply include it in your console or browser extension. The captured token can be accessed using window.getCapturedToken()
for further processing or testing.
- 🎣 Intercepts
fetch
andXMLHttpRequest
requests - 🔑 Captures Bearer tokens from the
Authorization
header - 💾 Stores the captured token in the
window.capturedToken
variable - 📞 Provides a
window.getCapturedToken()
function to retrieve the captured token - 🛑 Disables further token capture once a token is captured to avoid overwriting
⚠️ This script modifies the default behavior offetch
andXMLHttpRequest
, so use it with caution and ensure it aligns with your application's security and privacy requirements.
This user script captures API request and response data based on a specified hostname. It allows you to monitor and log the requests and responses made to a specific API endpoint while browsing a website. The captured data is stored in the browser's local storage and can be downloaded as a JSON file for further analysis.
- Captures API request and response data based on a specified hostname
- Stores captured data in the browser's local storage
- Allows downloading the captured data as a JSON file
- Supports customizable timezone for timestamp formatting
- Easy to use with Tampermonkey or Greasemonkey browser extensions
- Make sure you have either Tampermonkey (for Chrome) or Greasemonkey (for Firefox) browser extension installed.
- Create a new user script in Tampermonkey or Greasemonkey.
- Copy and paste the provided script code into the user script editor.
- Modify the
hostname
variable in the script to match the API endpoint you want to capture data from. - Customize the
filename
andtimezone
variables if needed. - Save the user script.
- Navigate to a website that makes requests to the specified API endpoint.
- The script will automatically capture the request and response data for any requests made to the specified hostname.
- The captured data will be stored in the browser's local storage.
- To download the captured data as a JSON file, open the browser's developer console and run the following command:
downloadCapturedData();
- To delete the captured data, run the following command in the browser's developer console:
clearCapturedData();