diff --git a/src/constants.ts b/src/constants.ts index f087bdd4..470753b3 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -30,13 +30,13 @@ export const OPEN_SAUCED_EMOJIS_ENDPOINT = `${OPEN_SAUCED_API_ENDPOINT}/emojis`; // Content-scripts selectors 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 GITHUB_PR_COMMENT_HEADER_SELECTOR = "timeline-comment-header clearfix d-flex"; -export const GITHUB_REVIEW_SUGGESTION_SELECTOR = "js-suggestion-button-placeholder"; +export const GITHUB_PROFILE_EDIT_MENU_CLASS = "button.js-profile-editable-edit-button"; +export const GITHUB_PR_COMMENT_HEADER_CLASS = "timeline-comment-header clearfix d-flex"; +export const GITHUB_REVIEW_SUGGESTION_CLASS = "js-suggestion-button-placeholder"; export const GITHUB_REPO_ACTIONS_SELECTOR = ".pagehead-actions"; -export const GITHUB_PR_COMMENT_TEXT_AREA_SELECTOR = "pull_request[body]"; -export const GITHUB_PR_SUGGESTION_TEXT_AREA_SELECTOR = "[name='comment[body]']"; -export const GITHUB_PR_BASE_BRANCH_SELECTOR = "css-truncate css-truncate-target"; +export const GITHUB_PR_COMMENT_TEXT_AREA_CLASS = "pull_request[body]"; +export const GITHUB_PR_SUGGESTION_TEXT_AREA_Attribute = "[name='comment[body]']"; +export const GITHUB_PR_BASE_BRANCH_CLASS = "css-truncate css-truncate-target"; export const LINKEDIN_PROJECT_FORM_SELECTOR = ".artdeco-text-input--input"; // External Links diff --git a/src/content-scripts/components/AICodeReview/AICodeReviewMenu.ts b/src/content-scripts/components/AICodeReview/AICodeReviewMenu.ts index 9c52ba7a..dc5c05a2 100644 --- a/src/content-scripts/components/AICodeReview/AICodeReviewMenu.ts +++ b/src/content-scripts/components/AICodeReview/AICodeReviewMenu.ts @@ -1,4 +1,4 @@ -import { GITHUB_PR_SUGGESTION_TEXT_AREA_SELECTOR } from "../../../constants"; +import { GITHUB_PR_SUGGESTION_TEXT_AREA_Attribute } from "../../../constants"; import { insertTextAtCursor } from "../../../utils/ai-utils/cursorPositionInsert"; import { DescriptionConfig, @@ -130,7 +130,7 @@ const handleSubmit = async ( return console.error("No description was generated!"); } const textArea = commentNode.querySelector( - GITHUB_PR_SUGGESTION_TEXT_AREA_SELECTOR, + GITHUB_PR_SUGGESTION_TEXT_AREA_Attribute, )!; insertTextAtCursor(textArea as HTMLTextAreaElement, suggestionStream); diff --git a/src/content-scripts/components/GenerateAIDescription/DescriptionGeneratorButton.ts b/src/content-scripts/components/GenerateAIDescription/DescriptionGeneratorButton.ts index dd6a1a61..8c65d4e0 100644 --- a/src/content-scripts/components/GenerateAIDescription/DescriptionGeneratorButton.ts +++ b/src/content-scripts/components/GenerateAIDescription/DescriptionGeneratorButton.ts @@ -3,7 +3,7 @@ import openSaucedLogoIcon from "../../../assets/opensauced-icon.svg"; import { getPullRequestAPIURL } from "../../../utils/urlMatchers"; import { getDescriptionContext, isOutOfContextBounds } from "../../../utils/fetchGithubAPIData"; import { generateDescription } from "../../../utils/ai-utils/openai"; -import { GITHUB_PR_COMMENT_TEXT_AREA_SELECTOR } from "../../../constants"; +import { GITHUB_PR_COMMENT_TEXT_AREA_CLASS } from "../../../constants"; import { insertTextAtCursor } from "../../../utils/ai-utils/cursorPositionInsert"; import { getAIDescriptionConfig } from "../../../utils/ai-utils/descriptionconfig"; import { getAuthToken, isLoggedIn, optLogIn } from "../../../utils/checkAuthentication"; @@ -50,7 +50,7 @@ const handleSubmit = async () => { logo.classList.toggle("animate-spin"); button.classList.toggle("pointer-events-none"); - const textArea = document.getElementsByName(GITHUB_PR_COMMENT_TEXT_AREA_SELECTOR)[0] as HTMLTextAreaElement; + const textArea = document.getElementsByName(GITHUB_PR_COMMENT_TEXT_AREA_CLASS)[0] as HTMLTextAreaElement; insertTextAtCursor(textArea, descriptionStream); } catch (error: unknown) { diff --git a/src/utils/dom-utils/addPRToHighlights.ts b/src/utils/dom-utils/addPRToHighlights.ts index 4d2f5792..26709de7 100644 --- a/src/utils/dom-utils/addPRToHighlights.ts +++ b/src/utils/dom-utils/addPRToHighlights.ts @@ -1,5 +1,5 @@ import { AddPRToHighlightsButton } from "../../content-scripts/components/AddPRToHighlights/AddPRToHighlightsButton"; -import { GITHUB_PR_COMMENT_HEADER_SELECTOR } from "../../constants"; +import { GITHUB_PR_COMMENT_HEADER_CLASS } from "../../constants"; import { isLoggedIn } from "../checkAuthentication"; import { isPublicRepository } from "../fetchGithubAPIData"; @@ -9,7 +9,7 @@ const injectAddPRToHighlightsButton = async () => { } const commentFormatRow = document.getElementsByClassName( - GITHUB_PR_COMMENT_HEADER_SELECTOR, + GITHUB_PR_COMMENT_HEADER_CLASS, )[0]; const addPRToHighlightsButton = AddPRToHighlightsButton(); diff --git a/src/utils/dom-utils/changeSuggestorButton.ts b/src/utils/dom-utils/changeSuggestorButton.ts index d91ccdda..5d70e334 100644 --- a/src/utils/dom-utils/changeSuggestorButton.ts +++ b/src/utils/dom-utils/changeSuggestorButton.ts @@ -1,5 +1,5 @@ import { AICodeReviewButton } from "../../content-scripts/components/AICodeReview/AICodeReviewButton"; -import { GITHUB_REVIEW_SUGGESTION_SELECTOR } from "../../constants"; +import { GITHUB_REVIEW_SUGGESTION_CLASS } from "../../constants"; import { isPublicRepository } from "../fetchGithubAPIData"; import { SettingsConfig } from "../../popup/pages/settings"; @@ -22,7 +22,7 @@ const injectChangeSuggestorButton = async (commentNode: HTMLElement) => { } } - const suggestChangesIcon = commentNode.getElementsByClassName(GITHUB_REVIEW_SUGGESTION_SELECTOR)[0]; + const suggestChangesIcon = commentNode.getElementsByClassName(GITHUB_REVIEW_SUGGESTION_CLASS)[0]; const changeSuggestorButton = AICodeReviewButton(commentNode); if (suggestChangesIcon.querySelector("#os-ai-change-gen")) {