Last active
August 29, 2015 14:08
-
-
Save alexcasalboni/22484e3b9f03764d8ff0 to your computer and use it in GitHub Desktop.
Replace ugly fed-id user title on user pages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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