DailyRush V5 Message notifications

try to take over the world!

  1. // ==UserScript==
  2. // @name DailyRush V5 Message notifications
  3. // @namespace drNotify
  4. // @version 0.1
  5. // @description try to take over the world!
  6. // @author johnnie johansen
  7. // @match https://www.dailyrush.dk/*
  8. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.12.3/jquery.js
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12.  
  13. // http://www.greasespot.net/2012/08/greasemonkey-10-jquery-broken-with.html
  14. this.$ = this.jQuery = jQuery.noConflict(true); // GM/jQ v1.0 quickfix
  15.  
  16. let userLoggedInSelector = '.td_user_logd_in';
  17.  
  18. $(document).ready(function(){
  19.  
  20. dailyrushNotifications();
  21.  
  22. function cl(string){
  23. console.log(string);
  24. }
  25.  
  26. function dailyrushNotifications()
  27. {
  28. let userLoggedIn = $(userLoggedInSelector).attr('href');
  29.  
  30. if (!userLoggedIn) return;
  31.  
  32. userLoggedIn += "/messages";
  33.  
  34. $.get(userLoggedIn, function( data ) {
  35. let anyNewMessages = $(data).find('#user-messages span').html();
  36. if(!anyNewMessages) return;
  37.  
  38. let currentHtml = $(userLoggedInSelector).html();
  39. $(userLoggedInSelector).html(currentHtml + '<span style="margin-left:6px;color:#fff;background:#f0f;border-radius:6px;padding:3px 6px;font-size:10px;font-family:verdana;">' + anyNewMessages + '</span>');
  40. });
  41. }
  42.  
  43. });