32 lines
1.8 KiB
TypeScript
32 lines
1.8 KiB
TypeScript
// Profile+: the rules of its two hide features, one builder per flag. Pure (a string out), so the
|
|
// tests read them without a DOM. They moved here unchanged from src/inject/features.ts
|
|
// (`buildFeatureCss`); selectors from Control Panel for Twitter (MIT, see THIRD_PARTY_NOTICES.md).
|
|
|
|
import { sidebarModuleSelectors } from '../../inject/features.ts';
|
|
|
|
const hide = (selectors: string[]) => `${selectors.join(',\n')} {\n display: none !important;\n}`;
|
|
const PROFILE = 'html[data-bt-route="profile"]';
|
|
|
|
export const PROFILE_CSS = {
|
|
// Profiles: follow suggestions in the sidebar and the ones X inserts into the profile timeline
|
|
// (`html[data-bt-route]` is set by the runtime).
|
|
hideProfileWhoToFollow: () => hide([
|
|
...sidebarModuleSelectors('aside', '[data-testid="UserCell"]', `${PROFILE} [data-testid="sidebarColumn"]`),
|
|
`${PROFILE} [data-testid="primaryColumn"] aside:has([data-testid="UserCell"])`,
|
|
`${PROFILE} [data-testid="primaryColumn"] [data-testid="cellInnerDiv"]:has([data-testid="UserCell"])`,
|
|
`${PROFILE} [data-testid="primaryColumn"] [data-testid="cellInnerDiv"]:has(a[href^="/i/connect_people"])`,
|
|
]),
|
|
// Posts/profiles: creator subscription buttons and prompts
|
|
hideSubscribeButtons: () => hide([
|
|
'a[href*="/creator-subscriptions/subscribe"]',
|
|
'button[data-testid$="-subscribe"]',
|
|
'a[data-testid$="-subscribe"]',
|
|
]),
|
|
} as const;
|
|
|
|
export type ProfileCssFlag = keyof typeof PROFILE_CSS;
|
|
|
|
/** The rules of the Profile+ hide flags that are on in `flags`, in table order (tests; the modules inject one sheet each). */
|
|
export function profileCss(flags: Readonly<Record<string, boolean | undefined>>): string {
|
|
return (Object.keys(PROFILE_CSS) as ProfileCssFlag[]).filter(flag => flags[flag] === true).map(flag => PROFILE_CSS[flag]()).join('\n\n');
|
|
}
|