ImDantuiMan

单推man的觉悟

  1. // ==UserScript==
  2. // @name ImDantuiMan
  3. // @namespace https://www.joi-club.cn/
  4. // @version 0.2
  5. // @description 单推man的觉悟
  6. // @author Xinrea
  7. // @include https://t.bilibili.com/*
  8. // @include https://space.bilibili.com/*/dynamic
  9. // @exclude https://t.bilibili.com/h5/*
  10. // @require https://cdn.staticfile.org/jquery/3.3.1/jquery.min.js
  11. // @grant none
  12. // @run-at document-end
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. 'use strict';
  17. // waitForKeyElements.js: https://gist.github.com/BrockA/2625891
  18. function waitForKeyElements (
  19. selectorTxt, /* Required: The jQuery selector string that
  20. specifies the desired element(s).
  21. */
  22. actionFunction, /* Required: The code to run when elements are
  23. found. It is passed a jNode to the matched
  24. element.
  25. */
  26. bWaitOnce, /* Optional: If false, will continue to scan for
  27. new elements even after the first match is
  28. found.
  29. */
  30. iframeSelector /* Optional: If set, identifies the iframe to
  31. search.
  32. */
  33. ) {
  34. var targetNodes, btargetsFound;
  35.  
  36. if (typeof iframeSelector == "undefined")
  37. targetNodes = $(selectorTxt);
  38. else
  39. targetNodes = $(iframeSelector).contents ()
  40. .find (selectorTxt);
  41.  
  42. if (targetNodes && targetNodes.length > 0) {
  43. btargetsFound = true;
  44. /*--- Found target node(s). Go through each and act if they
  45. are new.
  46. */
  47. targetNodes.each ( function () {
  48. var jThis = $(this);
  49. var alreadyFound = jThis.data ('alreadyFound') || false;
  50.  
  51. if (!alreadyFound) {
  52. //--- Call the payload function.
  53. var cancelFound = actionFunction (jThis);
  54. if (cancelFound)
  55. btargetsFound = false;
  56. else
  57. jThis.data ('alreadyFound', true);
  58. }
  59. } );
  60. }
  61. else {
  62. btargetsFound = false;
  63. }
  64.  
  65. //--- Get the timer-control variable for this selector.
  66. var controlObj = waitForKeyElements.controlObj || {};
  67. var controlKey = selectorTxt.replace (/[^\w]/g, "_");
  68. var timeControl = controlObj [controlKey];
  69.  
  70. //--- Now set or clear the timer as appropriate.
  71. if (btargetsFound && bWaitOnce && timeControl) {
  72. //--- The only condition where we need to clear the timer.
  73. clearInterval (timeControl);
  74. delete controlObj [controlKey]
  75. }
  76. else {
  77. //--- Set a timer, if needed.
  78. if ( ! timeControl) {
  79. timeControl = setInterval ( function () {
  80. waitForKeyElements ( selectorTxt,
  81. actionFunction,
  82. bWaitOnce,
  83. iframeSelector
  84. );
  85. },
  86. 300
  87. );
  88. controlObj [controlKey] = timeControl;
  89. }
  90. }
  91. waitForKeyElements.controlObj = controlObj;
  92. }
  93. let d = $.ajax({
  94. url:'https://api.bilibili.com/x/relation/tag?tagid=-10&pn=1&ps=1&jsonp=jsonp',
  95. xhrFields: {
  96. withCredentials: true
  97. },
  98. async: false,
  99. success : function(liveData) {
  100. for(var index in liveData["data"]["items"]){
  101. var i = liveData["data"]["items"][index]
  102. liveStatus[i["uid"]] = { "title":i["title"], "link":i["link"]}
  103. }
  104. }})
  105. let DaisukiMid = (d.responseJSON.data)[0]["mid"]
  106. let Self = getCookie("DedeUserID")
  107. waitForKeyElements('.button-bar',banInteract,false)
  108. waitForKeyElements('.comment-send',banComment,false)
  109. function banInteract(jNode) {
  110. var link = jNode.eq(0).parents(".card").children('a').attr('href')
  111. if (link == null) return
  112. var uid = link.replace(/[^0-9]/ig,"")
  113. if (uid == Self) return
  114. var bangumi = link.indexOf("bangumi")
  115. if (uid == DaisukiMid || bangumi != -1){
  116. } else {
  117. jNode.eq(0).find(".text-bar").children().remove()
  118. }
  119. }
  120. function banComment(jNode) {
  121. var link = jNode.eq(0).parents(".card").children('a').attr('href')
  122. if (link == null) return
  123. var uid = link.replace(/[^0-9]/ig,"")
  124. if (uid == Self) return
  125. if (uid == DaisukiMid){
  126. } else {
  127. jNode.eq(0).remove()
  128. }
  129. }
  130. function getCookie(name) {
  131. var prefix = name + "="
  132. var start = document.cookie.indexOf(prefix)
  133.  
  134. if (start == -1) {
  135. return null;
  136. }
  137.  
  138. var end = document.cookie.indexOf(";", start + prefix.length)
  139. if (end == -1) {
  140. end = document.cookie.length;
  141. }
  142.  
  143. var value = document.cookie.substring(start + prefix.length, end)
  144. return unescape(value);
  145. }
  146. })();