Skip to content
Draft
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
2 changes: 1 addition & 1 deletion src/features/accesskit/disable_gifs.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ const processRows = function (rowsElements) {
};

const processHoverableElements = elements =>
elements.forEach(element => element.setAttribute(hoverContainerAttribute, ''));
elements.forEach(element => element.toggleAttribute(hoverContainerAttribute, true));

const onStorageChanged = async function (changes) {
const { 'accesskit.preferences.disable_gifs_loading_mode': modeChanges } = changes;
Expand Down
2 changes: 1 addition & 1 deletion src/features/anti_capitalism/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const styleElement = buildStyle();
const processVideoCTAs = videoCTAs => videoCTAs
.map(getTimelineItemWrapper)
.filter(Boolean)
.forEach(timelineItem => timelineItem.setAttribute(hiddenAttribute, ''));
.forEach(timelineItem => timelineItem.toggleAttribute(hiddenAttribute, true));

export const main = async () => {
const { includeBlazed } = await getPreferences('anti_capitalism');
Expand Down
2 changes: 1 addition & 1 deletion src/features/classic_footer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ const processPosts = (postElements) => postElements.forEach(async postElement =>
click: onNoteCountClick,
}, getButtonChildren(noteCount));

engagementControls.closest('footer').setAttribute(activeAttribute, '');
engagementControls.closest('footer').toggleAttribute(activeAttribute, true);
engagementControls.before(noteCountButton);

if (noReblogMenu) {
Expand Down
2 changes: 1 addition & 1 deletion src/features/mutual_checker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const addIcons = function (postElements) {
const iconTarget = getPopoverWrapper(postAttribution) ?? postAttribution;
iconTarget?.before(createIcon(isMutual, blogName));
} else if (showOnlyMutuals) {
getTimelineItemWrapper(postElement)?.setAttribute(hiddenAttribute, '');
getTimelineItemWrapper(postElement)?.toggleAttribute(hiddenAttribute, true);
}
});
};
Expand Down
4 changes: 2 additions & 2 deletions src/features/no_recommended/hide_blog_carousels.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ const hideBlogCarousels = carousels =>
timelineItem.previousElementSibling.querySelector(keyToCss('titleObject')) ||
timelineItem.previousElementSibling.dataset.cellId?.startsWith('timelineObject:title')
) {
timelineItem.setAttribute(hiddenAttribute, '');
timelineItem.previousElementSibling.setAttribute(hiddenAttribute, '');
timelineItem.toggleAttribute(hiddenAttribute, true);
timelineItem.previousElementSibling.toggleAttribute(hiddenAttribute, true);
}
}
});
Expand Down
4 changes: 2 additions & 2 deletions src/features/no_recommended/hide_community_carousels.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ const hideCommunityCarousels = carousels =>
timelineItem.previousElementSibling.querySelector(keyToCss('titleObject')) ||
timelineItem.previousElementSibling.dataset.cellId?.startsWith('timelineObject:title')
) {
timelineItem.setAttribute(hiddenAttribute, '');
timelineItem.previousElementSibling.setAttribute(hiddenAttribute, '');
timelineItem.toggleAttribute(hiddenAttribute, true);
timelineItem.previousElementSibling.toggleAttribute(hiddenAttribute, true);
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/features/no_recommended/hide_radar.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const styleElement = buildStyle(`[${hiddenAttribute}] { display: none; }`
const checkForRadar = function (sidebarTitles) {
sidebarTitles
.filter(h1 => h1.textContent === translate('Radar'))
.forEach(h1 => h1.closest('aside > *').setAttribute(hiddenAttribute, ''));
.forEach(h1 => h1.closest('aside > *').toggleAttribute(hiddenAttribute, true));
};

export const main = async function () {
Expand Down
4 changes: 2 additions & 2 deletions src/features/no_recommended/hide_recommended_blogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ export const styleElement = buildStyle(`[${hiddenAttribute}] { display: none; }`
const hideDashboardRecommended = function (sidebarTitles) {
sidebarTitles
.filter(h1 => h1.textContent === translate('Check out these blogs'))
.forEach(h1 => h1.closest('aside > *').setAttribute(hiddenAttribute, ''));
.forEach(h1 => h1.closest('aside > *').toggleAttribute(hiddenAttribute, true));
};

const hideTagPageRecommended = blogsLists =>
blogsLists
.filter(ul => !ul.matches(blogViewSelector))
.forEach(ul => ul.parentNode.setAttribute(hiddenAttribute, ''));
.forEach(ul => ul.parentNode.toggleAttribute(hiddenAttribute, true));

export const main = async function () {
pageModifications.register('aside h1', hideDashboardRecommended);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const styleElement = buildStyle(`[${hiddenAttribute}] { display: none; }`
const hideModalRecommended = blogsLists =>
blogsLists
.filter(ul => ul.matches(blogViewSelector))
.forEach(ul => ul.parentNode.setAttribute(hiddenAttribute, ''));
.forEach(ul => ul.parentNode.toggleAttribute(hiddenAttribute, true));

export const main = async function () {
const blogsListSelector = `${keyToCss('desktopContainer')} > ${keyToCss('recommendedBlogs')}`;
Expand Down
4 changes: 2 additions & 2 deletions src/features/no_recommended/hide_recommended_posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ const processPosts = async function (postElements) {

const timelineItem = getTimelineItemWrapper(postElement);

timelineItem.setAttribute(hiddenAttribute, '');
timelineItem.toggleAttribute(hiddenAttribute, true);

if (precedingHiddenPosts(timelineItem) >= 10) {
timelineItem.setAttribute(unHiddenAttribute, '');
timelineItem.toggleAttribute(unHiddenAttribute, true);
}
});
};
Expand Down
4 changes: 2 additions & 2 deletions src/features/no_recommended/hide_tag_carousels.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ const hideTagCarousels = carouselWrappers => carouselWrappers
.filter(carouselWrapper => carouselWrapper.querySelector(tagCardSelector) !== null)
.map(getTimelineItemWrapper)
.forEach(timelineItem => {
timelineItem.setAttribute(hiddenAttribute, '');
timelineItem.previousElementSibling.setAttribute(hiddenAttribute, '');
timelineItem.toggleAttribute(hiddenAttribute, true);
timelineItem.previousElementSibling.toggleAttribute(hiddenAttribute, true);
});

export const main = async function () {
Expand Down
4 changes: 2 additions & 2 deletions src/features/quick_reblog/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ function onTabClick ({ currentTarget }) {
previousSelectedTab.ariaSelected = 'false';
previousSelectedTab.getAttribute('aria-controls').split(',')
.map(elementId => document.getElementById(elementId))
.forEach(tabPanel => tabPanel.setAttribute('hidden', ''));
.forEach(tabPanel => tabPanel.toggleAttribute('hidden', true));
}

currentTarget.ariaSelected = 'true';
currentTarget.getAttribute('aria-controls').split(',')
.map(elementId => document.getElementById(elementId))
.forEach(tabPanel => tabPanel.removeAttribute('hidden'));
.forEach(tabPanel => tabPanel.toggleAttribute('hidden', false));
}

/** @param {KeyboardEvent} event commentInput/tagsInput keydown event object */
Expand Down
2 changes: 1 addition & 1 deletion src/features/scroll_to_bottom/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const addButtonToPage = async function ([scrollToTopButton]) {
scrollToBottomButton.style.transform = 'rotate(180deg)';
scrollToBottomButton.addEventListener('click', onclick);
scrollToBottomButton.id = scrollToBottomButtonId;
scrollToBottomButton.setAttribute(displayBlockUnlessDisabledAttr, '');
scrollToBottomButton.toggleAttribute(displayBlockUnlessDisabledAttr, true);

scrollToBottomButton.classList.toggle(activeClass, active);
}
Expand Down
6 changes: 3 additions & 3 deletions src/features/seen_posts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ const dimPosts = function (postElements, reprocessPosts = false) {
const { id } = postElement.dataset;
const timelineItem = getTimelineItemWrapper(postElement);

const isFirstRender = timelineItem.getAttribute(excludeAttribute) === null;
timelineItem.setAttribute(excludeAttribute, '');
const isFirstRender = timelineItem.hasAttribute(excludeAttribute) === false;
timelineItem.toggleAttribute(excludeAttribute, true);

if (seenPosts.includes(id) === false) {
observer.observe(postElement.querySelector('article header + *'));
} else if (isFirstRender || reprocessPosts) {
timelineItem.setAttribute(dimAttribute, '');
timelineItem.toggleAttribute(dimAttribute, true);
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/features/show_originals/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const processPosts = async function (postElements) {
const visibleBlogName = community ? postAuthor : blogName;
if (whitelist.includes(visibleBlogName)) { return; }

getTimelineItemWrapper(postElement).setAttribute(hiddenAttribute, '');
getTimelineItemWrapper(postElement).toggleAttribute(hiddenAttribute, true);
});
};

Expand Down
4 changes: 2 additions & 2 deletions src/features/tweaks/caught_up_line.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ const createCaughtUpLine = tagChicletCarouselItems => tagChicletCarouselItems
.map(getTimelineItemWrapper)
.filter((element, index, array) => array.indexOf(element) === index)
.forEach(timelineItem => {
timelineItem.setAttribute(borderAttribute, '');
timelineItem.previousElementSibling.setAttribute(hiddenAttribute, '');
timelineItem.toggleAttribute(borderAttribute, true);
timelineItem.previousElementSibling.toggleAttribute(hiddenAttribute, true);
});

export const main = async function () {
Expand Down
2 changes: 1 addition & 1 deletion src/features/tweaks/create_button_no_bubbles.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const processCreateButtons = (createButtons) => {
createButtons.forEach(createButton => {
createButton.dataset.originalHref ??= createButton.getAttribute('href');

createButton.setAttribute(modifiedAttribute, '');
createButton.toggleAttribute(modifiedAttribute, true);
createButton.setAttribute('href', createButton.dataset.originalHref.replace(/\/new$/, '/new/text'));
createButton.addEventListener('click', onClickNavigate);
});
Expand Down
2 changes: 1 addition & 1 deletion src/features/tweaks/hide_mini_follow.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ article ${keyToCss('followButton')}:not(${keyToCss('postMeatballsContainer')} *)

const processButtons = buttons => buttons.forEach(button => {
if (button.textContent === translate('Follow')) {
button.setAttribute(hiddenAttribute, '');
button.toggleAttribute(hiddenAttribute, true);
}
});

Expand Down
6 changes: 3 additions & 3 deletions src/utils/hide_posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ export const createPostHideFunctions = ({ id, permalinkPageControls }) => {

const addPermalinkPageControls = (postElement, timelineElement) => {
const timelineItemWrapper = getTimelineItemWrapper(postElement);
if (timelineItemWrapper.getAttribute(controlledHiddenAttribute) !== '') {
timelineItemWrapper.setAttribute(controlledHiddenAttribute, '');
if (timelineItemWrapper.hasAttribute(controlledHiddenAttribute) === false) {
timelineItemWrapper.toggleAttribute(controlledHiddenAttribute, true);

const { message } = permalinkPageControls;
const controlsElement = div({ class: controlsClass, [controlsAttribute]: id }, [
Expand All @@ -122,7 +122,7 @@ export const createPostHideFunctions = ({ id, permalinkPageControls }) => {
// do nothing; avoid hiding single post and making permalink page look broken
}
} else {
getTimelineItemWrapper(postElement).setAttribute(hiddenAttribute, '');
getTimelineItemWrapper(postElement).toggleAttribute(hiddenAttribute, true);
}
};
const showPost = postElement => {
Expand Down