Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/features/tweaks/hide_filtered_posts.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { keyToCss } from '../../utils/css_map.js';
import { createPostHideFunctions } from '../../utils/hide_posts.js';
import { getTimelineItemWrapper } from '../../utils/interface.js';
import { postSelector } from '../../utils/interface.js';
import { pageModifications } from '../../utils/mutations.js';

const { hidePost, showPosts } = createPostHideFunctions({
Expand All @@ -11,7 +11,7 @@ const { hidePost, showPosts } = createPostHideFunctions({
});

const hideFilteredPosts = filteredScreens => filteredScreens
.map(getTimelineItemWrapper)
.map(filteredScreen => filteredScreen.closest(postSelector))
.forEach(hidePost);

export const main = async function () {
Expand Down
1 change: 1 addition & 0 deletions src/utils/hide_posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export const createPostHideFunctions = ({ id, permalinkPageControls }) => {
[${hiddenAttribute}], [${controlsAttribute}] ~ div [${controlledHiddenAttribute}] {
content: linear-gradient(transparent, transparent);
height: 0;
margin: 0 !important;
}
`;

Expand Down
7 changes: 1 addition & 6 deletions src/utils/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ export const trailItemSelector = `${postSelector} ${keyToCss('reblog')}`;
export const blogViewSelector = '[style*="--blog-title-color"] *';
export const notificationSelector = `:is(${keyToCss('notification')}[role="listitem"], ${keyToCss('activityItem')})`;

const listTimelineObjectSelector = keyToCss('listTimelineObject');
const cellSelector = keyToCss('cell');
const targetWrapperSelector = keyToCss(
'targetWrapper',
'targetWrapperBlock',
Expand All @@ -21,10 +19,7 @@ const targetWrapperSelector = keyToCss(
* @param {Element} element Element within a timeline item
* @returns {Element | null} The timeline item wrapper
*/
export const getTimelineItemWrapper = element =>
(element.closest('[data-timeline-id]') && element.closest(listTimelineObjectSelector)?.parentElement) ||
element.closest(cellSelector) ||
element.closest(listTimelineObjectSelector);
export const getTimelineItemWrapper = element => element.closest(`${timelineSelector} > div > div`);

/**
* @param {Element} element Element within a popover wrapper
Expand Down