Advertisement
brasofilo

test mod/no-mod icon

Sep 22nd, 2014
444
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        Test sprite
  3. // @description hide questions by score, user reputation and accepted answers
  4. // @namespace   http://stackapps.com/users/10590
  5. // @author      brasofilo
  6. // @version     0.3
  7. // @copyright   2014, Rodolfo Buaiz (http://stackapps.com/users/10590/brasofilo)
  8. // @license     ISC; http://opensource.org/licenses/ISC
  9. // @match http*://*.askubuntu.com/questions*
  10. // @match http*://*.askubuntu.com/unanswered*
  11. // @match http*://*.mathoverflow.net/questions*
  12. // @match http*://*.mathoverflow.net/unanswered*
  13. // @match http*://*.serverfault.com/questions*
  14. // @match http*://*.serverfault.com/unanswered*
  15. // @match http*://*.stackapps.com/questions*
  16. // @match http*://*.stackapps.com/unanswered*
  17. // @match http*://*.stackexchange.com/questions*
  18. // @match http*://*.stackexchange.com/unanswered*
  19. // @match http*://*.stackoverflow.com/questions*
  20. // @match http*://*.stackoverflow.com/unanswered*
  21. // @match http*://*.superuser.com/questions*
  22. // @match http*://*.superuser.com/unanswered*
  23. // @homepageURL http://stackapps.com/questions/
  24. // @grant       GM_addStyle
  25. // ==/UserScript==
  26.  
  27. GM_addStyle("\
  28. .se-app-gear1 {                                                                           \
  29.     background: url('http://i.stack.imgur.com/I5vIL.png') no-repeat -2px -2px !important; \
  30.     width: 24px !important;                                                               \
  31.     height: 14px !important;                                                              \
  32.     margin-top: 9px;                                                                      \
  33. }                                                                                         \
  34. .se-app-gear2 {                                                                           \
  35.     background: url('http://i.stack.imgur.com/I5vIL.png') no-repeat -2px -20px !important;\
  36.     width: 24px !important;                                                               \
  37.     height: 14px !important;                                                              \
  38.     margin-top: 9px;                                                                      \
  39. }");      
  40.  
  41. var userscript = function($) {
  42.     var testForMod = function() {
  43.         return $('div.topbar-links').find('.mod-only').length;
  44.     }
  45.  
  46.     $class = testForMod() ? ' se-app-gear1' : ' icon-inbox-mod';
  47.     var $html = '<a href="javascript:void(0)" id="my-se-mod" class="topbar-icon yes-hover' + $class + '" title="Testing mod icon"></a>';
  48.     $($html).appendTo('div.network-items');
  49.     var $icon = $('#my-se-mod');
  50.  
  51.     $icon.hover(
  52.         function () {
  53.             if( testForMod() )
  54.                 $(this).removeClass('se-app-gear1').addClass('se-app-gear2');
  55.             else
  56.                 $(this).addClass('icon-inbox-mod-announcements');
  57.         },
  58.         function () {
  59.              if( testForMod() )
  60.                 $(this).removeClass('se-app-gear2').addClass('se-app-gear1');
  61.             else
  62.                 $(this).removeClass('icon-inbox-mod-announcements');
  63.         }
  64.     );
  65. };
  66.  
  67. var el = document.createElement('script');
  68. el.type = 'text/javascript';
  69. el.text = '(' + userscript + ')(jQuery);';
  70. document.head.appendChild(el);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement