Igor Tolkov

January 2019

12345678910111213141516171819202122232425262728293031

February 2019

12345678910111213141516171819202122232425262728

March 2019

1234567891011121314151617202223242530

April 2019

45101116172223252627282930

May 2019

127101316232627

June 2019

614162126

July 2019

13910131416232728

August 2019

1236122631

September 2019

123416212223

October 2019

48912141518212223252728293031

November 2019

123457891013151617192122232425262830

December 2019

124810121314151617181920212426283031

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!