斗鱼屏蔽SB

try to take over the world!

  1. // ==UserScript==
  2. // @name 斗鱼屏蔽SB
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description try to take over the world!
  6. // @author You
  7. // @include *douyu.com*
  8. // @grant GM.addStyle
  9. // @require https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js
  10. // ==/UserScript==
  11.  
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. //在这里增加要屏蔽的直播间号码,右键直播间卡片复制网址,斗鱼直播间链接格式为为 https://www.douyu.com/123456 或者 https://www.douyu.com/xxxxxx,只要把域名后面的数字填进去就行
  17. var sb = ["6567483","246195","64609","2150596","234544","8948464","8948464","59889","943298","339610"];
  18. sb.forEach((value)=>{
  19. waitForKeyElements (
  20. "[href='/" +value+"']",
  21. appendImageNumber
  22. );
  23. })
  24.  
  25. function appendImageNumber (jNode) {
  26. jNode.parents (".layout-Cover-item").remove();
  27. };
  28.  
  29.  
  30. // Your code here...、
  31. //优化网页全屏UI
  32. GM.addStyle( ` body.is-fullScreenPage .layout-Player-video {
  33. bottom: 44px;height: auto;
  34. }
  35. body.is-fullScreenPage .layout-Player-toolbar {
  36. height: 44px;
  37. }
  38. `);
  39.  
  40. })();
  41.  
  42. /*--- waitForKeyElements(): A utility function, for Greasemonkey scripts,
  43. that detects and handles AJAXed content.
  44.  
  45. Usage example:
  46.  
  47. waitForKeyElements (
  48. "div.comments"
  49. , commentCallbackFunction
  50. );
  51.  
  52. //--- Page-specific function to do what we want when the node is found.
  53. function commentCallbackFunction (jNode) {
  54. jNode.text ("This comment changed by waitForKeyElements().");
  55. }
  56.  
  57. IMPORTANT: This function requires your script to have loaded jQuery.
  58. */
  59. function waitForKeyElements (
  60. selectorTxt, /* Required: The jQuery selector string that
  61. specifies the desired element(s).
  62. */
  63. actionFunction, /* Required: The code to run when elements are
  64. found. It is passed a jNode to the matched
  65. element.
  66. */
  67. bWaitOnce, /* Optional: If false, will continue to scan for
  68. new elements even after the first match is
  69. found.
  70. */
  71. iframeSelector /* Optional: If set, identifies the iframe to
  72. search.
  73. */
  74. ) {
  75. var targetNodes, btargetsFound;
  76.  
  77. if (typeof iframeSelector == "undefined")
  78. targetNodes = $(selectorTxt);
  79. else
  80. targetNodes = $(iframeSelector).contents ()
  81. .find (selectorTxt);
  82.  
  83. if (targetNodes && targetNodes.length > 0) {
  84. btargetsFound = true;
  85. /*--- Found target node(s). Go through each and act if they
  86. are new.
  87. */
  88. targetNodes.each ( function () {
  89. var jThis = $(this);
  90. var alreadyFound = jThis.data ('alreadyFound') || false;
  91.  
  92. if (!alreadyFound) {
  93. //--- Call the payload function.
  94. var cancelFound = actionFunction (jThis);
  95. if (cancelFound)
  96. btargetsFound = false;
  97. else
  98. jThis.data ('alreadyFound', true);
  99. }
  100. } );
  101. }
  102. else {
  103. btargetsFound = false;
  104. }
  105.  
  106. //--- Get the timer-control variable for this selector.
  107. var controlObj = waitForKeyElements.controlObj || {};
  108. var controlKey = selectorTxt.replace (/[^\w]/g, "_");
  109. var timeControl = controlObj [controlKey];
  110.  
  111. //--- Now set or clear the timer as appropriate.
  112. if (btargetsFound && bWaitOnce && timeControl) {
  113. //--- The only condition where we need to clear the timer.
  114. clearInterval (timeControl);
  115. delete controlObj [controlKey]
  116. }
  117. else {
  118. //--- Set a timer, if needed.
  119. if ( ! timeControl) {
  120. timeControl = setInterval ( function () {
  121. waitForKeyElements ( selectorTxt,
  122. actionFunction,
  123. bWaitOnce,
  124. iframeSelector
  125. );
  126. },
  127. 300
  128. );
  129. controlObj [controlKey] = timeControl;
  130. }
  131. }
  132. waitForKeyElements.controlObj = controlObj;
  133. }
  134.