zbluebugz / facebook-clean-my-feeds

Clean up Facebook feeds by hiding sponsored, suggestions and other posts based on keywords.
GNU General Public License v3.0
113 stars 13 forks source link

[Survey] Delayed filtering #20

Open thiendt2k1 opened 1 year ago

thiendt2k1 commented 1 year ago

Does anyone experience delayed in filtering, like only after 3 or 5s the filtering can kick in, especially for newer posts after 50 60-th :/ Sometimes it kick in, some don't even load into filtering and just stand there, unfiltered. is there a performance issue with my laptop or it's a common issues? Thanks. https://anonfiles.com/t9J99aEey9/2022-10-27_08-26-26_mp4 Here is HTML of the 2 post that not filtering in case you need to check: https://anotepad.com/notes/5tc3mjga

zbluebugz commented 1 year ago

I sometimes see fb being "slow" - even with the script disabled.

I often get the "slow" down after viewing several group posts and fb is loading up 1-200 consecutive Suggested posts.

Not too sure why some of the Sponsored & Suggested posts slipped through in your feed stream.

I'll review the performance of the code. to to make sure it isn't being to aggressive.

Are you using version 4.09?

thiendt2k1 commented 1 year ago

yes, 4.09 English

thiendt2k1 commented 1 year ago

i think i got it, i got 2 or more kinds of sponsored post, and suggested, here is 2 of them(sponsored): https://anotepad.com/notes/ktx5a2t8 also suggested: https://anotepad.com/notes/447mdm4y can you add another case in the filter and give me for a test? thanks P/s: i included html code of both filtered and unfiltered in 1 file each for both sponsor and suggestion

zbluebugz commented 1 year ago

I've had a quick look at the first file - couldn't see anything odd about it. As for the second file, I could not see the contents of that file.

I've uploaded a development copy of the script, that makes FB appear a little bit more nippy. This copy is a work-in-progress. It is listed as beta-400-beta.js in the /beta/archive folder. You're welcome to try it out - it will be available for download for a short period of time.

You might want to tweak two lines in the code to adjust the cleaning frequency. Line 1408: mutationsMax: 3,

Line 1418: scanCountMaxLoop: 5,

FYI, upto version v4.09, the code would do the cleaning tasks everytime a certain new element was added and each post cleaned 12 times (not 12 times per new element). The above two lines aims to reduce the frequency of the cleaning.

thiendt2k1 commented 1 year ago

much better, i set the above to 6 and 8 respectively, which make the load much faster and more stable, i got to about 100 no problem, the after 100, there is still a slight delay but acceptable as sponsored and suggest shows and then gone, but that's ok for me. Thanks for the tips. Excellent work!!

zbluebugz commented 1 year ago

Thanks for the positive feedback.

Good to see you've found a sweet spot for the code on your laptop.

Can you give us an update after a week or so?

zbluebugz commented 1 year ago

FB has changed the main news feed structure.

A new version of beta-400-beta.js has been uploaded - will be up for a few hours for you to download.

I have not released this version to the public yet as I'm still testing it.

Before overwriting your copy, take note of the two numbers you changed in the code.

This new version has some additional code for adjusting the executing of the filtering code.

You'll need to adjust mutationsNonAgressiveMax and scanCountMaxLoop

If you find the code is not hiding certain elements at the start, you could try tweaking mutationsAggressiveMax to have a higher number.

// - mutations speed mode, 1 = aggressive, 2 = non-aggressive
mutationsMode: 1,
// - on start, how many mutations to process consecutively, before switching to non-agressive mode
mutationsAggressiveMax: 250,
// - non-agressive mode - which NTH element to trigger the code
mutationsNonAgressiveMax: 4,
// - mutations counter (used with either mutationsAgressiveMax or mutationsNonAgressiveMax)
mutationsCount: 0,
// - how many times to scan a post
scanCountStart: 0,
scanCountMaxLoop: 10, // was 12
zbluebugz commented 1 year ago

News Feed suggested/recommendations are slipping through.

Here's the code snippet to update in your copy of the code - replace _function nfisSuggested(...) with the following:

function nf_isSuggested(post) {
    // - check if any of the suggestions / recommendations type post
    // -- nb: <name> commented / <name> replied to a commment posts have similar structure - but have extra elements ...
    // -- nb: x people recently commented posts have similar structure - suggested/recommended posts don't start with a number ...
    let query = ':scope > div > div > div > div > div > div > div > div > div > div > div > div:nth-of-type(2) > div > div:nth-of-type(1) > div > div > div > div > span';
    let elSuggestion = querySelectorAllNoChildren(post, query, 1);
    // console.info(log+'isSuggested:', elSuggestion.length, elSuggestion);
    if (elSuggestion.length === 0) {
        query = ':scope > div > div > div > div > div > div > div > div > div > div > div:nth-of-type(2) > div > div:nth-of-type(1) > div > div > div > div > span';
        elSuggestion = querySelectorAllNoChildren(post, query, 1);
    }
    if (elSuggestion.length > 0) {
        const pattern = /([0-9]|[\u0660-\u0669])/;
        let firstCharacter = cleanText(elSuggestion[0].textContent).trim().slice(0, 1);
        // console.info(log+'isSuggested - match test:', firstCharacter, pattern.test(firstCharacter), pattern.test(firstCharacter) ? 'No': 'Yes' );
        return (pattern.test(firstCharacter)) ? '' : KeyWords.NF_SUGGESTIONS[VARS.language];
    }
    else {
        return '';
    }
}
thiendt2k1 commented 1 year ago

I was about to post about this today, but it's working as expected, thanks!

zbluebugz commented 1 year ago

I've uploaded a development copy of the script with some changes. This copy is a work-in-progress.

It is listed as beta-400-beta.js in the /beta/archive folder.

You're welcome to try it out - it will be available for download for a short period of time.

New features added:

Note: The aggressive-mode code has been adjusted.

thiendt2k1 commented 1 year ago

Hi, sorry for the long waiting time, I think the order should be non-aggressive -> aggressive -> doing nothing, as initially doing nothing is something similar to not using for the first 15 post

zbluebugz commented 1 year ago

Hmmm, sounds like the script is a bit slow to start on your computer. On my computer, it starts quite early and the site was still building non-feed elements.

So, I implemented a "sleep" facility to allow the site to do it's stuff before the script did the filtering.

Change line 1488: mutationsInitSkip: 400, to have a lower count of elements to skip at start - from 400 down to say 200.

May need to adjust line 1490: mutationsAggressiveMax: 150, to process more elements in fast mode, before switching to slow mode.

thiendt2k1 commented 1 year ago

ok works as expected, i change "mutationsInitSkip" to 200, "mutationsAggressiveMax" to 350 and it's smoooth again👌

thiendt2k1 commented 1 year ago

ok now we're back to square one, using the beta testing won't help anymore as it isn't filtered, even after i scroll through about 15 20 post(and only force filter using save in menu make the filter begin), i think we should roll back to previous version or try another one, as this version isn't working for me anymore...

zbluebugz commented 1 year ago

Are you saying nothing is happening on start up and only kicks in when you press the Save button?

I have the next version version (v4.12) ready to be published, but will hold off releasing for a few days due to rumours about Sponsored posts no longer being filtered. This version has a simplified start-up code - there's a bit of a delay before doing the filtering (no aggressive/passive modes).

thiendt2k1 commented 1 year ago

seems to have some trouble posting, i answered yesterday and now i see nothing, so here i go again The filtering is back to normal yesterday, even without delay, seems like my FB is their favorite code dump these days Will report back when the symptom show up again(and no, it's not because the sponsored filter don't work, it only delays)

zbluebugz commented 1 year ago

FYI, there are some errors/bugs with the code which causes it to not to hide some elements when Verbosity's option is set to <no message>. Use either 1 post hidden. Rule: ______ or 7 posts hidden option for now.

Will be doing some more testing before releasing v4.12.