Table of Contents
This Node.js API allows you to inject custom code into JavaScript libraries fetched from remote sources. It's a useful tool for modifying the behavior of client-side code without having to modify the source directly. The API provides flexibility in renaming and redirecting resources as needed. It also includes a custom 404 error page for enhanced user experience.
- Fetches external JavaScript files using Axios.
- Injects custom code into any external JavaScript file.
- Handles 404 errors gracefully with a custom error page.
To use this project, follow these steps:
- Clone the repository to your local machine:
git clone https://github.com/nullydev/dynamic-script-injector.git
- Install the required dependencies:
npm install
- Start the server:
node index.js
- Access the application by navigating to 'http://localhost:3000' in your web browser.
The API endpoint is structured as follows:
GET http://localhost:3000/:obfuscationString?src=:sourceURL&o=:oldString&n=:newString
:obfuscationString
(optional): An optional parameter for obfuscation purposes. You can add a random string here(without slashes "/")
to make the API endpoint less predictable. This parameter does not affect the API's functionality.
src=:sourceURL:
The URL of the JavaScript library you want to fetch and modify.
o=:oldString:
The old string you want to replace within the fetched library.
n=:newString:
The new string you want to replace the old string with within the fetched library.
Let's say you want to inject custom code into the "jquery" library fetched from "https://cdn.jsdelivr.net/npm/jquery". You also want to rename some resources. Here's how you can structure the API call:
GET http://localhost:3000
/your-obfuscation-string
?src=https://cdn.jsdelivr.net/npm/jquery
&o=jQuery
&n=My name
&o=/jquery\.org\/license/g
&n=example.org/NeverRemoveALicense
In this example, your-obfuscation-string
is a placeholder for your obfuscation string, and the src
, o
, and n
parameters define the source URL and injection parameters, respectively.
The application includes a custom 404 error page with a CSS-based animated text effect. This error page is displayed when:
- The specified external script URL is invalid.
- The external script cannot be fetched.
- Any other errors occur during the process.
- Express.js: Fast, unopinionated, minimalist web framework for Node.js.
- Axios: Promise-based HTTP client for the browser and Node.js.
Contributions to this project are welcome! If you have any suggestions, improvements, or bug fixes, please submit an issue or a pull request.
This project is licensed under the MIT License.