Gmail - Remove "Empty Trash Now" link

Removes the "Empty Trash Now" link when in the Trash

  1. // ==UserScript==
  2. // @name Gmail - Remove "Empty Trash Now" link
  3. // @namespace gmail_remove_empy_trash_now_link
  4. // @description Removes the "Empty Trash Now" link when in the Trash
  5. // @version 0.1
  6. // @author Tim Berneman
  7. // @copyright Tim Berneman (c) 2015
  8. // @include /https?:\/\/mail.google.com\/mail\/u\/0\/#trash/
  9. // @grant none
  10. // @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.js
  11. // @run-at document-start
  12. //
  13. // License: http://creativecommons.org/licenses/by-nc-sa/3.0/
  14. //
  15. // CHANGELOG:
  16. // v0.1 - initial release
  17. //
  18. // ==/UserScript==
  19.  
  20. // THESE DO NOT WORK FOR THIS SCRIPT!
  21. //
  22. // window.addEventListener ("load", pageFullyLoaded);
  23. // document.addEventListener ("DOMContentLoaded", DOM_ContentReady);
  24. // $(document).ready(function() {} );
  25. //
  26. // I suspect Gmail is loading this particular code through AJAX and thus the above statements do not work.
  27. //
  28. // To circumvent this, I wait 3 seconds then call the function to hide the div. (Kludgy, I know, but it works!)
  29.  
  30. function yourFunction() {
  31.  
  32. if ( jQuery("div.ya") == null ) {
  33. setTimeout(function() { yourFunction(); }, 1000);
  34. } else {
  35. jQuery('span:contains("Empty Trash now")').parent().hide();
  36. }
  37.  
  38. }
  39. setTimeout(function() { yourFunction(); }, 3000);