diff --git a/extension/app/src/components/conversation/AttachFragment.tsx b/extension/app/src/components/conversation/AttachFragment.tsx
index 7266283bb841..a58b9dd740ef 100644
--- a/extension/app/src/components/conversation/AttachFragment.tsx
+++ b/extension/app/src/components/conversation/AttachFragment.tsx
@@ -1,20 +1,24 @@
+import type { LightWorkspaceType } from "@dust-tt/client";
import { Button, CameraIcon, DocumentPlusIcon } from "@dust-tt/sparkle";
import { InputBarContext } from "@extension/components/input_bar/InputBarContext";
+import { useCurrentDomain } from "@extension/hooks/useCurrentDomain";
import type { FileUploaderService } from "@extension/hooks/useFileUploaderService";
import { useContext, useEffect } from "react";
type AttachFragmentProps = {
+ owner: LightWorkspaceType;
fileUploaderService: FileUploaderService;
isLoading: boolean;
};
export const AttachFragment = ({
+ owner,
fileUploaderService,
isLoading,
}: AttachFragmentProps) => {
+ // Blinking animation.
const { attachPageBlinking, setAttachPageBlinking } =
useContext(InputBarContext);
-
useEffect(() => {
let timer: NodeJS.Timeout;
if (attachPageBlinking) {
@@ -25,12 +29,23 @@ export const AttachFragment = ({
return () => clearTimeout(timer);
}, [attachPageBlinking]);
+ // Blacklisting logic to disable share buttons.
+ const currentDomain = useCurrentDomain();
+ const blacklistedDomains: string[] = owner.blacklistedDomains ?? [];
+ const isBlacklisted = blacklistedDomains.some((d) =>
+ currentDomain.endsWith(d)
+ );
+
return (
<>
>
diff --git a/extension/app/src/components/input_bar/InputBarContainer.tsx b/extension/app/src/components/input_bar/InputBarContainer.tsx
index 5fd162269f03..34a4327fa4f8 100644
--- a/extension/app/src/components/input_bar/InputBarContainer.tsx
+++ b/extension/app/src/components/input_bar/InputBarContainer.tsx
@@ -134,6 +134,7 @@ export const InputBarContainer = ({
diff --git a/extension/app/src/hooks/useCurrentDomain.ts b/extension/app/src/hooks/useCurrentDomain.ts
new file mode 100644
index 000000000000..6657c906619e
--- /dev/null
+++ b/extension/app/src/hooks/useCurrentDomain.ts
@@ -0,0 +1,63 @@
+import { useEffect, useState } from "react";
+
+export const useCurrentDomain = () => {
+ const [currentDomain, setCurrentDomain] = useState
("");
+
+ useEffect(() => {
+ // Function to update domain from tab.
+ const updateDomainFromTab = (tab: chrome.tabs.Tab) => {
+ if (tab?.url) {
+ try {
+ const url = new URL(tab.url);
+ if (url.protocol.startsWith("http")) {
+ setCurrentDomain(url.hostname);
+ }
+ } catch (e) {
+ console.error("Invalid URL:", e);
+ setCurrentDomain("");
+ }
+ }
+ };
+
+ // Update domain when active tab changes.
+ const handleTabActivated = (activeInfo: chrome.tabs.TabActiveInfo) => {
+ chrome.tabs.get(activeInfo.tabId, (tab) => {
+ updateDomainFromTab(tab);
+ });
+ };
+
+ // Update domain when tab URL changes.
+ const handleTabUpdated = (
+ tabId: number,
+ changeInfo: chrome.tabs.TabChangeInfo,
+ tab: chrome.tabs.Tab
+ ) => {
+ if (changeInfo.status === "complete") {
+ chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
+ if (tabs[0]?.id === tabId) {
+ updateDomainFromTab(tab);
+ }
+ });
+ }
+ };
+
+ // Get initial domain.
+ chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
+ if (tabs[0]) {
+ updateDomainFromTab(tabs[0]);
+ }
+ });
+
+ // Add listeners.
+ chrome.tabs.onActivated.addListener(handleTabActivated);
+ chrome.tabs.onUpdated.addListener(handleTabUpdated);
+
+ // Cleanup listeners.
+ return () => {
+ chrome.tabs.onActivated.removeListener(handleTabActivated);
+ chrome.tabs.onUpdated.removeListener(handleTabUpdated);
+ };
+ }, []);
+
+ return currentDomain;
+};