0

The top navbar (the top horizontal bar with the Facebook logo, search icon, etc.) on Facebook is in a fixed position so it scrolls down with you. I want to prevent this, it should get hidden when you scroll down. I tried making the element's position relative/inherit using Stylus (Google Chrome extension) but it just messed things up. Is there a way to do this using a Tampermonkey script?

I tried the following using a previous script that's several years old but that doesn't work anymore. Here's the link to that script. https://greasyfork.org/en/scripts/31019-facebook-scroll-hider

What I tried by modifying the script:

(function() {
    'use strict';

    var hideElementList = [document.getElementsByClassName(".ehxjyohh.kr520xx4.j9ispegn.poy2od1o.dhix69tm.byvelhso.buofh1pr.j83agx80.rq0escxv.bp9cbjyn")
    ];
    
    function checkScroll(timestamp) {
        console.log(window.pageYOffset);
        if(window.pageYOffset !== 0) {
            for(var i = 0; i < hideElementList.length; i++) {
                hideElementList[i].style.opacity = "0";
            }
        } else {
            for(var i = 0; i < hideElementList.length; i++) {
                hideElementList[i].style.opacity = "1";
            }
        }
        window.requestAnimationFrame(checkScroll);
    }
    
    window.requestAnimationFrame(checkScroll);
})();

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.