dd-ignore-tempermonkey

Hide blacklisted users and their data.

当前为 2014-11-15 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name dd-ignore-tempermonkey
  3. // @version 0.2
  4. // @description Hide blacklisted users and their data.
  5. // @include http://www.darkdiary.ru/
  6. // @include http://darkdiary.ru/
  7. // @include darkdiary.ru/
  8. // @include http://www.darkdiary.ru/?page=*
  9. // @include http://darkdiary.ru/?page=*
  10. // @include darkdiary.ru/?page=*
  11. // @include http://www.darkdiary.ru/users/*
  12. // @include http://darkdiary.ru/users/*
  13. // @include darkdiary.ru/users/*
  14. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js
  15. // @grant GM_getValue
  16. // @grant GM_setValue
  17. // @grant GM_log
  18. // @namespace https://gf.qytechs.cn/users/6880
  19. // ==/UserScript==
  20.  
  21. var antimagic = function(event){
  22. var nick = $(this).siblings("a[href $= '/profile']").attr("href").replace("/users/","").replace("/profile","");
  23. removeFromList(nick);
  24. event.preventDefault();
  25. };
  26.  
  27. var toggle = function(event){
  28. var pObjects=$(this).parents("article").children().siblings("[class!='notice']");
  29. var strStyle=pObjects.attr("style");
  30. //GM_log(strStyle);
  31. var strQ="Скрыть?"
  32. if(strStyle=="display:none"){
  33. pObjects.attr("style","padding-bottom:3px")
  34. }else{
  35. pObjects.attr("style","display:none")
  36. strQ="Показать?"
  37. }
  38. $(this).parents("article").find("a[class='igShow']").html(strQ);
  39. event.preventDefault();
  40. };
  41.  
  42. var hide = function(ignoreList){
  43. ignoreList.forEach(function(value, index, array){
  44. $('a[title^="Профиль пользователя"][href="/users/' + value + '/profile"] + a + a').closest("div[class='userlistRow']").attr("style","display:none");
  45. var pToHide=$('a[title^="Профиль пользователя"][href="/users/' + value + '/profile"] + a + a').attr("title", "Скрыть").unbind("click").bind("click", toggle)
  46. .after(" <a title='Амнистировать' class='forgive friendreqButton' href = '#'></a>")
  47. .closest("article[class^='block comment']");
  48. var strPrevEl="div[class!='notice']";
  49. if(pToHide.size()<1){
  50. pToHide=$('a[title^="Профиль пользователя"][href="/users/' + value + '/profile"] + a + a')
  51. .closest("article[class^='block entry']");
  52. strPrevEl="div[class^='rightPane']";
  53. }
  54. //if(pToHide.length<1) continue;
  55. pToHide.children().siblings("[class!='notice']").attr("style","display:none").siblings(strPrevEl)
  56. .after("<section class='notice' style='" + noticeStyle + "'><div class='textBg' data-user='" + value +
  57. "' style='border:solid 1px #ddddcc; padding-left: 120px'>Пользователь <b>" +
  58. value + "</b> написал какую-то глупость. <a class='igShow' href='#'>Показать?</a></div></section>");
  59. GM_log(pToHide);
  60. });
  61. $("a.igShow").unbind("click").bind("click", toggle);
  62. $("a.forgive").unbind("click").bind("click", antimagic);
  63. };
  64.  
  65. var magic = function(event){
  66. var nick = $(this).siblings("a[href $= '/profile']").attr("href").replace("/users/","").replace("/profile","");
  67. GM_setValue("dd_ignore", GM_getValue("dd_ignore", " ").replace(" " + nick + " ", " ") + nick + " ");
  68. fillList(GM_getValue("dd_ignore", " ").split(" "));
  69. hide([nick]);
  70. event.preventDefault();
  71. };
  72.  
  73. var antimagicByName = function(event){
  74. var nick= $(this).closest("div").prev().attr("href").replace("/users/","").replace("/profile","").replace("/","");
  75. removeFromList(nick);
  76. event.preventDefault();
  77. };
  78.  
  79. var removeFromList = function(nick){
  80. GM_setValue("dd_ignore", GM_getValue("dd_ignore", " ").replace(" " + nick+" ", " "));
  81. fillList(GM_getValue("dd_ignore", " ").split(" "));
  82. $("div[data-user = '" + nick + "']").parent().siblings().attr("style","").siblings("div[class!='leftPane'][class!='rightPane rightPaneOffset']").attr("style","clear:both;");
  83. $("div[data-user = '" + nick + "']").parent().remove();
  84. $('a[title^="Профиль"][href="/users/' + nick + '/profile"] + a + a').attr("title", "В игнор").unbind("click").bind("click", magic).next().remove();
  85. $('a[title^="Профиль пользователя"][href="/users/' + value + '/profile"] + a + a').closest("div[class='userlistRow']").attr("style","");
  86. };
  87. var fillList = function(ignoreList){
  88. ignoreListContainer.html("<h1 class='section'>Список игнора</h1>");
  89. ignoreListContainer.next().remove();
  90. var tmpList="<div>";
  91. ignoreList.forEach(function(value, index, array){
  92. if(value!="")tmpList+='<div class="userlistRow"><a href="/users/'+value+'/">'+value+'</a>'+
  93. '<div class="controls"><a title="Амнистировать" class="forgiveFromList friendreqButton" href = "#"></a></div></div>'
  94. });
  95. tmpList+="</div>";
  96. ignoreListContainer.after(tmpList);
  97. $("a.forgiveFromList").unbind("click").bind("click", antimagicByName);
  98. };
  99.  
  100. var showIgnore = function(event){
  101. ignoreListStyle=(ignoreListStyle=="display:none"?"padding-bottom:3px":"display:none");
  102. ignoreListContainer.closest("h1").parent().attr("style", ignoreListStyle);
  103. $(this).text(ignoreListStyle=="display:none"?"Показать список":"Скрыть список");
  104. GM_setValue("ignoreListStyle", ignoreListStyle);
  105. fillList(GM_getValue("dd_ignore", " ").split(" "));
  106. event.preventDefault();
  107. };
  108.  
  109. var toggleNotices = function(event){
  110. if( $(this).text() == "Скрыть оповещения"){
  111. noticeStyle = "display:none";
  112. $(this).text("Показать оповещения");
  113. $(".notice").attr("style", noticeStyle);
  114. }else{
  115. noticeStyle = "padding-bottom:3px";
  116. $(this).text("Скрыть оповещения");
  117. $(".notice[style='display:none']").attr("style", noticeStyle);
  118. }
  119. GM_setValue("noticeStyle", noticeStyle);
  120. event.preventDefault();
  121. };
  122.  
  123. var noticeStyle = GM_getValue("noticeStyle", "padding-bottom:3px");
  124. var ignoreListStyle = GM_getValue("ignoreListStyle", "display:none");
  125. var ignoreListContainerType=0;
  126. var ignoreListContainer;
  127. var ignoreListContainerHolder=$("h1.section:contains('Наши интересы')").parent().parent();
  128. if(ignoreListContainerHolder.prop("baseURI")==undefined){
  129. ignoreListContainerType=1;
  130. ignoreListContainerHolder=$("h1.section:contains('Мои теги')").parent().parent();
  131. if(ignoreListContainerHolder.prop("baseURI")==undefined){
  132. ignoreListContainerHolder=$("h1.section:contains(' друзья')").parent().parent();
  133. if(ignoreListContainerHolder.prop("baseURI")==undefined){
  134. ignoreListContainerType=-1;
  135. }
  136. }
  137. }
  138. if(ignoreListContainerType>=0){
  139. var sHTMLTemplate='<div class="block"><h1 class="section">1</h1></div>';
  140. ignoreListContainerHolder.children().last().after(sHTMLTemplate);
  141. ignoreListContainer=ignoreListContainerHolder.find("h1.section").last();
  142. }
  143. ignoreListContainer.closest("h1").parent().attr("style", ignoreListStyle);
  144. fillList(GM_getValue("dd_ignore", " ").split(" "));
  145. $("a[class ^= 'profileButton'][href $= '/profile'] + a").after(" <a title='В игнор' class = 'clIgnore deleteButton inline' href = '#'></a>");
  146. $(".clIgnore").bind("click", magic);
  147. $("div.section:contains('Мой дневник')").parent().after("<nav class='block leftMenu'><div class='section'>Игнор</div>"+
  148. "<a id='showIgnoreList' href='#'>" +
  149. (ignoreListStyle == "display:none" ? "Показать список" : "Скрыть список")+"</a><a id='toggleNotices' href='#'>" +
  150. (noticeStyle == "display:none" ? "Показать оповещения" : "Скрыть оповещения")+"</a></nav>");
  151. $("#showIgnoreList").bind("click", showIgnore);
  152. $("#toggleNotices").bind("click", toggleNotices);
  153. hide(GM_getValue("dd_ignore", " ").split(" "));

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址