Skip to content

Commit

Permalink
feat: support firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewinci committed Mar 19, 2023
1 parent 526c2a4 commit d22ad7c
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 20 deletions.
16 changes: 5 additions & 11 deletions public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,13 @@
},
"content_scripts": [
{
"js": [
"assets/script.js"
],
"matches": [
"https://excalidraw.com/*"
]
"run_at": "document_start",
"js": ["assets/script.js"],
"matches": ["https://excalidraw.com/*"]
}
],
"action": {
"default_popup": "index.html"
},
"permissions": [
"storage",
"unlimitedStorage"
]
}
"permissions": ["storage", "unlimitedStorage"]
}
4 changes: 2 additions & 2 deletions src/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ const sendReceiveMessageChrome: sendReceiveMessageType = async (
export const sendReceiveMessage = sendReceiveMessageChrome;

// *** TABS ***
export const createTab = async (url: string) =>
await chrome.tabs.create({ url });
export const createTab = async (url: string, callback: () => void) =>
await chrome.tabs.create({ url }, callback);

// *** On message received ***
export function onMessageReceived<T, R>(
Expand Down
6 changes: 3 additions & 3 deletions src/components/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export type ModalProps = {
description?: string | ReactJSXElement;
opened: boolean;
icons?: "OK" | "Ignore" | "OkIgnore" | "None";
onSubmit: (response: "Ok" | "Ignore") => void;
onSubmit?: (response: "Ok" | "Ignore") => void;
};

export const Modal = (props: ModalProps) => {
Expand Down Expand Up @@ -63,14 +63,14 @@ export const Modal = (props: ModalProps) => {
>
<Button
hidden={icons === "None" || icons === "Ignore"}
onClick={() => onSubmit("Ok")}
onClick={() => onSubmit?.("Ok")}
color="red"
>
Ok
</Button>
<Button
hidden={icons === "None" || icons === "OK"}
onClick={() => onSubmit("Ignore")}
onClick={() => onSubmit?.("Ignore")}
color="green"
>
Ignore
Expand Down
5 changes: 3 additions & 2 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ const App = () => {
<Group margin="25px 0 0 0">
<Button
color="green"
onClick={() => createTab("https://excalidraw.com/")}
onClick={() =>
createTab("https://excalidraw.com/", () => checkIsAlive())
}
>
Go to Excalidraw
</Button>
Expand All @@ -139,7 +141,6 @@ const App = () => {
}
opened={true}
icons={"None"}
onSubmit={checkIsAlive}
/>
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ onMessageReceived<PopUpMessage, ScriptMessage>((request, sendResponse) => {
break;
}
});

console.log("Loaded");
export {};
4 changes: 3 additions & 1 deletion src/style/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { css } from "@emotion/react";
import virgil from "./Virgil.woff2";

export const POP_UP_WIDTH = 500;
export const POP_UP_HEIGHT = 450;
export const POP_UP_HEIGHT = 460;

export const GlobalStyles = css`
@font-face {
Expand All @@ -14,9 +14,11 @@ export const GlobalStyles = css`
font-family: "virgil";
}
html {
width: ${POP_UP_WIDTH}px;
min-width: ${POP_UP_WIDTH}px;
max-width: ${POP_UP_WIDTH}px;
height: ${POP_UP_HEIGHT}px;
min-height: ${POP_UP_HEIGHT}px;
max-height: ${POP_UP_HEIGHT}px;
Expand Down

0 comments on commit d22ad7c

Please sign in to comment.