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

clean my feed prevents feed from loading #35

Closed tomerrr closed 12 months ago

tomerrr commented 1 year ago

ver 4.21 chrome 114.0.5735.198 / Fedora 37 tested also on Firefox Nightly 116.0a1 / Windows 10 TamperMonkey v4.19.0 (on both) once script enabled, I can only see a single post, the rest are blinking (loading) disabling script and feed return to normal

zbluebugz commented 1 year ago

FB has changed the HTML structure again.

Version 4.22 will be released shortly.

In the meantime, replace the _function nfgetCollectionOfPosts()'s code in the script with the following:

function nf_getCollectionOfPosts() {
    let posts = [];
    // -- various news feed queries
    const queries = [
        // -- July 2023 - fb tweaked the structure
        'h3[dir="auto"] ~ div:not([class]) > div[class] > div',
        // -- December 2022 - try the [data-pagelet] attribute
        'span[id="ssrb_feed_start"] ~ div > div div[data-pagelet]',
        // -- May 2023 - fb tweaked the structure
        'h2[dir="auto"] ~ div:not([class]) > div[class]',
        // -- February 2023 - fb tweaked the structure
        'h3[dir="auto"] ~ div:not([class]) > div[class]',
        // -- older ...
        'span[id="ssrb_feed_start"] ~ div > h3 ~ div',
        // -- 31/10/2022 - fb tweaked the structure
        'h3[dir="auto"] ~ div:not([class]) > div[class] > div'
    ]

    for (const query of queries) {
        const nodeList = document.querySelectorAll(query);
        if (nodeList.length > 1) {
            posts = Array.from(nodeList);
            break;
        }
    }

    return posts;
}
zbluebugz commented 1 year ago

Scratch that. FB is really messing up the HTML code. Will post another hotfix shortly.

tomerrr commented 1 year ago

many thanks, code works

zbluebugz commented 1 year ago

Unfortunately, it still hiding some posts by accident.

FB is injecting random DIVs into the posts which messes up the query used for collection of posts.

Working on a fix for this.

zbluebugz commented 1 year ago

Below is a temporary solution. Replace _function nfgetCollectionOfPosts() code with this:

function nf_getCollectionOfPosts() {
    let posts = [];
    // -- various news feed queries
    const queries = [
       // -- July 2023 - fb tweaked the structure - random div levels.
        // -- - home news feed
        'h3[dir="auto"] ~ div > div > div div.x1yztbdb:not([role])',
        // -- - "recent" feed
        'h2[dir="auto"] ~ div > div > div div.x1yztbdb:not([role])',

        // -- December 2022 - try the [data-pagelet] attribute
        'span[id="ssrb_feed_start"] ~ div > div div[data-pagelet]',
        // -- May 2023 - fb tweaked the structure
        'h2[dir="auto"] ~ div:not([class]) > div[class]',
        // -- February 2023 - fb tweaked the structure
        'h3[dir="auto"] ~ div:not([class]) > div[class]',
        // -- older ...
        'span[id="ssrb_feed_start"] ~ div > h3 ~ div',
        // -- 31/10/2022 - fb tweaked the structure
        'h3[dir="auto"] ~ div:not([class]) > div[class] > div'
    ]

    for (const query of queries) {
        const nodeList = document.querySelectorAll(query);
        if (nodeList.length > 1) {
            posts = Array.from(nodeList);
            break;
        }
    }

    return posts;
}
zbluebugz commented 12 months ago

Version 4.22 released with fix.