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

WIP: Firefox #258

Closed
wants to merge 5 commits into from
Closed
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
10 changes: 8 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}
],
"background": {
"service_worker": "src/worker/background.ts",
"scripts": ["src/worker/background.ts"],
"type": "module"
},
"icons": {
Expand All @@ -21,5 +21,11 @@
"128": "src/assets/os-icons/os-icon-128.png"
},
"host_permissions": ["https://github.com/*", "https://*.insights.opensauced.pizza/*" , "https://www.linkedin.com/*"],
"permissions": ["scripting", "storage", "tabs", "cookies"]
"permissions": ["scripting", "storage", "tabs", "cookies"],
"browser_specific_settings": {
"gecko": {
"id": "[email protected]",
"strict_min_version": "1.0"
}
}
}
16 changes: 11 additions & 5 deletions src/utils/checkAuthentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,20 @@ export const getAuthToken = async (): Promise<string> => (await chrome.storage.s

export const optLogOut = () => {
void removeAuthTokenFromStorage();
void chrome.storage.local.set({ [OPEN_SAUCED_OPTED_LOG_OUT_KEY]: true });
const optedLogOut = { [OPEN_SAUCED_OPTED_LOG_OUT_KEY]: true };

void chrome.storage.local.set(optedLogOut);
};

export const optLogIn = async () => {
if (typeof window === "undefined") {
return;
}
void chrome.storage.local.set({ [OPEN_SAUCED_OPTED_LOG_OUT_KEY]: false });
// TODO: Figure out a better check here or remove it as window is always undefined in Firefox.
// if (typeof window === "undefined") {
// return;
// }

const optedLogOut = { [OPEN_SAUCED_OPTED_LOG_OUT_KEY]: true };

void chrome.storage.local.set(optedLogOut);

const verifier = generatePKCEVerifier();
const challenge = await generatePKCEChallenge(verifier);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/colorPreference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const prefersDarkMode = (cookieString: string): boolean => {
const regex = /(?<=\bcolor_mode=)[^;]+/g;
const match = regex.exec(cookieString);
const cookie = match && JSON.parse(decodeURIComponent(match[0]));
const colorScheme: ColorScheme = cookie.color_mode ?? "auto";
const colorScheme: ColorScheme = cookie?.color_mode ?? "auto";

if (colorScheme === "auto") {
return window.matchMedia("(prefers-color-scheme: dark)").matches;
Expand Down
12 changes: 11 additions & 1 deletion src/worker/background.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
import { setDefaultDescriptionConfig } from "../utils/ai-utils/descriptionconfig";

chrome.runtime.onInstalled.addListener(setDefaultDescriptionConfig);
// not sure why the linter/prettier are fighting between two and four spaces here
declare global {
interface Window {
browser: typeof chrome;
}

// eslint-disable-next-line no-var
var browser: typeof chrome;
}

browser.runtime.onInstalled.addListener(setDefaultDescriptionConfig);
Loading