Skip to content

Commit

Permalink
fix tumblr tv cards
Browse files Browse the repository at this point in the history
maybe I'll make this a separate PR. sigh.
  • Loading branch information
marcustyphoon committed Feb 21, 2025
1 parent 96400c7 commit c4dae68
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/features/accesskit/disable_gifs.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,25 @@ const processBackgroundGifs = function (gifBackgroundElements) {
});
};

const reprocessBackgroundGif = gifBackgroundElement => {
if (gifBackgroundElement.matches('[style*=".gif"], [style*=".webp"]')) {
processBackgroundGifs([gifBackgroundElement]);
} else {
gifBackgroundElement.style.removeProperty(pausedBackgroundImageVar);
gifBackgroundElement.querySelector(`.${labelClass}`)?.remove();
}
};
const reprocessObserver = new MutationObserver(mutations =>
mutations
.map(({ target }) => target)
.forEach(reprocessBackgroundGif)
);
const processTumblrTvCards = cards =>
cards.forEach(card => {
reprocessObserver.observe(card, { attributeFilter: ['style'] });
reprocessBackgroundGif(card);
});

const processRows = function (rowsElements) {
rowsElements.forEach(rowsElement => {
[...rowsElement.children].forEach(row => {
Expand Down Expand Up @@ -216,12 +235,16 @@ export const main = async function () {
'communityHeaderImage', // search page tags section header: https://www.tumblr.com/search/gif?v=tag
'bannerImage', // tagged page sidebar header: https://www.tumblr.com/tagged/gif
'tagChicletWrapper', // "trending" / "your tags" timeline carousel entry: https://www.tumblr.com/dashboard/trending, https://www.tumblr.com/dashboard/hubs
'communityCategoryImage', // tumblr communities browse page entry: https://www.tumblr.com/communities/browse, https://www.tumblr.com/communities/browse/movies
'videoHubCardWrapper' // tumblr tv channels section: https://www.tumblr.com/dashboard/tumblr_tv
'communityCategoryImage' // tumblr communities browse page entry: https://www.tumblr.com/communities/browse, https://www.tumblr.com/communities/browse/movies
)}:is([style*=".gif"], [style*=".webp"])
`;
pageModifications.register(gifBackgroundImage, processBackgroundGifs);

pageModifications.register(
keyToCss('videoHubCardWrapper'), // tumblr tv channels section: https://www.tumblr.com/dashboard/tumblr_tv
processTumblrTvCards
);

const hoverableElement = `
${keyToCss('listTimelineObject')} ${keyToCss('carouselWrapper')} ${keyToCss('postCard')}, /* recommended blog carousel entry */
div:has(> a${keyToCss('cover')}):has(${keyToCss('communityCategoryImage')}), /* tumblr communities browse page entry: https://www.tumblr.com/communities/browse */
Expand All @@ -242,6 +265,7 @@ export const main = async function () {
export const clean = async function () {
pageModifications.unregister(processGifs);
pageModifications.unregister(processBackgroundGifs);
pageModifications.unregister(processTumblrTvCards);
pageModifications.unregister(processRows);
pageModifications.unregister(processHoverableElements);

Expand Down

0 comments on commit c4dae68

Please sign in to comment.