Advertisement
webnesto

Ello - Display Usernames

Oct 24th, 2014
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name           Ello - Display Usernames
  3. // @description    Usernames for Ello
  4. // @include        https://ello.co/*
  5. // @version        1.0
  6. // ==/UserScript==
  7.  
  8. // a function that loads jQuery and calls a callback function when jQuery has finished loading
  9. function addJQuery(callback) {
  10.   var script = document.createElement("script");
  11.   script.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js");
  12.   script.addEventListener('load', function() {
  13.     var script = document.createElement("script");
  14.     script.textContent = "window.jQ=jQuery.noConflict(true);(" + callback.toString() + ")();";
  15.     document.body.appendChild(script);
  16.   }, false);
  17.   document.body.appendChild(script);
  18. }
  19.  
  20. GM_addStyle( '.script-username-label { font-size:0.6rem;clear:both; }' );
  21.  
  22. addJQuery( function(){
  23.     setInterval(function() {
  24.  
  25.         function handleUpdate( uname, $this, where ) {
  26.             if( !$this.hasClass("script-processed")){
  27.                 $this[ where ]( '<div class="script-username-label">' + uname + '</div>' );
  28.                 $this.addClass("script-processed");
  29.             }
  30.             //else - do nothing
  31.         }
  32.  
  33.         $('.posts .avatar').each( function(){
  34.             var $this = $( this );
  35.             handleUpdate(  $this.attr('title'), $this.closest(".post").find( ".post-content" ), "prepend" );
  36.         } );
  37.  
  38.         //todo: alphabetise the avatars first.
  39.         $('#drawer .avatar').each( function(){
  40.             var $this = $( this );
  41.             handleUpdate(  $this.attr('title'), $this, "before" );
  42.         } );
  43.  
  44.     }, 5000);
  45. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement