hoelz.ro - Avatar Blacklist Userscript for Identica

Avatar Blacklist Userscript for Identica

I'm on a microblogging site called Identica, and there are a lot of interesting people in the various groups there. However, sometimes while I find a user's content interesting, I don't like looking at their avatar for whatever reason. I'm not going to name names, but to get around this, I wrote this userscript to display the default avatar for select users.

identica-avatar-blacklist.user.js
  1. // ==UserScript==
  2. // @match http://identi.ca/*
  3. // ==/UserScript==
  4.  
  5. (function() {
  6. var onLoadCallback = function() {
  7. var blacklist = {
  8. // put the usernames of the people whose avatars you
  9. // would like to block as the keys in this object; the
  10. // values can be anything
  11. };
  12. var replacement = 'http://theme.identi.ca/1.0.0/neo/default-avatar-profile.png';
  13.  
  14. var handleImage = function() {
  15. var parentTitle = $(this).parent().attr('title');
  16. var alt = $(this).attr('alt');
  17.  
  18. if(alt in blacklist || parentTitle in blacklist) {
  19. this.src = replacement;
  20. }
  21. };
  22.  
  23. $('img.avatar').each(function(_, element) {
  24. handleImage.call(element);
  25. });
  26. var script = document.createElement('script');
  27. script.src = 'http://brandonaaron.net/javascripts/plugins/livequery.js'
  28. $(script).load(function() {
  29. $('img.avatar').livequery(function() {
  30. handleImage.call(this);
  31. });
  32. });
  33. document.body.appendChild(script)
  34. };
  35.  
  36. var callback = function() {
  37. var script = document.createElement('script');
  38. script.textContent = "(" + onLoadCallback.toString() + ")()";
  39. document.body.appendChild(script);
  40. };
  41.  
  42. if(document.readyState == 'complete') {
  43. callback();
  44. } else {
  45. document.body.onload = callback;
  46. }
  47. })();

Recent changes RSS feed Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki ipv6 ready