forked from AprilSylph/XKit-Rewritten
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix/improve content hiding with "virtual scroller" experiment (AprilS…
…ylph#1213) Co-authored-by: April Sylph <[email protected]>
- Loading branch information
1 parent
92645e6
commit af2ab3e
Showing
18 changed files
with
112 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,36 @@ | ||
import { keyToCss } from '../util/css_map.js'; | ||
import { buildStyle } from '../util/interface.js'; | ||
import { buildStyle, getTimelineItemWrapper } from '../util/interface.js'; | ||
import { pageModifications } from '../util/mutations.js'; | ||
|
||
const hiddenClass = 'xkit-anti-capitalism-hidden'; | ||
const hiddenAttribute = 'data-anti-capitalism-hidden'; | ||
|
||
const listTimelineObjectInnerSelector = keyToCss('listTimelineObjectInner'); | ||
|
||
const styleElement = buildStyle(` | ||
.${hiddenClass}, | ||
[${hiddenAttribute}] > div, | ||
${keyToCss('adTimelineObject', 'instreamAd', 'mrecContainer', 'nativeIponWebAd', 'takeoverBanner')} { | ||
display: none !important; | ||
}` | ||
); | ||
|
||
const processVideoCTAs = videoCTAs => videoCTAs | ||
.map(videoCTA => videoCTA.closest(listTimelineObjectInnerSelector)) | ||
.map(getTimelineItemWrapper) | ||
.filter(Boolean) | ||
.forEach(({ classList }) => classList.add(hiddenClass)); | ||
.forEach(timelineItem => timelineItem.setAttribute(hiddenAttribute, '')); | ||
|
||
export const main = async () => { | ||
document.documentElement.append(styleElement); | ||
pageModifications.register(`${listTimelineObjectInnerSelector}:first-child ${keyToCss('videoCTA', 'videoImageCTA')}`, processVideoCTAs); | ||
pageModifications.register( | ||
` | ||
${listTimelineObjectInnerSelector}:first-child ${keyToCss('videoCTA', 'videoImageCTA')}, | ||
${keyToCss('adTimelineObject', 'instreamAd', 'mrecContainer', 'nativeIponWebAd', 'takeoverBanner')} | ||
`, | ||
processVideoCTAs | ||
); | ||
}; | ||
|
||
export const clean = async () => { | ||
pageModifications.unregister(processVideoCTAs); | ||
styleElement.remove(); | ||
$(`.${hiddenClass}`).removeClass(hiddenClass); | ||
$(`[${hiddenAttribute}]`).removeAttr(hiddenAttribute); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
.xkit-postblock-hidden article { | ||
[data-postblock-hidden] article { | ||
display: none; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.