From 29d1eed84d7b8a9d126d84355d99b6141ecbf018 Mon Sep 17 00:00:00 2001 From: Abdurrahman Rajab Date: Sat, 4 Nov 2023 18:54:12 +0300 Subject: [PATCH 1/7] fix: margin reduced to two --- .../ViewOnOpenSaucedButton/ViewOnOpenSaucedButton.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/content-scripts/components/ViewOnOpenSaucedButton/ViewOnOpenSaucedButton.ts b/src/content-scripts/components/ViewOnOpenSaucedButton/ViewOnOpenSaucedButton.ts index fac8aaea..f7135dca 100644 --- a/src/content-scripts/components/ViewOnOpenSaucedButton/ViewOnOpenSaucedButton.ts +++ b/src/content-scripts/components/ViewOnOpenSaucedButton/ViewOnOpenSaucedButton.ts @@ -7,8 +7,7 @@ export const ViewOnOpenSaucedButton = (username: string) => { const viewOnOpenSaucedButton = createHtmlElement("a", { id: "view-on-opensauced-button", href: `https://${OPEN_SAUCED_INSIGHTS_DOMAIN}/user/${username}/contributions`, - className: - "inline-block my-4 text-black bg-gh-white dark:bg-gh-gray dark:text-white rounded-md p-2 text-sm font-semibold text-center select-none w-full border hover:shadow-button hover:no-underline", + className: "inline-block my-2 text-black bg-gh-white dark:bg-gh-gray dark:text-white rounded-md p-2 text-sm font-semibold text-center select-none w-full border hover:shadow-button hover:no-underline", target: "_blank", rel: "noopener noreferrer", innerHTML: ` From 38ee7014f4832896056add486010381314551a27 Mon Sep 17 00:00:00 2001 From: Abdurrahman Rajab Date: Sat, 4 Nov 2023 18:54:32 +0300 Subject: [PATCH 2/7] fix: add your own profile edge case --- src/utils/dom-utils/viewOnOpenSauced.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/utils/dom-utils/viewOnOpenSauced.ts b/src/utils/dom-utils/viewOnOpenSauced.ts index d82bbf4e..4c79abcf 100644 --- a/src/utils/dom-utils/viewOnOpenSauced.ts +++ b/src/utils/dom-utils/viewOnOpenSauced.ts @@ -12,8 +12,13 @@ const injectViewOnOpenSaucedButton = (username: string) => { GITHUB_PROFILE_USER_PROFILE_EDITABLE_AREA_SELECTOR, ); const editableAreaElement = userEditableArea[0]; - - editableAreaElement.parentNode?.insertBefore(viewOnOpenSaucedButton, editableAreaElement); + const editProfileButtonSelector = ".btn-block.js-profile-editable-edit-button" + const editProfileButton = document.querySelector(editProfileButtonSelector); + if (editProfileButton) { + editProfileButton.parentNode?.insertBefore(viewOnOpenSaucedButton, editProfileButton) + } else { + editableAreaElement.parentNode?.insertBefore(viewOnOpenSaucedButton, editableAreaElement); + } }; export default injectViewOnOpenSaucedButton; From 5b82cc1d3131a2dbacf9644de8845396315ed146 Mon Sep 17 00:00:00 2001 From: Abdurrahman Rajab Date: Sat, 4 Nov 2023 19:20:49 +0300 Subject: [PATCH 3/7] fix: adjust the margin to bottom only --- .../components/ViewOnOpenSaucedButton/ViewOnOpenSaucedButton.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content-scripts/components/ViewOnOpenSaucedButton/ViewOnOpenSaucedButton.ts b/src/content-scripts/components/ViewOnOpenSaucedButton/ViewOnOpenSaucedButton.ts index f7135dca..8a6c0cf2 100644 --- a/src/content-scripts/components/ViewOnOpenSaucedButton/ViewOnOpenSaucedButton.ts +++ b/src/content-scripts/components/ViewOnOpenSaucedButton/ViewOnOpenSaucedButton.ts @@ -7,7 +7,7 @@ export const ViewOnOpenSaucedButton = (username: string) => { const viewOnOpenSaucedButton = createHtmlElement("a", { id: "view-on-opensauced-button", href: `https://${OPEN_SAUCED_INSIGHTS_DOMAIN}/user/${username}/contributions`, - className: "inline-block my-2 text-black bg-gh-white dark:bg-gh-gray dark:text-white rounded-md p-2 text-sm font-semibold text-center select-none w-full border hover:shadow-button hover:no-underline", + className: "inline-block mb-2 text-black bg-gh-white dark:bg-gh-gray dark:text-white rounded-md p-2 text-sm font-semibold text-center select-none w-full border hover:shadow-button hover:no-underline", target: "_blank", rel: "noopener noreferrer", innerHTML: ` From 746fcae4431b06e5d02dd1008eeb283bc183e390 Mon Sep 17 00:00:00 2001 From: Abdurrahman Rajab Date: Sat, 4 Nov 2023 19:21:07 +0300 Subject: [PATCH 4/7] fix: show the button on top of GitHub CTAs --- src/utils/dom-utils/viewOnOpenSauced.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/utils/dom-utils/viewOnOpenSauced.ts b/src/utils/dom-utils/viewOnOpenSauced.ts index 4c79abcf..eeff2198 100644 --- a/src/utils/dom-utils/viewOnOpenSauced.ts +++ b/src/utils/dom-utils/viewOnOpenSauced.ts @@ -17,7 +17,8 @@ const injectViewOnOpenSaucedButton = (username: string) => { if (editProfileButton) { editProfileButton.parentNode?.insertBefore(viewOnOpenSaucedButton, editProfileButton) } else { - editableAreaElement.parentNode?.insertBefore(viewOnOpenSaucedButton, editableAreaElement); + const ButtonArea = document.querySelector(".js-user-profile-follow-button")?.closest(".flex-order-1.flex-md-order-none") + ButtonArea?.insertBefore(viewOnOpenSaucedButton, ButtonArea?.firstChild); } }; From 121587d132d5bb91409358cb68c00e0623c2a52d Mon Sep 17 00:00:00 2001 From: Abdurrahman Rajab Date: Sat, 4 Nov 2023 19:39:12 +0300 Subject: [PATCH 5/7] chore: update the constants file --- src/constants.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/constants.ts b/src/constants.ts index d264f53b..e1a70665 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -31,8 +31,7 @@ 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_PROFILE_USER_PROFILE_BIO_SELECTOR = ".p-note.user-profile-bio.mb-3.js-user-profile-bio.f4"; -export const GITHUB_PROFILE_USER_PROFILE_EDITABLE_AREA_SELECTOR = "js-profile-editable-area d-flex flex-column d-md-block"; +export const GITHUB_PROFILE_USER_PROFILE_EDITABLE_AREA_SELECTOR = ".btn-block.js-profile-editable-edit-button"; export const GITHUB_PR_COMMENT_HEADER_SELECTOR = "timeline-comment-header clearfix d-flex"; export const GITHUB_NEW_PR_COMMENT_EDITOR_SELECTOR = "flex-nowrap d-none d-md-inline-block mr-md-0 mr-3"; export const GITHUB_PR_COMMENT_EDITOR_SELECTOR = "flex-nowrap d-inline-block mr-3"; From 0969cc9458efde0061a95e14d9cdaac4ee2c1930 Mon Sep 17 00:00:00 2001 From: Abdurrahman Rajab Date: Sat, 4 Nov 2023 19:44:31 +0300 Subject: [PATCH 6/7] chore: renaming and removing extra code --- src/constants.ts | 1 - src/utils/dom-utils/viewOnOpenSauced.ts | 10 +++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/constants.ts b/src/constants.ts index e1a70665..a2183cfe 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -31,7 +31,6 @@ 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_PROFILE_USER_PROFILE_EDITABLE_AREA_SELECTOR = ".btn-block.js-profile-editable-edit-button"; export const GITHUB_PR_COMMENT_HEADER_SELECTOR = "timeline-comment-header clearfix d-flex"; export const GITHUB_NEW_PR_COMMENT_EDITOR_SELECTOR = "flex-nowrap d-none d-md-inline-block mr-md-0 mr-3"; export const GITHUB_PR_COMMENT_EDITOR_SELECTOR = "flex-nowrap d-inline-block mr-3"; diff --git a/src/utils/dom-utils/viewOnOpenSauced.ts b/src/utils/dom-utils/viewOnOpenSauced.ts index eeff2198..049aa76f 100644 --- a/src/utils/dom-utils/viewOnOpenSauced.ts +++ b/src/utils/dom-utils/viewOnOpenSauced.ts @@ -1,4 +1,3 @@ -import { GITHUB_PROFILE_USER_PROFILE_EDITABLE_AREA_SELECTOR } from "../../constants"; import { ViewOnOpenSaucedButton } from "../../content-scripts/components/ViewOnOpenSaucedButton/ViewOnOpenSaucedButton"; const injectViewOnOpenSaucedButton = (username: string) => { @@ -8,17 +7,14 @@ const injectViewOnOpenSaucedButton = (username: string) => { const viewOnOpenSaucedButton = ViewOnOpenSaucedButton(username); - const userEditableArea = document.getElementsByClassName( - GITHUB_PROFILE_USER_PROFILE_EDITABLE_AREA_SELECTOR, - ); - const editableAreaElement = userEditableArea[0]; const editProfileButtonSelector = ".btn-block.js-profile-editable-edit-button" const editProfileButton = document.querySelector(editProfileButtonSelector); + if (editProfileButton) { editProfileButton.parentNode?.insertBefore(viewOnOpenSaucedButton, editProfileButton) } else { - const ButtonArea = document.querySelector(".js-user-profile-follow-button")?.closest(".flex-order-1.flex-md-order-none") - ButtonArea?.insertBefore(viewOnOpenSaucedButton, ButtonArea?.firstChild); + const callToActionButtonsArea = document.querySelector(".js-user-profile-follow-button")?.closest(".flex-order-1.flex-md-order-none") + callToActionButtonsArea?.insertBefore(viewOnOpenSaucedButton, callToActionButtonsArea?.firstChild); } }; From 12e20e52c9525c9b78f7076135ee6c0ddd523814 Mon Sep 17 00:00:00 2001 From: Abdurrahman Rajab Date: Sun, 5 Nov 2023 00:11:36 +0300 Subject: [PATCH 7/7] chore: lint --- src/utils/dom-utils/viewOnOpenSauced.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/utils/dom-utils/viewOnOpenSauced.ts b/src/utils/dom-utils/viewOnOpenSauced.ts index 049aa76f..dcc95943 100644 --- a/src/utils/dom-utils/viewOnOpenSauced.ts +++ b/src/utils/dom-utils/viewOnOpenSauced.ts @@ -7,14 +7,15 @@ const injectViewOnOpenSaucedButton = (username: string) => { const viewOnOpenSaucedButton = ViewOnOpenSaucedButton(username); - const editProfileButtonSelector = ".btn-block.js-profile-editable-edit-button" + const editProfileButtonSelector = ".btn-block.js-profile-editable-edit-button"; const editProfileButton = document.querySelector(editProfileButtonSelector); if (editProfileButton) { - editProfileButton.parentNode?.insertBefore(viewOnOpenSaucedButton, editProfileButton) + editProfileButton.parentNode?.insertBefore(viewOnOpenSaucedButton, editProfileButton); } else { - const callToActionButtonsArea = document.querySelector(".js-user-profile-follow-button")?.closest(".flex-order-1.flex-md-order-none") - callToActionButtonsArea?.insertBefore(viewOnOpenSaucedButton, callToActionButtonsArea?.firstChild); + const callToActionButtonsArea = document.querySelector(".js-user-profile-follow-button")?.closest(".flex-order-1.flex-md-order-none"); + + callToActionButtonsArea?.insertBefore(viewOnOpenSaucedButton, callToActionButtonsArea.firstChild); } };