-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto-fix linting errors with lint:fix(--lint)
- Loading branch information
Showing
22 changed files
with
468 additions
and
362 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
export const SUPABASE_LOCAL_STORAGE_KEY = "supabase.auth.token" | ||
export const SUPABASE_AUTH_DOMAIN = "ibcwmlhcimymasokhgvn.supabase.co" | ||
export const SUPABASE_COOKIE_NAME = "sb-access-token" | ||
export const SUPABASE_LOGIN_URL = "https://ibcwmlhcimymasokhgvn.supabase.co/auth/v1/authorize?provider=github&redirect_to=https://hot.opensauced.pizza/" | ||
export const SUPABASE_LOGOUT_URL = "https://ibcwmlhcimymasokhgvn.supabase.co/auth/v1/logout" | ||
export const OPEN_SAUCED_AUTH_TOKEN_KEY = "os-access-token" | ||
export const OPEN_SAUCED_USERS_ENDPOINT = "https://api.opensauced.pizza/v1/users" | ||
export const OPEN_SAUCED_SESSION_ENDPOINT = "https://api.opensauced.pizza/v1/auth/session" | ||
export const GITHUB_PROFILE_MENU_SELECTOR = ".p-nickname.vcard-username.d-block" | ||
export const GITHUB_PROFILE_EDIT_MENU_SELECTOR = "button.js-profile-editable-edit-button" | ||
export const SUPABASE_LOCAL_STORAGE_KEY = "supabase.auth.token"; | ||
export const SUPABASE_AUTH_DOMAIN = "ibcwmlhcimymasokhgvn.supabase.co"; | ||
export const SUPABASE_COOKIE_NAME = "sb-access-token"; | ||
export const SUPABASE_LOGIN_URL = "https://ibcwmlhcimymasokhgvn.supabase.co/auth/v1/authorize?provider=github&redirect_to=https://hot.opensauced.pizza/"; | ||
export const SUPABASE_LOGOUT_URL = "https://ibcwmlhcimymasokhgvn.supabase.co/auth/v1/logout"; | ||
export const OPEN_SAUCED_AUTH_TOKEN_KEY = "os-access-token"; | ||
export const OPEN_SAUCED_USERS_ENDPOINT = "https://api.opensauced.pizza/v1/users"; | ||
export const OPEN_SAUCED_SESSION_ENDPOINT = "https://api.opensauced.pizza/v1/auth/session"; | ||
export const GITHUB_PROFILE_MENU_SELECTOR = ".p-nickname.vcard-username.d-block"; | ||
export const GITHUB_PROFILE_EDIT_MENU_SELECTOR = "button.js-profile-editable-edit-button"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,32 @@ | ||
import { checkTokenValidity } from "../utils/fetchOpenSaucedApiData"; | ||
import getAccessToken from "../utils/getAccessToken"; | ||
import setAccessTokenInChromeStorage from "../utils/setAccessToken"; | ||
import {OPEN_SAUCED_AUTH_TOKEN_KEY} from "../constants"; | ||
import { OPEN_SAUCED_AUTH_TOKEN_KEY } from "../constants"; | ||
|
||
const processHotOSHomePage = async () => { | ||
const data = await chrome.storage.sync.get([OPEN_SAUCED_AUTH_TOKEN_KEY]); | ||
if (data[OPEN_SAUCED_AUTH_TOKEN_KEY]) return; | ||
|
||
if (data[OPEN_SAUCED_AUTH_TOKEN_KEY]) { | ||
return; | ||
} | ||
try { | ||
const accessToken = getAccessToken(); | ||
if (!accessToken) return; | ||
|
||
if (!accessToken) { | ||
return; | ||
} | ||
|
||
const isValid = await checkTokenValidity(accessToken); | ||
if (!isValid) return; | ||
|
||
if (!isValid) { | ||
return; | ||
} | ||
|
||
await setAccessTokenInChromeStorage(accessToken); | ||
} catch (error) { | ||
console.error("Error processing Hot home page:", error); | ||
} | ||
}; | ||
|
||
//The local storage takes time to set after the document is idle | ||
// the local storage takes time to set after the document is idle | ||
setTimeout(processHotOSHomePage, 1000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,29 @@ | ||
import { useEffect, useState } from "react" | ||
import { isOpenSaucedUser } from "../utils/fetchOpenSaucedApiData" | ||
import { getGithubUsername } from "../utils/urlMatchers" | ||
import { useEffect, useState } from "react"; | ||
import { isOpenSaucedUser } from "../utils/fetchOpenSaucedApiData"; | ||
import { getGithubUsername } from "../utils/urlMatchers"; | ||
|
||
export const useOpensaucedUserCheck = () => { | ||
const [currentTabIsOpensaucedUser, setCurrentTabIsOpensaucedUser] = useState(false) | ||
const [checkedUser, setCheckedUser] = useState<string|null>(null) | ||
const [currentTabIsOpensaucedUser, setCurrentTabIsOpensaucedUser] = useState(false); | ||
const [checkedUser, setCheckedUser] = useState<string|null>(null); | ||
|
||
useEffect(() => { | ||
//get active tab | ||
chrome.tabs.query({ active: true, currentWindow: true }, async (tabs) => { | ||
// get active tab | ||
chrome.tabs.query({ active: true, currentWindow: true }, async tabs => { | ||
if (tabs.length > 0) { | ||
const tab = tabs[0] | ||
const username = getGithubUsername(tab.url!) | ||
if(username != null) { | ||
setCheckedUser(username) | ||
setCurrentTabIsOpensaucedUser(await isOpenSaucedUser(username)) | ||
const tab = tabs[0]; | ||
const username = getGithubUsername(tab.url!); | ||
|
||
if (username !== null) { | ||
setCheckedUser(username); | ||
setCurrentTabIsOpensaucedUser(await isOpenSaucedUser(username)); | ||
} else { | ||
setCheckedUser(null) | ||
setCurrentTabIsOpensaucedUser(false) | ||
} | ||
setCheckedUser(null); | ||
setCurrentTabIsOpensaucedUser(false); | ||
} | ||
} | ||
}) | ||
}, []) | ||
}); | ||
}, []); | ||
|
||
|
||
return { currentTabIsOpensaucedUser, checkedUser } | ||
} | ||
return { currentTabIsOpensaucedUser, checkedUser }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import React from 'react' | ||
import ReactDOM from 'react-dom/client' | ||
import App from './App' | ||
import './popup.css' | ||
import React from "react"; | ||
import ReactDOM from "react-dom/client"; | ||
import App from "./App"; | ||
import "./popup.css"; | ||
|
||
ReactDOM.createRoot(document.getElementById('root')!).render( | ||
ReactDOM.createRoot(document.getElementById("root")!).render( | ||
<React.StrictMode> | ||
<App /> | ||
</React.StrictMode> | ||
) | ||
</React.StrictMode>, | ||
); |
Oops, something went wrong.