Skip to content

The purpose of this project was to serve as a proxy router for CDNs while also having the capability to modify the code.

License

Notifications You must be signed in to change notification settings

nullydev/DynamicScriptInjector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dynamic Script Injector API

Table of Contents

Introduction

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.

Features

  • Fetches external JavaScript files using Axios.
  • Injects custom code into any external JavaScript file.
  • Handles 404 errors gracefully with a custom error page.

Getting Started

To use this project, follow these steps:

  1. Clone the repository to your local machine:
    git clone https://github.com/nullydev/dynamic-script-injector.git
  2. Install the required dependencies:
    npm install
  3. Start the server:
    node index.js
  4. Access the application by navigating to 'http://localhost:3000' in your web browser.

Usage

Endpoint

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.

Query Parameters

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.

Example

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.

Error Handling

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.

Dependencies

  • Express.js: Fast, unopinionated, minimalist web framework for Node.js.
  • Axios: Promise-based HTTP client for the browser and Node.js.

Contributing

Contributions to this project are welcome! If you have any suggestions, improvements, or bug fixes, please submit an issue or a pull request.

License

This project is licensed under the MIT License.

About

The purpose of this project was to serve as a proxy router for CDNs while also having the capability to modify the code.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published