Skip to content

Commit

Permalink
Added an option to hide the Tweet box in the timeline
Browse files Browse the repository at this point in the history
Closes #411
  • Loading branch information
insin committed Sep 8, 2023
1 parent 732a6c0 commit c80cd74
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 1 deletion.
3 changes: 3 additions & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,5 +340,8 @@
},
"replaceLogoLabel": {
"message": "Replace X branding changes"
},
"hideTimelineTweetBoxLabel": {
"message": "Tweet box in timeline"
}
}
3 changes: 3 additions & 0 deletions _locales/es/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,5 +340,8 @@
},
"replaceLogoLabel": {
"message": "Reemplazar X cambios de marca"
},
"hideTimelineTweetBoxLabel": {
"message": "Cuadro de tweet en timeline"
}
}
3 changes: 3 additions & 0 deletions _locales/fr/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,5 +340,8 @@
},
"replaceLogoLabel": {
"message": "Remplacer les changements de marque X"
},
"hideTimelineTweetBoxLabel": {
"message": "Zone de tweet dans timeline"
}
}
3 changes: 3 additions & 0 deletions _locales/ja/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,5 +340,8 @@
},
"replaceLogoLabel": {
"message": "X のブランド変更を置き換える"
},
"hideTimelineTweetBoxLabel": {
"message": "タイムラインのツイートボックス"
}
}
3 changes: 3 additions & 0 deletions _locales/ko/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,5 +340,8 @@
},
"replaceLogoLabel": {
"message": "X 브랜딩 변경 사항 바꾸기"
},
"hideTimelineTweetBoxLabel": {
"message": "타임라인 트윗 상자"
}
}
3 changes: 3 additions & 0 deletions _locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,5 +340,8 @@
},
"replaceLogoLabel": {
"message": "更换 X 品牌变更"
},
"hideTimelineTweetBoxLabel": {
"message": "时间线推文框"
}
}
7 changes: 7 additions & 0 deletions options.html
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,13 @@
<span class="toggle"></span>
</label>
</section>
<section class="checkbox desktop">
<label>
<span id="hideTimelineTweetBoxLabel">Tweet box in timeline</span>
<input type="checkbox" name="hideTimelineTweetBox">
<span class="toggle"></span>
</label>
</section>
<section class="checkbox desktop">
<label>
<span id="hideAccountSwitcherLabel">Account switcher</span>
Expand Down
6 changes: 5 additions & 1 deletion options.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ for (let translationId of [
'hideShareTweetButtonLabel',
'hideSidebarContentLabel',
'hideSubscriptionsLabel',
'hideTimelineTweetBoxLabel',
'hideTotalTweetsMetricsLabel',
'hideTweetAnalyticsLinksLabel',
'hideTwitterAdsNavLabel',
Expand Down Expand Up @@ -175,6 +176,7 @@ const defaultConfig = {
hideSeeNewTweets: false,
hideShareTweetButton: false,
hideSubscriptions: true,
hideTimelineTweetBox: false,
hideTotalTweetsMetrics: true,
hideTweetAnalyticsLinks: false,
hideTwitterAdsNav: true,
Expand Down Expand Up @@ -295,20 +297,22 @@ function applyConfig() {
'hideTweetAnalyticsLinks',
desktop && 'hideAccountSwitcher',
desktop && 'hideBookmarksNav',
desktop && 'hideCommunitiesNav',
desktop && 'hideExploreNav',
desktop && 'hideListsNav',
desktop && 'hideMessagesDrawer',
desktop && 'hideTimelineTweetBox',
mobile && 'hideMessagesBottomNavItem',
].filter(Boolean),
hideMoreSlideOutMenuItems: [
'hideAnalyticsNav',
'hideCommunitiesNav',
'hideHelpCenterNav',
'hideMonetizationNav',
'hideTwitterAdsNav',
desktop && 'hideConnectNav',
desktop && 'hideKeyboardShortcutsNav',
mobile && 'hideBookmarksNav',
mobile && 'hideCommunitiesNav',
mobile && 'hideListsNav',
].filter(Boolean),
hideAllMetrics: [
Expand Down
6 changes: 6 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const config = {
hideSeeNewTweets: false,
hideShareTweetButton: false,
hideSubscriptions: true,
hideTimelineTweetBox: false,
hideTotalTweetsMetrics: true,
hideTweetAnalyticsLinks: false,
hideTwitterAdsNav: true,
Expand Down Expand Up @@ -2629,6 +2630,7 @@ function checkforDisabledHomeTimeline() {
}
}

//#region CSS
const configureCss = (() => {
let $style

Expand Down Expand Up @@ -2879,6 +2881,9 @@ const configureCss = (() => {
if (config.hideSeeNewTweets) {
hideCssSelectors.push(`body.MainTimeline ${Selectors.PRIMARY_COLUMN} > div > div:first-child > div[style^="transform"]`)
}
if (config.hideTimelineTweetBox) {
hideCssSelectors.push(`body.MainTimeline ${Selectors.PRIMARY_COLUMN} > div > div:nth-child(3)`)
}
if (config.disableHomeTimeline) {
hideCssSelectors.push(`${Selectors.PRIMARY_NAV_DESKTOP} a[href="/home"]`)
}
Expand Down Expand Up @@ -3167,6 +3172,7 @@ const configureNavFontSizeCss = (() => {
$style.textContent = cssRules.map(dedent).join('\n')
}
})()
//#endregion

/**
* Configures – or re-configures – the separated tweets timeline title.
Expand Down
1 change: 1 addition & 0 deletions types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export type Config = {
hideSeeNewTweets: boolean
hideShareTweetButton: boolean
hideSubscriptions: boolean
hideTimelineTweetBox: boolean
hideTotalTweetsMetrics: boolean
hideTweetAnalyticsLinks: boolean
hideTwitterAdsNav: boolean
Expand Down

0 comments on commit c80cd74

Please sign in to comment.