matt-kruse / SocialFixer

Social Fixer is a browser extension that enhances Facebook
41 stars 14 forks source link

Filtering by post action: Rule target doesn't exist (yet) #24

Open ojchase opened 3 years ago

ojchase commented 3 years ago

I'm subscribed to the Friend Activity Stories filter, which is configured to block posts where the "Post Action" "Matches Regex" "(.*(?:^(.*) commented on this\.(?:(?! \2 $).)*$|was mentioned in a post|was live| likes | liked |reacted to this|was tagged in|replied to a comment).*)"

It is not currently filtering out these sorts of posts. From the Filter Debugger, I see: 1.055000 Filter #6 (Friend Activity Stories) 1.055000 -> Rule target doesn't exist (yet): action; acting as if it were null

dmitriy1980 commented 3 years ago

Could you provide a couple of examples on what the text is within the posts that you expect to be filtered, please?

ojchase commented 3 years ago
[A friend of mine] replied to a comment.
-----------------
[A public post that I don't care about]

Filter debugger: 1.288000 Filter #6 (Friend Activity Stories) 1.288000 -> Rule target doesn't exist (yet): action; acting as if it were null

Raw post:

{
   "sfx_id": null,
   "dom_id": "sfx_post_321",
   "id": "sfx_post_321",
   "next_filter": 8,
   "all_content": "[My friend]  replied to a  comment . Dramane Traore    ·  S e p n t t e s S e S m l u b p g e c o r o n   s f 8 e   s a s o r t l e   d f 8 : 3 d 8 n g o   r a A M o h    ·  Only people with a very good view find the intruder      ·  See original    ·  Rate this translation 1.8M   1.8M 5.8M Comments 162K Shares Like Comment Share 5.8M Comments Most Relevant  Active [The person my friend responded to] 805 809 603  ·  Like  ·  Reply  ·  4d Most Relevant is selected, so some replies may have been filtered out. [My friend] [The person my friend responded to]    pareil que toi avec en + 883, 903, 808    ·  Like  ·  Reply  ·  See Translation  ·  3d View 1 more reply View more comments 1 of 4,957,582",
   "image": "😂 😂 🧐 🧐 😉 No photo description available. 🙃 ",
   "actionContent": []
}
NotFiltered
ojchase commented 3 years ago

Surprisingly hard to find a clear example. It's inconsistent. I think it has to do with the action element in the debug not being set all the time.

I'm also suspicious of whether it has to do with whether the text is "above the line" (friend responding to a comment, friend commented, friend was tagged, etc.) or "below the line" (original post was live, original post had a tag). I've seen other cases that looked promising until I saw that action was set, but was using the original post's action, that I don't care about. It's the friend activity that's the problem.

In general, spend some time actively using this filter, and you'll find it's not catching nearly enough. More strings are needed in the regex too.

dmitriy1980 commented 3 years ago

Based on above, there's nothing to match to. The closest it matches to is to "replied to a comment". However, in the post there are 2 spaces between 'a' and a 'comment'

ojchase commented 3 years ago

There is no extra space visible to the end user in the Facebook post. I question both whether all_content was parsed correctly and the assumption that end users should need to be using the debugger.

This is not a user-created filter. This one is a subscription shipped directly with Social Fixer. If Facebook has changed their HTML to add a new space, then a filter subscription update would be appreciated.

In general, spend some time actively using this filter, and you'll find it's not catching nearly enough.

dmitriy1980 commented 3 years ago

I agree to some extend. As you can see the software is not updated that often and as such there's a flexibility where subscription-based filter can be changed to local and you can update it accordingly based on the newfound use case. I personally have 42 filters and don't rely on subscriptions. Any time I see something not being caught, I update my filter. Granted you need to have some knowledge of RegEx and I agree non-technical people would not be able to do this.

ojchase commented 3 years ago

Yeah, I hear you. This is the type of github project that straddles the technical/non-technical line nicely. And if it were just me, adding more filters is probably exactly what I'll do. But it is open-source software, and I can at least get it reported...

I don't want to distract from what appears to be the main issue. When the existing filter works, it appears to be using the action field in the constructed JSON. When the error message appears (Rule target doesn't exist (yet): action; acting as if it were null), it's not even being set, despite there being an action in the post (with a debatable number of spaces). Not having that filter type working reliably decreases the precision we can use.

mjeveritt commented 3 years ago

Mmm, I can see where this might indeed be a pain. I suppose the neat solution, without involving some coding effort, would be to replace any ' ' (space characters) in the match expression with a '[ ]+' RegEx (ie. minimum one 'space') and see how that works.

I'm tempted to run the existing filter, and this modified version, with No Action (or 'Copy to Tab' perhaps) in parallel, and see how the matches stack up. I can buy the argument it probably isn't functioning quite as intended ... but this is definitely made harder by Facebook's obfuscation efforts!! @ojchase feel free to do so also, and report back with any interesting findings! If it makes a marked improvement, and there is little (or no) fall-out then we'll see about updating it.

Also, moving/copying this issue over to the https://github.com/matt-kruse/socialfixerdata repo is probably appropriate too.

filbo commented 3 years ago

It is a known problem that the 'action' field is not being consistently populated. Some current FB posts have the 'action' content in the same HTML structure that the field extractor expects; some do not. This needs to be fixed.

Some 'extra spaces' in SFx filter fields are actually introduced by SFx code putting together the pieces of the post. That's also a known issue, not much looked at.

The filter in question could be improved by teaching it about these possibly variable spaces.

However, the biggest problem of all with that filter is: some time ago, like 12-24 months, FB stopped putting any sort of 'action' line onto many such posts. We can't filter on intent, only on actual words in the post.

mjeveritt commented 3 years ago

Yeah, I think I'd be tempted to axe the 'Post Action' filter option. Or rewrite it to use text in post HTML rather than tag info.... there's probably some RegEx construction that would better fit this kind of filter too.

filbo commented 3 years ago

axe the 'Post Action' filter option

Definitely not. Capture it better. It is OK that existing filters which use it may fail or have to be changed; that is the nature of dealing with FB. It's still a useful tool with respect to whatever kinds of posts FB are currently pasting 'action' lines onto, at any moment now or in the future. Even if that doesn't include post types which were so 'blessed' in the past.

mjeveritt commented 3 years ago

axe the 'Post Action' filter option

Definitely not. Capture it better. It is OK that existing filters which use it may fail or have to be changed; that is the nature of dealing with FB. It's still a useful tool with respect to whatever kinds of posts FB are currently pasting 'action' lines onto, at any moment now or in the future. Even if that doesn't include post types which were so 'blessed' in the past.

Fair enough - do we have any insights on how to do this at present? @matt-kruse do you have any 'development 'spoons'' available in the near future™ to address core-code issues?