Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BDE-240: Fix broken user context #76

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/main/content-script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(async () => {
let connected;

try {
const response = await fetch('/nuxeo/json/cmis');
// Some pages can return an HTML page with 404 message on it.
// We should validate that the response is a json object.
await response.json();
connected = response.ok;
} catch (error) {
connected = false;
}

if (!connected) {
await chrome.runtime.sendMessage({
extension: 'nuxeo-web-extension',
component: 'serverConnector',
action: 'disconnect',
params: []
});
}
})();
11 changes: 10 additions & 1 deletion src/main/manifest-chrome.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,14 @@
},
"default_title": "Nuxeo Dev Tools",
"default_popup": "popup/index.html"
}
},
"content_scripts": [
{
"matches": [
"http://*/*",
"https://*/*"
],
"js": ["content-script.js"]
}
]
}
9 changes: 9 additions & 0 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@ export default defineConfig(({ mode }) => {
],
hook: 'writeBundle', // run the plugin at the end of bundling
}),
copy({
targets: [
{
src: 'src/main/content-script.js',
dest: `dist/${browserVendor}`,
}
],
// hook: 'writeBundle', // run the plugin at the end of bundling
}),
htmlReparent({ browserVendor, buildEntry, sourceDir: 'src', outputDir: `dist/${browserVendor}` }),
mainReparent({ browserVendor, buildEntry, sourceDir: 'src', outputDir: `dist/${browserVendor}` }),
astPatch({ browserVendor, buildEntry }),
Expand Down
Loading