browser-lens-mcp 3.0.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,8 +11,31 @@ chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => {
11
11
  chrome.storage.local.get(DEFAULTS, (cfg) => sendResponse(cfg));
12
12
  return true;
13
13
  }
14
+
14
15
  if (msg.type === "setConfig") {
15
16
  chrome.storage.local.set(msg.config, () => sendResponse({ ok: true }));
16
17
  return true;
17
18
  }
19
+
20
+ if (msg.type === "injectScript" && sender.tab) {
21
+ chrome.scripting.executeScript({
22
+ target: { tabId: sender.tab.id },
23
+ world: "MAIN",
24
+ func: (code) => {
25
+ if (window.__MCP_BROWSER_LENS__) return;
26
+ try {
27
+ new Function(code).call(window);
28
+ } catch (e) {
29
+ console.error("[BrowserLens Extension] Inject error:", e);
30
+ }
31
+ },
32
+ args: [msg.code]
33
+ }).then(() => {
34
+ sendResponse({ ok: true });
35
+ }).catch((e) => {
36
+ console.error("[BrowserLens Extension] scripting.executeScript failed:", e);
37
+ sendResponse({ error: e.message });
38
+ });
39
+ return true;
40
+ }
18
41
  });
@@ -2,37 +2,24 @@
2
2
  if (window.__MCP_BROWSER_LENS_EXT__) return;
3
3
  window.__MCP_BROWSER_LENS_EXT__ = true;
4
4
 
5
- function inject(cfg) {
5
+ chrome.storage.local.get({ enabled: true, httpPort: 3202 }, function (cfg) {
6
6
  if (!cfg.enabled) return;
7
- var httpPort = cfg.httpPort || 3202;
7
+ var port = cfg.httpPort || 3202;
8
8
 
9
- fetch("http://localhost:" + httpPort + "/connector.js")
9
+ fetch("http://localhost:" + port + "/connector.js")
10
10
  .then(function (r) {
11
11
  if (!r.ok) throw new Error("HTTP " + r.status);
12
12
  return r.text();
13
13
  })
14
14
  .then(function (code) {
15
- try {
16
- new Function(code).call(window);
17
- console.log("[BrowserLens Extension] Injected on " + location.hostname);
18
- } catch (e) {
19
- console.error("[BrowserLens Extension] Inject failed:", e);
20
- }
15
+ chrome.runtime.sendMessage({
16
+ type: "injectScript",
17
+ code: code,
18
+ port: port
19
+ });
21
20
  })
22
21
  .catch(function () {
23
- console.log("[BrowserLens Extension] MCP server not running on port " + httpPort);
22
+ console.log("[BrowserLens Extension] MCP server not reachable on port " + port);
24
23
  });
25
- }
26
-
27
- if (typeof chrome !== "undefined" && chrome.runtime && chrome.runtime.sendMessage) {
28
- chrome.runtime.sendMessage({ type: "getConfig" }, function (cfg) {
29
- if (chrome.runtime.lastError) {
30
- inject({ enabled: true, httpPort: 3202, wsPort: 3203 });
31
- return;
32
- }
33
- inject(cfg || { enabled: true, httpPort: 3202, wsPort: 3203 });
34
- });
35
- } else {
36
- inject({ enabled: true, httpPort: 3202, wsPort: 3203 });
37
- }
24
+ });
38
25
  })();
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "Browser Lens — MCP UI Inspector",
4
- "version": "2.3.1",
5
- "description": "Real-time DOM, CSS, layout inspection for your IDE's AI agent. Connects to Browser Lens MCP server.",
6
- "permissions": ["storage", "activeTab"],
4
+ "version": "3.0.0",
5
+ "description": "Real-time DOM, CSS, layout inspection for your IDE's AI agent. Persists across page reloads.",
6
+ "permissions": ["storage", "scripting", "activeTab"],
7
7
  "host_permissions": ["<all_urls>"],
8
8
  "action": {
9
9
  "default_popup": "popup.html",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browser-lens-mcp",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "description": "MCP server that connects to your browser for real-time DOM, CSS, layout inspection, screenshot capture, and Figma design comparison — your IDE's AI agent sees exactly what users see",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",