diff --git a/packages/chrome-extension/icons/128.vitepress.png b/packages/chrome-extension/icons/128.vitepress.png new file mode 100644 index 000000000..f1428ccc0 Binary files /dev/null and b/packages/chrome-extension/icons/128.vitepress.png differ diff --git a/packages/chrome-extension/icons/16.vitepress.png b/packages/chrome-extension/icons/16.vitepress.png new file mode 100644 index 000000000..4c1515e5c Binary files /dev/null and b/packages/chrome-extension/icons/16.vitepress.png differ diff --git a/packages/chrome-extension/icons/48.vitepress.png b/packages/chrome-extension/icons/48.vitepress.png new file mode 100644 index 000000000..cabc49673 Binary files /dev/null and b/packages/chrome-extension/icons/48.vitepress.png differ diff --git a/packages/chrome-extension/popups/disabled.vitepress.html b/packages/chrome-extension/popups/disabled.vitepress.html new file mode 100644 index 000000000..3c7b51f64 --- /dev/null +++ b/packages/chrome-extension/popups/disabled.vitepress.html @@ -0,0 +1,8 @@ + + + +

+ VitePress + Vue.js is detected on this page.
+ Devtools inspection is not available because it's in production mode or + explicitly disabled by the author. +

diff --git a/packages/chrome-extension/popups/enabled.vitepress.html b/packages/chrome-extension/popups/enabled.vitepress.html new file mode 100644 index 000000000..267db98f2 --- /dev/null +++ b/packages/chrome-extension/popups/enabled.vitepress.html @@ -0,0 +1,23 @@ + + + +
+
+ Screenshot +
+ +
+

+ VitePress + Vue.js is detected on this page.
+ Open DevTools and look for the Vue panel. +

+ +

+ Troubleshooting +

+
+
diff --git a/packages/chrome-extension/src/background.ts b/packages/chrome-extension/src/background.ts index 4b2735a01..21e0fbd90 100644 --- a/packages/chrome-extension/src/background.ts +++ b/packages/chrome-extension/src/background.ts @@ -90,7 +90,12 @@ chrome.runtime.onConnect.addListener((port) => { chrome.runtime.onMessage.addListener((req, sender) => { if (sender.tab && req.vueDetected) { - const suffix = req.nuxtDetected ? '.nuxt' : '' + let suffix = '' + + if (req.nuxtDetected) + suffix = '.nuxt' + else if (req.vitePressDetected) + suffix = '.vitepress' chrome.action.setIcon({ tabId: sender.tab.id, diff --git a/packages/chrome-extension/src/detector.ts b/packages/chrome-extension/src/detector.ts index fb9950617..aa0a953f6 100644 --- a/packages/chrome-extension/src/detector.ts +++ b/packages/chrome-extension/src/detector.ts @@ -26,7 +26,21 @@ function detect(win: Window) { return } - // 2. check Vue + // 2. check VitePress + // @ts-expect-error types + const vitePressDetected = !!(window.__VITEPRESS__) + if (vitePressDetected) { + sendMessage({ + devtoolsEnabled: window.__VUE_DEVTOOLS_GLOBAL_HOOK__ && window.__VUE_DEVTOOLS_GLOBAL_HOOK__.enabled, + vueDetected: true, + vitePressDetected: true, + vitePluginDetected: !!window.__VUE_DEVTOOLS_VITE_PLUGIN_DETECTED__, + vitePluginClientUrl: window.__VUE_DEVTOOLS_VITE_PLUGIN_CLIENT_URL__, + }) + return + } + + // 3. check Vue // @ts-expect-error types const vueDetected = !!(window.__VUE__) if (vueDetected) { diff --git a/packages/firefox-extension/popups/disabled.vitepress.html b/packages/firefox-extension/popups/disabled.vitepress.html new file mode 100644 index 000000000..3c7b51f64 --- /dev/null +++ b/packages/firefox-extension/popups/disabled.vitepress.html @@ -0,0 +1,8 @@ + + + +

+ VitePress + Vue.js is detected on this page.
+ Devtools inspection is not available because it's in production mode or + explicitly disabled by the author. +

diff --git a/packages/firefox-extension/popups/enabled.vitepress.html b/packages/firefox-extension/popups/enabled.vitepress.html new file mode 100644 index 000000000..267db98f2 --- /dev/null +++ b/packages/firefox-extension/popups/enabled.vitepress.html @@ -0,0 +1,23 @@ + + + +
+
+ Screenshot +
+ +
+

+ VitePress + Vue.js is detected on this page.
+ Open DevTools and look for the Vue panel. +

+ +

+ Troubleshooting +

+
+
diff --git a/packages/firefox-extension/src/background.ts b/packages/firefox-extension/src/background.ts index 34bd86ba6..e165aa13e 100644 --- a/packages/firefox-extension/src/background.ts +++ b/packages/firefox-extension/src/background.ts @@ -88,7 +88,12 @@ chrome.runtime.onConnect.addListener((port) => { chrome.runtime.onMessage.addListener((req, sender) => { if (sender.tab && req.vueDetected) { - const suffix = req.nuxtDetected ? '.nuxt' : '' + let suffix = '' + + if (req.nuxtDetected) + suffix = '.nuxt' + else if (req.vitePressDetected) + suffix = '.vitepress' chrome.browserAction.setIcon({ tabId: sender.tab.id, diff --git a/packages/firefox-extension/src/detector.ts b/packages/firefox-extension/src/detector.ts index fb9950617..aa0a953f6 100644 --- a/packages/firefox-extension/src/detector.ts +++ b/packages/firefox-extension/src/detector.ts @@ -26,7 +26,21 @@ function detect(win: Window) { return } - // 2. check Vue + // 2. check VitePress + // @ts-expect-error types + const vitePressDetected = !!(window.__VITEPRESS__) + if (vitePressDetected) { + sendMessage({ + devtoolsEnabled: window.__VUE_DEVTOOLS_GLOBAL_HOOK__ && window.__VUE_DEVTOOLS_GLOBAL_HOOK__.enabled, + vueDetected: true, + vitePressDetected: true, + vitePluginDetected: !!window.__VUE_DEVTOOLS_VITE_PLUGIN_DETECTED__, + vitePluginClientUrl: window.__VUE_DEVTOOLS_VITE_PLUGIN_CLIENT_URL__, + }) + return + } + + // 3. check Vue // @ts-expect-error types const vueDetected = !!(window.__VUE__) if (vueDetected) {