File tree Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change 2727 "label" : " Remove the coloured shadow from focused posts" ,
2828 "default" : false
2929 },
30+ "hide_filtered_posts" : {
31+ "type" : " checkbox" ,
32+ "label" : " Hide filtered posts entirely" ,
33+ "default" : false
34+ },
3035 "hide_my_posts" : {
3136 "type" : " checkbox" ,
3237 "label" : " Hide my own posts on the dashboard" ,
Original file line number Diff line number Diff line change 1+ ( function ( ) {
2+ const excludeClass = 'xkit-tweaks-hide-filtered-posts-done' ;
3+ const includeFiltered = true ;
4+ const hiddenClass = 'xkit-tweaks-hide-filtered-posts-hidden' ;
5+ const css = `.${ hiddenClass } article { display: none; }` ;
6+
7+ const processPosts = async function ( ) {
8+ const { getPostElements } = await fakeImport ( '/util/interface.js' ) ;
9+ const { timelineObjectMemoized } = await fakeImport ( '/util/react_props.js' ) ;
10+
11+ getPostElements ( { excludeClass, includeFiltered } ) . forEach ( async postElement => {
12+ const { filtered } = await timelineObjectMemoized ( postElement . dataset . id ) ;
13+
14+ if ( filtered !== undefined && Object . keys ( filtered ) . length !== 0 ) {
15+ postElement . classList . add ( hiddenClass ) ;
16+ }
17+ } ) ;
18+ } ;
19+
20+ const main = async function ( ) {
21+ const { onNewPosts } = await fakeImport ( '/util/mutations.js' ) ;
22+ const { addStyle } = await fakeImport ( '/util/interface.js' ) ;
23+
24+ onNewPosts . addListener ( processPosts ) ;
25+ processPosts ( ) ;
26+
27+ addStyle ( css ) ;
28+ } ;
29+
30+ const clean = async function ( ) {
31+ const { onNewPosts } = await fakeImport ( '/util/mutations.js' ) ;
32+ const { removeStyle } = await fakeImport ( '/util/interface.js' ) ;
33+
34+ onNewPosts . removeListener ( processPosts ) ;
35+ removeStyle ( css ) ;
36+
37+ $ ( `.${ excludeClass } ` ) . removeClass ( excludeClass ) ;
38+ $ ( `.${ hiddenClass } ` ) . removeClass ( hiddenClass ) ;
39+ } ;
40+
41+ return { main, clean } ;
42+ } ) ( ) ;
You can’t perform that action at this time.
0 commit comments