Skip to content

Commit

Permalink
fix: placeholder icon should be blue
Browse files Browse the repository at this point in the history
  • Loading branch information
pionxzh committed Jul 30, 2023
1 parent 1bbf000 commit 4159ea3
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions packages/userscript/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ function main() {
injectStyle()

const placeHolderIconSelector = '#placeholder > svg'
replaceIcon(placeHolderIconSelector, false)
replaceIcon(placeHolderIconSelector, 'twitter-blue')

const headerIconSelector = 'h1 a[href=\'/home\'] svg'
replaceIcon(headerIconSelector, true)
replaceIcon(headerIconSelector, 'old-twitter-icon')

const mobileHeaderIconSelector = '[data-testid="TopNavBar"] svg'
replaceIcon(mobileHeaderIconSelector, true)
replaceIcon(mobileHeaderIconSelector, 'old-twitter-icon')

// Fuzzy matching for all 𝕏 icons
sentinel.on('svg', (svg) => {
Expand Down Expand Up @@ -74,7 +74,7 @@ function injectStyle() {
width: 20px;
max-width: 100%;
fill: currentcolor;
color: rgba(29,155,240,1.00);
color: rgb(29,155,240);
vertical-align: text-bottom;
position: relative;
-ms-flex-positive: 1;
Expand All @@ -88,20 +88,24 @@ function injectStyle() {
display: inline-block;
}
.twitter-blue {
color: rgb(29,155,240);
}
[data-color-scheme="dim"] .old-twitter-icon,
[data-color-scheme="dark"] .old-twitter-icon {
color: rgba(231,233,234,1.00);
color: rgb(231,233,234);
}`)
document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet]
}

function replaceIcon(selector: string, applyStyle: boolean) {
function replaceIcon(selector: string, applyStyle?: string) {
sentinel.on(selector, (svg) => {
if (svg.getAttribute('data-replaced') === 'true') return
svg.setAttribute('data-replaced', 'true')

svg.innerHTML = twitterIconSvgInner
if (applyStyle) svg.classList.add('old-twitter-icon')
if (applyStyle) svg.classList.add(applyStyle)
})
}

Expand Down

0 comments on commit 4159ea3

Please sign in to comment.