Skip to content
Open
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
11 changes: 6 additions & 5 deletions apps/browser-extension/entrypoints/content/twitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
MESSAGE_TYPES,
POSTHOG_EVENT_KEY,
STORAGE_KEYS,
TWITTER_BOOKMARKS_PATH,
UI_CONFIG,
} from "../../utils/constants"
import { trackEvent } from "../../utils/posthog"
Expand Down Expand Up @@ -86,9 +87,9 @@ export async function initializeTwitter() {
return
}

if (window.location.pathname === "/i/bookmarks") {
if (window.location.pathname === TWITTER_BOOKMARKS_PATH) {
setTimeout(async () => {
if (window.location.pathname === "/i/bookmarks") {
if (window.location.pathname === TWITTER_BOOKMARKS_PATH) {
await handleBookmarksPageLoad()
}
}, 2000)
Expand All @@ -102,7 +103,7 @@ export async function initializeTwitter() {
* Handle what to show when user lands on bookmarks page
*/
async function handleBookmarksPageLoad() {
if (window.location.pathname !== "/i/bookmarks") {
if (window.location.pathname !== TWITTER_BOOKMARKS_PATH) {
return
}

Expand Down Expand Up @@ -589,7 +590,7 @@ export async function handleTwitterNavigation() {
return
}

if (window.location.pathname === "/i/bookmarks") {
if (window.location.pathname === TWITTER_BOOKMARKS_PATH) {
addTwitterImportButtonForFolders()
await handleBookmarksPageLoad()
} else {
Expand All @@ -601,7 +602,7 @@ export async function handleTwitterNavigation() {
* Adds import buttons to bookmark folders
*/
function addTwitterImportButtonForFolders() {
if (window.location.pathname !== "/i/bookmarks") {
if (window.location.pathname !== TWITTER_BOOKMARKS_PATH) {
return
}

Expand Down
11 changes: 7 additions & 4 deletions apps/browser-extension/entrypoints/popup/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {
getSupermemoryLoginUrl,
MESSAGE_TYPES,
STORAGE_KEYS,
TWITTER_BOOKMARKS_PATH,
TWITTER_BOOKMARKS_PAGE_URL,
UI_CONFIG,
} from "../../utils/constants"
import {
Expand Down Expand Up @@ -484,17 +486,18 @@ function App() {
}

const handleTwitterBookmarksImport = async () => {
const targetUrl = "https://x.com/i/bookmarks"
const targetUrl = TWITTER_BOOKMARKS_PAGE_URL

try {
const [activeTab] = await chrome.tabs.query({
active: true,
currentWindow: true,
})

const isOnBookmarksPage =
activeTab?.url?.includes("x.com/i/bookmarks") ||
activeTab?.url?.includes("twitter.com/i/bookmarks")
const activePathname = activeTab?.url
? new URL(activeTab.url).pathname
: ""
const isOnBookmarksPage = activePathname === TWITTER_BOOKMARKS_PATH

if (isOnBookmarksPage && activeTab?.id) {
try {
Expand Down
3 changes: 3 additions & 0 deletions apps/browser-extension/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ export const DOMAINS = {
SUPERMEMORY: ["localhost", "supermemory.ai", "app.supermemory.ai"],
} as const

export const TWITTER_BOOKMARKS_PATH = "/i/history"
export const TWITTER_BOOKMARKS_PAGE_URL = `https://x.com${TWITTER_BOOKMARKS_PATH}`

/**
* Container Tags
*/
Expand Down