Douyu Ad Remover

Remove ads on douyu.com

  1. // ==UserScript==
  2. // @name Douyu Ad Remover
  3. // @namespace Ad Remover
  4. // @version 0.1
  5. // @description Remove ads on douyu.com
  6. // @author X.Zhao
  7. // @grant none
  8. // @match http://www.douyutv.com/*
  9. // ==/UserScript==
  10. /* jshint -W097 */
  11. 'use strict';
  12.  
  13. function isEmpty(obj) {
  14. // null and undefined are "empty"
  15. if (obj === null || obj === undefined) return true;
  16. // Assume if it has a length property with a non-zero value
  17. // that that property is correct.
  18. if (obj.length > 0) return false;
  19. if (obj.length === 0) return true;
  20. // Otherwise, does it have any properties of its own?
  21. // Note that this doesn't handle
  22. // toString and valueOf enumeration bugs in IE < 9
  23. for (var key in obj) {
  24. if (hasOwnProperty.call(obj, key)) return false;
  25. }
  26. return true;
  27. }
  28.  
  29. function remover(name, callback) {
  30. var $ = window.jQuery;
  31. if (isEmpty($) || isEmpty($(name))) {
  32. setTimeout(function() {
  33. remover(name);
  34. }, 500);
  35. } else {
  36. if (isEmpty(callback)) {
  37. // default callback is clear html content and set "display: none".
  38. $(name).html('').hide();
  39. } else {
  40. callback($(name));
  41. }
  42. }
  43. }
  44.  
  45. function main() {
  46. remover('#chat-top-ad');
  47. remover('#js_chat_mem');
  48. remover('#cq_fans');
  49. remover('#js_mlist');
  50. remover('#dy_bottom_shadow');
  51. remover('#live_videobar');
  52. remover('.chat-right-ad');
  53. remove_flash_ad();
  54. remove_focus();
  55. }
  56.  
  57.  
  58. function remove_focus() {
  59. var $ = window.jQuery;
  60. if ($('#live_userinfo #js_share').length === 0) {
  61. setTimeout(remove_focus, 500);
  62. } else {
  63. $('#live_userinfo #js_share').html('').hide();
  64. }
  65. }
  66.  
  67. function remove_flash_ad() {
  68. var $ = window.jQuery;
  69. if ($('#sign_p_15_swf').width() === null) {
  70. setTimeout(remove_flash_ad, 500);
  71. } else {
  72. // alert($('#sign_p_15_swf').width());
  73. $('#sign_p_15_swf').width(0).height(0);
  74. }
  75. }
  76.  
  77. main();