Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to change design only for specific activities


  • mutoha
    Participant

    @mutoha

    I think that I want to change only activities about like “Smith and Jon are now friends” to background: pink;

    But in the following code error that “targetTxt is undefined”.

    (function($){
      var url = location.href	
      var urlSplit_activity = url.split('/')[5];	
      if (urlSplit_activity == 'activity'){		
        var observer = new MutationObserver(function (MutationRecords, MutationObserver) {
          $('.activity-header a:nth-child(2)').each(function() {
            var targetTxt = this.nextSibling.data; //error
            if (targetTxt.indexOf('are now friends') >= 0) {
              $(this).closest('li').css('background','pink');
            }
          });	
        });
        observer.observe($('#activity-stream').get(0), {
          childList: true,
          attributes: true,
          subtree: true
        });		
      }
    })(jQuery);

    Would you mind teaching me how to do that?

    Thanks.

Viewing 5 replies - 1 through 5 (of 5 total)

  • Prashant Singh
    Participant

    @prashantvatsh

    Hi,

    I think the element must be having this class ‘friendship_created’. So we can easily make the background pink using this simple CSS rule:

    li.friendship_created {
        background: pink !important;
    }

    Please try this and check if it works for you or not.

    Thanks


    mutoha
    Participant

    @mutoha

    Hi,Thank You!

    I did not notice that the ClassName was given.

    Because I could not speak English well, I was asking a different question from my original purpose.

    What I wanted to hear was originally “Activity of creating a topic” rather than “Activity of becoming a friend”.

    Therefore, such a ClassName was not granted, and it had only to judge with the word indexOf('are now friends').

    However, with the above code, I can not acquire the word var targetTxt and it becomes “targetTxt is undefined”.

    Thanks.


    Prashant Singh
    Participant

    @prashantvatsh

    Activity type ‘creating a topic’ will have a class ‘bbp_topic_create’ so you can use that.

    li.bbp_topic_create{
    background: pink !important;
    }

    Thanks


    mutoha
    Participant

    @mutoha

    Oh how embarrassing!Sorry!I didn’t see it!!
    Thank you so much for all the helpful advice you gave me.


    Prashant Singh
    Participant

    @prashantvatsh

    Not a problem.

    Great to see that it helped you 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Skip to toolbar