Igor Tolkov

January 2022

12345678910111213141516171819202122232425262728293031

February 2022

12345678910111213141516171819202122232425262728

March 2022

12345678910111213141516171819202122232425262728293031

April 2022

123456789101112131415161718192021222324252627282930

May 2022

156791011121314151617181920212324252627282931

June 2022

123467891011121314151617192021222324252627282930

July 2022

157891011121314151617181920212223242527282930

August 2022

13141516171819202122232627282931

September 2022

12345678910111317192021222324252627282930

October 2022

1234567891011121314151617181920232425262728293031

November 2022

123456789101112141516171819212223242930

December 2022

123456101516171819202122232425262728293031

Photos feed for the new Facebook

The new Facebook layout, compared with the “old new” Facebook layout, misses a photos feed. Bummer, since that’s probably my favorite way of browsing Facebook.

Challenge: code up a photos feed for Facebook in 40 minutes.

The simple solution relies on a macro plugin (I use Scriptish for Firefox, there is probably a similar app for Chrome.) The macro is Javascript code that is executed on or after page load. Here is the code:

// ==UserScript==
// @id             10
// @name           Facebook-photosfeed
// @version        0.01
// @namespace
// @author         Igor Tolkov
// @description    Introduces a photos feed for Facebook
// @include        https://www.facebook.com/*
// @run-at         document-start
// ==/UserScript==
window.setInterval(function(){
    /* Hides posts, leaving only those which contain photos */
    var show_photos = function(){
        var s = document.getElementsByClassName("_5jmm");
        for(var i in s){
            var a = s[i]; if(!a.className) continue;
            a.style.display = "none";
        }
        for(var t in {"_5cq3":0, "_2a2q":1}){
            var s = document.getElementsByClassName(t);
            for(var i in s){
                var a = s[i]; if(!a.className) continue;
                while(a.className.indexOf("_5jmm")==-1) a = a.parentNode;
                a.style.display = "block";
            }
        }
    };

    /* Adds a photos feed link in sidebar */
    if(!document.getElementById("link_show_photos"))
    {
        var li = document.createElement("LI");
        li.id = "link_show_photos";
        li.className = "sideNavItem stat_elem";
        li.innerHTML = '<a title="News Feed" href="/?sk=photos" class="item clearfix"><div class="rfloat"><span aria-busy="1" aria-label="Loading..." class="img _55ym _55yn _55yo _5tqs uiSideNavSpinner"></span></div><div><span class="imgWrap"><i class="img sp_247cvt sx_cfa14f"></i></span><div class="linkWrap noCount">Photos Feed</div></div></a>';
        var ref = document.getElementById("navItem_app_4748854339" /* News Feed */);
        ref.parentNode.insertBefore(li, ref.nextSibling);
    }
    else
    {
        if(location.search == "?sk=photos")
            document.getElementById("link_show_photos").className = "sideNavItem stat_elem selectedItem open";
        else
            document.getElementById("link_show_photos").className = "sideNavItem stat_elem";
    }

    /* We use a custom news feed landing url. Facebook does not recognize it and ignores it. */
    if(location.search == "?sk=photos")
        show_photos();
}, 500);

Now you can also have a Facebook photos feed!