Igor Tolkov

January 2018

12456789101112131415161718192021222324252627283031

February 2018

12345678910111213141516171819202122232425262728

March 2018

123456789101112141516171921262830

April 2018

123456789101112131415161718192021222324252627282930

May 2018

123456789101112131415161718192021222324252627293031

June 2018

1234567891011121314152527282930

July 2018

1234567891011121314151819202122232425262728293031

August 2018

1235678910111213141516171819202122232425262728293031

September 2018

1234567891011121314181920212223242526272829

October 2018

123456789101112131415161718192021222328293031

November 2018

123456789101112131415161718192021272930

December 2018

14567891011141516171819202122232425262728293031

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!