mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-05-19 07:42:43 +00:00
unable to get the message through
This commit is contained in:
parent
a1b3a1f223
commit
f6c2e220a3
6 changed files with 32 additions and 12 deletions
|
|
@ -31,6 +31,16 @@
|
|||
"http://supermemory.com/*"
|
||||
]
|
||||
},
|
||||
"firefox:content_scripts": [{
|
||||
"matches": [
|
||||
"http://localhost:3000/*",
|
||||
"https://supermemory.ai/*",
|
||||
"https://beta.supermemory.ai/*",
|
||||
"http://supermemory.com/*"
|
||||
],
|
||||
"js": ["src/firefox/content.ts"]
|
||||
}
|
||||
],
|
||||
"icons": {
|
||||
"16": "images/icon/16.png",
|
||||
"32": "images/icon/32.png",
|
||||
|
|
|
|||
|
|
@ -154,7 +154,6 @@ registerMessageHandler<MessageType>(
|
|||
target: { tabId: currentTab.id },
|
||||
files: ["scripts/content.js"],
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
console.error("Error injecting content script:", error);
|
||||
}
|
||||
|
|
|
|||
9
apps/extension/src/firefox/content.ts
Normal file
9
apps/extension/src/firefox/content.ts
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
const handleWindowMessage = (event: MessageEvent) => {
|
||||
if (event.data.action === "exportBookmarks") {
|
||||
console.log("Received exportBookmarks message via postMessage");
|
||||
chrome.runtime.sendMessage({ action: "exportBookmarks" });
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener("message", handleWindowMessage);
|
||||
|
||||
|
|
@ -366,6 +366,16 @@ const getBookmarks = async (cursor = "", totalImported = 0, allTweets = []) => {
|
|||
};
|
||||
|
||||
export const setupTwitterHeaderListener = () => {
|
||||
const extraOptions =
|
||||
chrome.runtime.getManifest().manifest_version === 2
|
||||
? ["blocking", "requestHeaders"]
|
||||
: ["requestHeaders"];
|
||||
|
||||
// Add extraHeaders only if we're on a Chromium-based browser
|
||||
if (!navigator.userAgent.includes("Firefox")) {
|
||||
extraOptions.push("extraHeaders");
|
||||
}
|
||||
|
||||
chrome.webRequest.onBeforeSendHeaders.addListener(
|
||||
(details) => {
|
||||
try {
|
||||
|
|
@ -426,16 +436,6 @@ export const setupTwitterHeaderListener = () => {
|
|||
const cookie = getHeaderValue("cookie");
|
||||
const csrf = getHeaderValue("x-csrf-token");
|
||||
|
||||
// // Validate required headers
|
||||
// if (!auth || !cookie || !csrf) {
|
||||
// console.warn("Missing required headers", {
|
||||
// hasAuth: !!auth,
|
||||
// hasCookie: !!cookie,
|
||||
// hasCsrf: !!csrf,
|
||||
// });
|
||||
// return;
|
||||
// }
|
||||
|
||||
// Only update storage if values have changed
|
||||
if (
|
||||
result.cookie !== cookie ||
|
||||
|
|
@ -465,6 +465,6 @@ export const setupTwitterHeaderListener = () => {
|
|||
}
|
||||
},
|
||||
{ urls: ["*://x.com/*", "*://twitter.com/*"] },
|
||||
["requestHeaders", "extraHeaders"]
|
||||
extraOptions
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -98,6 +98,7 @@ export const getIntegrations = (
|
|||
console.log("Response:", response);
|
||||
},
|
||||
);
|
||||
await window.postMessage({ action: "exportBookmarks" }, "*");
|
||||
console.log("Message sent");
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@
|
|||
"@supermemory/db": "workspace:*",
|
||||
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
|
||||
"@types/better-sqlite3": "^7.6.11",
|
||||
"@types/firefox": "^0.0.34",
|
||||
"@types/prismjs": "^1.26.5",
|
||||
"@types/react-virtualized": "^9.21.30",
|
||||
"@udecode/cn": "^39.0.0",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue