A modular, cross-browser extension built with TypeScript and Vite that intercepts client-side network requests (XMLHttpRequest) on Instagram Web to inspect, paginate, and extract the complete list of a profile's followers and following.
⚠️ Disclaimer: This project is developed strictly for educational and research purposes to demonstrate browser extension architecture, script injection lifecycles, and client-side network interception. It is not affiliated with, maintained by, or endorsed by Meta Platforms, Inc. or Instagram. The author assumes no responsibility for any misuse or violation of third-party Terms of Service.
- Cross-Browser Architecture: Standardized adapter pattern supporting Chrome, Firefox, Edge, and Opera.
- Isolated & Injected Execution: Uses a content script bridge to dynamically inject typed
web_accessible_resourcesinto the page execution context. - XHR Interception Engine: Hooks into native
XMLHttpRequestlifecycles to observe and parse authenticated internal API responses without relying on fragile DOM scraping. - Target & Permission-Aware Extraction: Dynamically resolves profile paths and extracts the full followers and following lists for public profiles and followed private accounts.
- Modern Developer Tooling: Configured with Vite for fast bundling, strict TypeScript definitions, ESLint, and Prettier.
- Language: TypeScript
- Bundler & Tooling: Vite
- Platform: WebExtensions API (Manifest V3)
- Core Technique:
XMLHttpRequestPrototype Hooking & DOM Script Injection
instagram-observer/
├── public/
│ ├── manifest.json # Extension manifest (MV3)
│ ├── popup.html # Extension popup interface
│ └── assets/ # Extension icons (16, 32, 48, 128px)
├── src/
│ ├── api/ # Instagram API types and payload models
│ ├── core/ # Prototype augmentations (Array, Map)
│ ├── helpers/ # Application constants & target route maps
│ ├── services/
│ │ ├── Browser/ # Cross-browser environment resolver
│ │ ├── Script/ # Multi-browser script injection adapters
│ │ └── XhrInterceptor/ # Core network request interceptor logic
│ ├── utils/ # Helper modules (DOM, path, post, user, async)
│ ├── content.ts # Content script bridge
│ └── web.accessible.resource.ts # Page-level injected payload
├── vite.config.ts # Vite bundle configuration
└── tsconfig.json # TypeScript configuration
- Injection Bridge: When navigating to Instagram Web,
content.tsinitializes the appropriate browser script adapter (Chrome,Firefox,Edge, orOpera) to injectweb.accessible.resource.tsdirectly into the page context. - Network Hooking:
XhrInterceptormonkey-patcheswindow.XMLHttpRequestmethods to monitor and intercept outgoing and incoming internal requests. - Path Validation:
getFirstPathSegmentinspectslocation.pathnameto confirm if the active profile handle exists withinuserIdNameMap. - Data Pagination: Asynchronous extraction utilities (
getAllFollowingandgetAllFollowers) paginate through social graph endpoints using the authenticated session. - Console Logging: Formatted follower and following lists are logged directly to the browser developer console.
- Node.js (v18 or later recommended)
npm,pnpm, oryarn
-
Clone the repository:
git clone https://github.com/yourusername/instagram-observer.git cd instagram-observer -
Install dependencies:
npm install
-
Configure targets in
src/helpers/Constants.ts:export const userIdNameMap = new Map<string, string>([ ['target_username', 'Target Display Name'] ]);
-
Build the extension bundle:
npm run build
- Open
chrome://extensions/(oredge://extensions/). - Enable Developer mode via the toggle in the top-right corner.
- Click Load unpacked and select the generated
distfolder.
- Open
about:debugging#/runtime/this-firefox. - Click Load Temporary Add-on...
- Select the
manifest.jsonfile inside thedistdirectory.
Distributed under the MIT License. See LICENSE for details.