afreecatv bj 차단

afreecatv bj 차단함

  1. // ==UserScript==
  2. // @name afreecatv bj 차단
  3. // @match *://afreecatv.com/*
  4. // @match *://www.afreecatv.com/*
  5. // @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js
  6. // @grant GM_addStyle
  7. // @grant GM_getValue
  8. // @grant GM_setValue
  9. // @grant GM_registerMenuCommand
  10. // @grant GM_deleteValue
  11. // @version 0.0.1.20210709164605
  12. // @namespace https://greasyfork.org/users/289839
  13. // @description afreecatv bj 차단함
  14. // ==/UserScript==
  15.  
  16.  
  17.  
  18. var regex = [] // [/키워드1/, /키워드2/]
  19. var bj = [] // ['abc123', 'def345']
  20.  
  21.  
  22. ////////////////////////////////////////////////////////
  23.  
  24. var bj_list = GM_getValue("bj_list")
  25. var test = GM_getValue("bj_list")
  26.  
  27. if (test == null || test == "undefined" || test == []){
  28. GM_setValue("bj_list", bj)}
  29.  
  30. bj_list = bj_list.concat(bj)
  31.  
  32. /*--- waitForKeyElements(): A utility function, for Greasemonkey scripts,
  33. that detects and handles AJAXed content.
  34.  
  35. Usage example:
  36.  
  37. waitForKeyElements (
  38. "div.comments"
  39. , commentCallbackFunction
  40. );
  41.  
  42. //--- Page-specific function to do what we want when the node is found.
  43. function commentCallbackFunction (jNode) {
  44. jNode.text ("This comment changed by waitForKeyElements().");
  45. }
  46.  
  47. IMPORTANT: This function requires your script to have loaded jQuery.
  48. */
  49. function waitForKeyElements (
  50. selectorTxt, /* Required: The jQuery selector string that
  51. specifies the desired element(s).
  52. */
  53. actionFunction, /* Required: The code to run when elements are
  54. found. It is passed a jNode to the matched
  55. element.
  56. */
  57. bWaitOnce, /* Optional: If false, will continue to scan for
  58. new elements even after the first match is
  59. found.
  60. */
  61. iframeSelector /* Optional: If set, identifies the iframe to
  62. search.
  63. */
  64. ) {
  65. var targetNodes, btargetsFound;
  66.  
  67. if (typeof iframeSelector == "undefined")
  68. targetNodes = $(selectorTxt);
  69. else
  70. targetNodes = $(iframeSelector).contents ()
  71. .find (selectorTxt);
  72.  
  73. if (targetNodes && targetNodes.length > 0) {
  74. btargetsFound = true;
  75. /*--- Found target node(s). Go through each and act if they
  76. are new.
  77. */
  78. targetNodes.each ( function () {
  79. var jThis = $(this);
  80. var alreadyFound = jThis.data ('alreadyFound') || false;
  81.  
  82. if (!alreadyFound) {
  83. //--- Call the payload function.
  84. var cancelFound = actionFunction (jThis);
  85. if (cancelFound)
  86. btargetsFound = false;
  87. else
  88. jThis.data ('alreadyFound', true);
  89. }
  90. } );
  91. }
  92. else {
  93. btargetsFound = false;
  94. }
  95.  
  96. //--- Get the timer-control variable for this selector.
  97. var controlObj = waitForKeyElements.controlObj || {};
  98. var controlKey = selectorTxt.replace (/[^\w]/g, "_");
  99. var timeControl = controlObj [controlKey];
  100.  
  101. //--- Now set or clear the timer as appropriate.
  102. if (btargetsFound && bWaitOnce && timeControl) {
  103. //--- The only condition where we need to clear the timer.
  104. clearInterval (timeControl);
  105. delete controlObj [controlKey]
  106. }
  107. else {
  108. //--- Set a timer, if needed.
  109. if ( ! timeControl) {
  110. timeControl = setInterval ( function () {
  111. waitForKeyElements ( selectorTxt,
  112. actionFunction,
  113. bWaitOnce,
  114. iframeSelector
  115. );
  116. },
  117. 300
  118. );
  119. controlObj [controlKey] = timeControl;
  120. }
  121. }
  122. waitForKeyElements.controlObj = controlObj;
  123. }
  124.  
  125.  
  126. window.addEventListener ("load", function () {
  127. waitForKeyElements ("#broadlist_area.cBox-list", bj_hide);
  128. //document.getElementsByTagName("html")[0].style.visibility = "visible";
  129. setTimeout(function(){document.getElementById("broadlist_area").style.visibility = "visible" }, 1000);
  130.  
  131.  
  132. }, false);
  133.  
  134. const bodyObserver = new MutationObserver(function(mutations, observer) {
  135. bj_hide()
  136. //console.log('afafaf')
  137. });
  138.  
  139.  
  140. bodyObserver.observe(document.body, {
  141. childList: true,
  142. subtree: true
  143. });
  144.  
  145.  
  146. function bj_hide (jNode) {
  147.  
  148. $("#broadlist_area.cBox-list").find('.cBox-info').each(function(){
  149. //var cbox = $(this).find('.cBox-info')
  150. var li = $(this).closest('li')
  151. var title = $(this).find('a.title').attr('title');
  152. var uid = $(this).find('a.nick').attr('user_id');
  153. var nick = $(this).find('a.nick').text
  154. if (bj_list.includes(uid) || regex.some(rx => rx.test(title)) || regex.some(rx => rx.test(nick))) {
  155. li.hide()
  156. //li.remove()
  157. }
  158.  
  159. //$('.reload').hide()
  160. });
  161.  
  162.  
  163. var cb = document.getElementById('broadlist_area').getElementsByClassName('cBox-info')
  164.  
  165. for(var i = 0; i < cb.length; i++){
  166. var node = cb[i]
  167. if (node.getElementsByTagName("chadan").length == 0) {
  168.  
  169. var newHTML = document.createElement ('chadan');
  170. newHTML.innerHTML = "<br><button id='hide" + i + "' type='button'>" + "차단</button>"
  171. node.append(newHTML);
  172. var hide = "hide" + i
  173. document.getElementById (hide).addEventListener (
  174. "click", ButtonClickAction, false
  175. );
  176. }
  177.  
  178. }
  179.  
  180. }
  181.  
  182.  
  183. function ButtonClickAction (zEvent) {
  184.  
  185. var button_id = zEvent.srcElement.attributes.id.value
  186. var c = document.getElementById (button_id).parentNode.parentNode
  187. var user_id = c.getElementsByTagName('a')[1].attributes[1].value
  188. c.parentNode.style.display = 'none'
  189. bj_list.push(user_id)
  190. bj_list = bj_list.filter(onlyUnique).filter(Boolean)
  191. GM_setValue("bj_list", bj_list)
  192.  
  193. }
  194.  
  195. GM_addStyle ( multilineStr ( function () {/*!
  196. chadan {
  197. color: black;
  198. background: white;
  199. margin: 5px;
  200. }
  201. #myButton {
  202. cursor: pointer;
  203. }
  204. #myContainer p {
  205. color: red;
  206. background: white;
  207. }
  208. */} ) );
  209.  
  210. function multilineStr (dummyFunc) {
  211. var str = dummyFunc.toString ();
  212. str = str.replace (/^[^\/]+\/\*!?/, '') // Strip function () { /*!
  213. .replace (/\s*\*\/\s*\}\s*$/, '') // Strip */ }
  214. .replace (/\/\/.+$/gm, '') // Double-slash comments wreck CSS. Strip them.
  215. ;
  216. return str;
  217. }
  218.  
  219. function onlyUnique(value, index, self) {
  220. return self.indexOf(value) === index;
  221. }
  222.