Skip to content

Instantly share code, notes, and snippets.

Last active January 31, 2023 05:17
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Filter Facebook Marketplace to only show entries in the last hour
// ==UserScript==
// @name     MarketplaceFilterLastHour
// @include*
// @require
// @grant    GM_addStyle
// ==/UserScript==
//- The @grant directive is needed to restore the proper sandbox.


let pattern= 'a[href^="/marketplace/item/"]:contains("hours") , a[href^="/marketplace/item/"]:contains("day") , a[href^="/marketplace/item/"]:contains("week")';

function mutationHandler (mutationRecords) {
  mutationRecords.forEach(function (mutation) {
    if (mutation.type=="childList" && typeof mutation.addedNodes=="object" && mutation.addedNodes.length) {
      for (let i=0; i<mutation.addedNodes.length; ++i) {
        if (mutation.addedNodes[i].nodeType===1) elementMutationHandler(mutation.addedNodes[i]);
    } else if (mutation.type == "attributes" && {

function elementMutationHandler(elem) {
  $(elem).find(pattern).each(function() { console.log($(this)); $(this).parent().remove(); });

// start

let MutationObserver = window.MutationObserver;
let myObserver       = new MutationObserver(mutationHandler);
let obsConfig        = { childList: true, attributes: true, subtree: true,   attributeFilter: ['href'] };
myObserver.observe (document, obsConfig);

setTimeout((function() {
}), 3*60*1000);

$('#globalContainer').attr('style', 'width: 100% !important');
$('#globalContainer:first div:first div:first  div:first').attr('style', 'width: 95% !important');
setInterval((function() {
  $('#globalContainer').attr('style', 'width: 100% !important');
  $('#globalContainer:first div:first div:first  div:first').attr('style', 'width: 95% !important');
}), 1000);
  • Hit the save icon
  • close greasemokey editor
  • refresh your marketplace page
Copy link

If anyone tries to do this in the future, change .../?sort=CREATION_TIME_DESCEND to .../?sortBy=creation_time_descend.

Copy link

@deltabravozulu is this still working for you ? I can't get back to "Classic Facebook"

Copy link

@MichaRotstein I don't think you actually need to use "Classic Facebook" to make it work.

Copy link

BUT I am not 100% sure, to be honest. I was rolling around between a few scripts trying to cobble my own usable one together and I think this one clued me in to the URL variations and so I just wanted to let people know the sort function changed.

I am pretty sure I had this one working but I was annoyed that I couldn't really toggle things in-page (nor could I in the script I wrote--I was a bit lazy with it), so I just went back to the way things were with no scripts at all (aka terrible).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment