Skip to content

Instantly share code, notes, and snippets.

@alexcasalboni
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexcasalboni/22484e3b9f03764d8ff0 to your computer and use it in GitHub Desktop.
Save alexcasalboni/22484e3b9f03764d8ff0 to your computer and use it in GitHub Desktop.
Replace ugly fed-id user title on user pages
(function($){
$(function(){
//on domready
muut(function(app){ //on forum load
//init custom DOM structure
var userFeedTitle = $('<span class="userpage-title"></span>');
var title = $('.m-pagetitle').prepend(userFeedTitle);
//on load and update events
app.on('load update', function (_, e) {
//switch userpage class
if(e.type == "user"){ //if userpage
title.addClass('userpage');
//the following looks for this user's name in the DOM (if any post is available!)
var firstUserPost = $('.m-moot .m-seed .m-facelink[href="#!/'+e.user.path+'"]', app.root).closest('.m-moot').first();
if(firstUserPost.length){
var userName = firstUserPost.find('.m-seed .m-meta .m-name').text();
userFeedTitle.text(userName);
}else{
userFeedTitle.text('User Feed');
}
}else{
title.removeClass('userpage');
}
});
});
});
})(window.jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment