Skip to content

Commit

Permalink
feat: support changing homepage's icons
Browse files Browse the repository at this point in the history
  • Loading branch information
so1ve committed Jul 29, 2023
1 parent 0784b37 commit f79f22f
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions script.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@
const NAVBAR_LOGO_SELECTOR =
'div[data-testid="TopNavBar"] > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(2)';
const PLACEHOLDER_SELECTOR = "#placeholder";
const HOMEPAGE_ICON_SELECTOR = "main > div > div > div > div > div > svg";
const HOMEPAGE_LEFT_ICON_SELECTOR =
"main > div > div > div > div:nth-child(2) > div > svg";
const LOGOUT_ICON_SELECTOR =
'div[data-testid="confirmationSheetDialog"] > svg';

Expand All @@ -90,6 +93,10 @@
const makeTwitterLogoStyle = createStyleMaker(LOGO_SELECTOR);
const makeTwitterNavbarLogoStyle = createStyleMaker(NAVBAR_LOGO_SELECTOR);
const makePlaceholderStyle = createStyleMaker(PLACEHOLDER_SELECTOR);
const makeHomepageIconStyle = createStyleMaker(HOMEPAGE_ICON_SELECTOR);
const makeHomepageLeftIconStyle = createStyleMaker(
HOMEPAGE_LEFT_ICON_SELECTOR,
);
const makeLogoutIconStyle = createStyleMaker(LOGOUT_ICON_SELECTOR);

function initChangers() {
Expand All @@ -111,6 +118,21 @@
GM_addStyle(makeTwitterLogoStyle(true));
});

if (location.pathname === "/") {
GM_addStyle(makeHomepageIconStyle(false));
waitForElement(HOMEPAGE_ICON_SELECTOR).then((svg) => {
svg.innerHTML = TWITTER_LOGO_G;
svg.classList.add("__FUCK_MUSK_BLUE__");
GM_addStyle(makeHomepageIconStyle(true));
});

GM_addStyle(makeHomepageLeftIconStyle(false));
waitForElement(HOMEPAGE_LEFT_ICON_SELECTOR).then((svg) => {
svg.innerHTML = TWITTER_LOGO_G;
GM_addStyle(makeHomepageLeftIconStyle(true));
});
}

if (location.pathname === "/home") {
GM_addStyle(makeTwitterNavbarLogoStyle(false));
waitForElement(NAVBAR_LOGO_SELECTOR).then((div) => {
Expand Down

0 comments on commit f79f22f

Please sign in to comment.