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

Support for firefox #115

Merged
merged 1 commit into from
Feb 29, 2024
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
6 changes: 3 additions & 3 deletions src/pages/background/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const senderIsPopup = (sender: chrome.runtime.MessageSender) => {
const origin = "chrome-extension://" + chrome.runtime.id;
const popupPath = origin + "/src/pages/popup/index.html";
return sender.origin === origin && sender.url === popupPath;
return ((sender.url?.startsWith('moz-extension://') || sender.url?.startsWith('chrome-extension://'))&&
sender.url?.endsWith('/src/pages/popup/index.html') &&
sender.id === chrome.runtime.id);
};

export const isValidUrl = (str: string) => {
Expand Down
11 changes: 8 additions & 3 deletions src/pages/content/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ window.addEventListener(
});

let filteredSignins: any[] = [];
console.log(event.data.type);
tabSigninResp?.data?.signins.forEach((signin: any) => {
if (
signin.identifier &&
Expand Down Expand Up @@ -98,7 +97,8 @@ chrome.runtime.onMessage.addListener(async function (
sender,
sendResponse
) {
if (sender.origin === "chrome-extension://" + chrome.runtime.id) {
if ((sender.url?.startsWith("moz-extension://") || sender.origin?.startsWith("chrome-extension://")) &&
sender.id === chrome.runtime.id) {
console.log(
"Message received from browser extension: " +
message.type +
Expand Down Expand Up @@ -135,7 +135,12 @@ chrome.runtime.onMessage.addListener(async function (
}

if (message.type === "tab" && message.subtype === "get-tab-state") {
sendResponse({ data: { appState: getTabState() } });
if (sender.origin?.startsWith("chrome-extension://")){
sendResponse({ data: { appState: getTabState() } });
} else {
return Promise.resolve({ data: { appState: getTabState() } })
}

}

if (message.type === "tab" && message.subtype === "set-tab-state") {
Expand Down
1 change: 0 additions & 1 deletion src/pages/popup/Popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export default function Popup(): JSX.Element {
if (data.isConnected) {
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
if (tabs.length === 1) {
console.log("realoading tab");
chrome.tabs.sendMessage(tabs[0].id!, {
type: "tab",
subtype: "reload-state",
Expand Down
8 changes: 3 additions & 5 deletions src/pages/popup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ function init() {
sender,
sendResponse
) {
if (
sender.url ===
"chrome-extension://" +
chrome.runtime.id +
"/service-worker-loader.js" &&
if ((sender.url?.startsWith('moz-extension://') || sender.url?.startsWith('chrome-extension://')) &&
sender.url?.endsWith('/service-worker-loader.js') &&
sender.id === chrome.runtime.id &&
request.type === "popup" &&
request.subtype === "isOpened"
) {
Expand Down