@@ -10,35 +10,20 @@ import { navigate } from '../../utils/tumblr_helpers.js';
1010const meatballButtonId = 'postblock' ;
1111const meatballButtonLabel = 'Block this post' ;
1212const hiddenAttribute = 'data-postblock-hidden' ;
13- const warningClass = 'xkit-postblock-warning' ;
13+ const controlsClass = 'xkit-postblock-hidden-post-controls' ;
14+ const controlledHiddenAttribute = 'data-xkit-postblock-hidden-controlled' ;
1415const storageKey = 'postblock.blockedPostRootIDs' ;
1516const blogUuidsStorageKey = 'postblock.blockedPostBlogUUIDs' ;
1617
1718let blogUuids = { } ;
1819
19- const addWarningElement = ( postElement , rootID ) => {
20- const showButton = dom ( 'button' , null , {
21- click : ( { currentTarget } ) => {
22- getTimelineItemWrapper ( postElement ) . removeAttribute ( hiddenAttribute ) ;
23- currentTarget . disabled = true ;
24- } ,
25- } , 'show it' ) ;
26-
27- const unblockButton = dom ( 'button' , null , {
28- click : ( ) => {
29- unblockPost ( rootID ) ;
30- warningElement . remove ( ) ;
31- } ,
32- } , 'unblock it' ) ;
33-
34- const warningElement = dom ( 'div' , { class : warningClass } , null , [
35- 'You have blocked this post!' ,
20+ const addPermalinkPageControls = timelineElement => {
21+ const controlsElement = dom ( 'div' , { class : controlsClass } , null , [
22+ 'You have hidden this post with PostBlock!' ,
3623 dom ( 'br' ) ,
37- showButton ,
38- ' / ' ,
39- unblockButton ,
24+ dom ( 'button' , null , { click : ( ) => controlsElement . remove ( ) } , 'show post anyway' ) ,
4025 ] ) ;
41- postElement . closest ( timelineSelector ) . before ( warningElement ) ;
26+ timelineElement . prepend ( controlsElement ) ;
4227} ;
4328
4429let blockedPostRootIDs = [ ] ;
@@ -65,10 +50,12 @@ const processPosts = postElements =>
6550 const rootID = rebloggedRootId || postID ;
6651
6752 if ( blockedPostRootIDs . includes ( rootID ) ) {
68- getTimelineItemWrapper ( postElement ) . setAttribute ( hiddenAttribute , '' ) ;
69-
70- if ( postPermalinkTimelineFilter ( postID ) ( postElement . closest ( timelineSelector ) ) ) {
71- addWarningElement ( postElement , rootID ) ;
53+ const timelineElement = postElement . closest ( timelineSelector ) ;
54+ if ( postPermalinkTimelineFilter ( postID ) ( timelineElement ) ) {
55+ getTimelineItemWrapper ( postElement ) . setAttribute ( controlledHiddenAttribute , '' ) ;
56+ addPermalinkPageControls ( timelineElement ) ;
57+ } else {
58+ getTimelineItemWrapper ( postElement ) . setAttribute ( hiddenAttribute , '' ) ;
7259 }
7360 } else {
7461 getTimelineItemWrapper ( postElement ) . removeAttribute ( hiddenAttribute ) ;
@@ -140,7 +127,7 @@ export const clean = async function () {
140127 onNewPosts . removeListener ( processPosts ) ;
141128
142129 $ ( `[${ hiddenAttribute } ]` ) . removeAttr ( hiddenAttribute ) ;
143- $ ( `.${ warningClass } ` ) . remove ( ) ;
130+ $ ( `.${ controlsClass } ` ) . remove ( ) ;
144131} ;
145132
146133export const stylesheet = true ;
0 commit comments