Search code examples
yammer

How do I hide posts with a specific hashtag in Yammer?


I want to hide posts in the feed that have a #joined hashtag. I tried to create a GreaseMonkey script with jQuery in the past, but it couldn't detect any posts that have the #joined text.

Am I using the wrong library? A starting point, or an existing library/plug-in would be helpful.

OFF-TOPIC: At the moment, Yammer does not have any feature to hide posts with a specific hashtag, although it has a feature to follow a hashtag.


Solution

  • I know that this is a pretty old question but I too was trying to create a Chrome based Add-on that hides these #joined posts (or any post with a specific hashtag). I came across this blog https://you.stonybrook.edu/thebaron/2014/10/06/hiding-joined-yammer-posts-in-chrome/ where the author of the post has shared his work (https://gist.github.com/thicknrich/e4cc2871462a6850fe8c). This is a simple javascript and does the job.

    //Script from https://gist.github.com/thicknrich/e4cc2871462a6850fe8c
    
    //load jQuery based on this SO Post: 
    //http://stackoverflow.com/questions/2246901/how-can-i-use-jquery-in-greasemonkey-scripts-in-google-chrome
    // a function that loads jQuery and calls a callback function when jQuery has finished loading
    function addJQuery(callback) {
      var script = document.createElement("script");
      script.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js");
      script.addEventListener('load', function() {
        var script = document.createElement("script");
        script.textContent = "window.jQ=jQuery.noConflict(true);(" + callback.toString() + ")();";
        document.body.appendChild(script);
      }, false);
      document.body.appendChild(script);
    }
    
    // the guts of this userscript
    function main() {
      // Note, jQ replaces $ to avoid conflicts.
    
      setInterval(function() {
      //if a item thread contains #joined, hide it
      //check every 5 second. 
        jQ('.yj-thread-list-item:contains("#joined")').css("display", "none");
    }, 5000);
    
    }
    
    // load jQuery and execute the main function
    addJQuery(main);