How amirshnll/custom-device-emulation-chrome works
Project type and purpose
• This is a browser‐extension project (“custom‐device‐emulation‐chrome”) that runs entirely inside Chrome.
• Its purpose is to let users select or add device presets (viewport size, DPR, UA string) in the Chrome DevTools device toolbar.
File structure
• Top level:
• CODE_OF_CONDUCT.md, CONTRIBUTING.md, LICENSE, README.md, .github/ – standard repo docs
• device.json – the master list of device definitions
• release.sh – deploy script for publishing the extension
• images/ – screenshots for the README
• plugin/ directory (the actual extension bundle) contains:
• manifest.json – extension metadata, permissions, entry points
• privacy.md – privacy policy for the Web Store
README for additional insights
• No runtime backend or server components are mentioned—everything is client‐side.
• The extension UI walks through DevTools keyboard shortcuts, device editing, and uses the device list in device.json.
a. Main components
1. Chrome Browser (host environment)
2. Extension Loader & Manifest (defines permissions and resources)
3. UI Layer (popup.html + styles.css)
4. Logic Layer (popup.js)
5. Data Layer (device.json)
6. Chrome DevTools Protocol / chrome.* APIs (to configure emulation)
7. Release Pipeline (release.sh → Chrome Web Store)
b. Relationships & interactions
• At install time, Chrome reads manifest.json and registers the extension.
• popup.js fetches device.json, renders the device list, handles “Add Device” actions.
• On user input, popup.js calls Chrome DevTools Protocol (via chrome.debugger or chrome.devtools.* APIs) to apply viewport, DPR, and UA overrides.
• release.sh picks up the plugin/ folder, packages it, and publishes to the Chrome Web Store.
c. Architectural patterns & design principles
• Separation of concerns: UI (HTML/CSS) vs. business logic (JS) vs. static data (JSON).
• Manifest‐driven plugin architecture—declarative registration of resources and permissions.
• Client‐only design—no backend required.
d. Key technologies/frameworks
• Native Chrome Extension APIs (chrome.browserAction, chrome.devtools)
• Standard web tech: HTML5, CSS3, JavaScript ES6
• JSON for data serialization