dd-ignore-tempermonkey

Hide blacklisted users and their data.

  1. // ==UserScript==
  2. // @name dd-ignore-tempermonkey
  3. // @namespace https://gf.qytechs.cn/en/scripts/6473-dd-ignore-tempermonkey
  4. // @version 0.4.7
  5. // @description Hide blacklisted users and their data.
  6. // @include *darkdiary.ru/*
  7. // @require https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js
  8. // @grant GM.getValue
  9. // @grant GM.setValue
  10. // @license GPLv3
  11. // ==/UserScript==
  12.  
  13.  
  14. var noticeStyle;
  15. var ignoreListStyle;
  16. var ignoreListContainerType;
  17. var ignoreListContainer;
  18. var ignoreListContainerHolder;
  19. var loggedIn;
  20. var currentListValues;
  21. var leftmenu;
  22. var loginMenu;
  23.  
  24. var removeFromList = async function (nick) {
  25. console.log("remove "+nick);
  26. currentListValues = currentListValues.replace(' ' + nick + ' ', ' ');
  27. await GM.setValue('dd_ignore', currentListValues);
  28. fillList(currentListValues.split(' '));
  29. $('div[data-user = "' + nick + '"]').parent().siblings().attr('style', '')
  30. .siblings('div[class!="leftPane"][class!="rightPane rightPaneOffset"]').attr('style', 'clear:both;');
  31. $('div[data-user = "' + nick + '"]').parent().remove();
  32. $('a[title^="Профиль"][href="/users/' + nick + '/profile"] + a' + (loggedIn ? ' + a' : ''))
  33. .attr('title', 'В игнор').unbind('click').bind('click', magic).next().remove();
  34. $('a[title^="Профиль пользователя"][href="/users/' + nick + '/profile"] + a' + (loggedIn ? ' + a' : ''))
  35. .closest('div[class="userlistRow"]').attr('style', '');
  36. };
  37.  
  38. var antimagic = function (event) {
  39. var nick = $(this).siblings('a[href $= "/profile"]').attr('href').replace('/users/', '').replace('/profile', '');
  40. removeFromList(nick);
  41. event.preventDefault();
  42. };
  43.  
  44. var toggle = function (event) {
  45. var pObjects = $(this).parents('article').children().siblings('[class!="notice"]');
  46. var strStyle = pObjects.attr('style');
  47. //console.log(strStyle);
  48. var strQ = 'Скрыть?'
  49. if (strStyle == 'display:none') {
  50. pObjects.attr('style', 'padding-bottom:3px')
  51. } else {
  52. pObjects.attr('style', 'display:none')
  53. strQ = 'Показать?'
  54. }
  55. $(this).parents('article').find('a[class="igShow"]').html(strQ);
  56. event.preventDefault();
  57. };
  58.  
  59. var hide = function (ignoreList) {
  60. ignoreList.forEach(function (value, index, array) {
  61. //console.log("hide "+value);
  62. $('a[title^="Профиль пользователя"][href="/users/' + value + '/profile"] + a' + (loggedIn ? ' + a' : ''))
  63. .closest('div[class="userlistRow"]').attr('style', 'display:none');
  64. var pToHide = $('a[title^="Профиль пользователя"][href="/users/' + value + '/profile"] + a' + (loggedIn ? ' + a' : ''))
  65. .attr('title', 'Скрыть').unbind('click')
  66. .bind('click', toggle)
  67. .after(' <a title="Амнистировать" class="forgive friendreqButton" href = "#"></a>')
  68. .closest('article[class^="block comment"]');
  69. var strPrevEl = 'div[class!="notice"]';
  70. if (pToHide.size() < 1) {
  71. pToHide = $('a[title^="Профиль пользователя"][href="/users/' + value + '/profile"] + a' + (loggedIn ? ' + a' : ''))
  72. .closest('article[class^="block entry"]');
  73. strPrevEl = 'div[class^="rightPane"]';
  74. }
  75. pToHide.children().siblings('[class!="notice"]').attr('style', 'display:none').siblings(strPrevEl).after('<section class="notice" style="' +
  76. noticeStyle + '" ><div class="textBg" data-user="' + value +
  77. '" style="border:solid 1px #ddddcc; padding-left: 120px">Пользователь <b>' +
  78. value + '</b> написал какую-то глупость. <a class="igShow" href="#">Показать?</a></div></section>');
  79. //console.log(pToHide);
  80. });
  81. $('a.igShow').unbind('click').bind('click', toggle);
  82. $('a.forgive').unbind('click').bind('click', antimagic);
  83. };
  84.  
  85. var magic = async function (event) {
  86. var nick = $(this).siblings('a[href $= "/profile"]').attr('href').replace('/users/', '').replace('/profile', '');
  87. currentListValues = currentListValues.replace(' ' + nick + ' ', ' ') + nick + ' ';
  88. await GM.setValue('dd_ignore',currentListValues);
  89. fillList(currentListValues.split(' '));
  90. hide([nick]);
  91. console.log("hide " + nick);
  92. event.preventDefault();
  93. };
  94.  
  95. var antimagicByName = function (event) {
  96. var nick = $(this).closest('div').prev().attr('href').replace('/users/', '').replace('/profile', '').replace('/', '');
  97. removeFromList(nick);
  98. event.preventDefault();
  99. };
  100.  
  101. var fillList = function (ignoreList) {
  102. ignoreListContainer.html('<h1 class="section">Список игнора</h1><hr class="divider"></hr></div>');
  103. ignoreListContainer.next().remove();
  104. var tmpList = '<div>';
  105. ignoreList.forEach(function (value, index, array) {
  106. if (value != ''){
  107. tmpList += '<div class="userlistRow"><a href="/users/' + value + '/">' + value + '</a>' +
  108. '<div class="controls"><a title="Амнистировать" class="forgiveFromList friendreqButton" ></a></div></div>';
  109. }
  110. });
  111. tmpList += '</div>';
  112. ignoreListContainer.after(tmpList);
  113. $('a.forgiveFromList').unbind('click').bind('click', antimagicByName);
  114. };
  115.  
  116. var showIgnore = async function (event) {
  117. ignoreListStyle = (ignoreListStyle == 'display:none' ? 'padding-bottom:3px' : 'display:none');
  118. ignoreListContainer.closest('h1').parent().attr('style', ignoreListStyle);
  119. $(this).text(ignoreListStyle == 'display:none' ? 'Показать список' : 'Скрыть список');
  120. await GM.setValue('ignoreListStyle', ignoreListStyle);
  121. fillList(currentListValues);
  122. event.preventDefault();
  123. };
  124.  
  125. var toggleNotices = async function (event) {
  126. noticeStyle = (noticeStyle == 'display:none' ? 'padding-bottom:3px' : 'display:none');
  127. $('.notice').attr('style', noticeStyle);
  128. $(this).text(noticeStyle == 'display:none' ? 'Показать оповещения' : 'Скрыть оповещения');
  129. await GM.setValue('noticeStyle', noticeStyle);
  130. event.preventDefault();
  131. };
  132.  
  133. var initSystem = async function () {
  134. console.log("Ignoring starting...");
  135. noticeStyle = await GM.getValue('noticeStyle', 'padding-bottom:3px');
  136. ignoreListStyle = await GM.getValue('ignoreListStyle', 'display:none');
  137. currentListValues = await GM.getValue('dd_ignore', ' ')
  138. ignoreListContainerType = 0;
  139. ignoreListContainerHolder = $('h1.section:contains("Наши интересы")').parent().parent();
  140. if (ignoreListContainerHolder.prop('baseURI') == undefined) {
  141. ignoreListContainerType = 1;
  142. ignoreListContainerHolder = $('h1.section:contains(" теги")').parent().parent();
  143. if (ignoreListContainerHolder.prop('baseURI') == undefined) {
  144. ignoreListContainerHolder = $('h1.section:contains(" друзья")').parent().parent();
  145. if (ignoreListContainerHolder.prop('baseURI') == undefined) {
  146. ignoreListContainerHolder = $('h1.section:contains("Дневники")').parent().parent();
  147. if (ignoreListContainerHolder.prop('baseURI') == undefined) {
  148. ignoreListContainerType = - 1;
  149. return;
  150. }
  151. }
  152. }
  153. }
  154. if (ignoreListContainerType >= 0) {
  155. var sHTMLTemplate = '<div class="block"><h1 class="section">1</h1>';
  156. ignoreListContainerHolder.children().last().after(sHTMLTemplate);
  157. ignoreListContainer = ignoreListContainerHolder.find('h1.section').last();
  158. }
  159. leftmenu = $('a.dropdown-toggle:contains("DarkDiary.ru")').parent();
  160. loggedIn = false;
  161. loginMenu= $('a.dropdown-toggle:contains("Вход")').parent();
  162. if (loginMenu.prop('baseURI') == undefined) {
  163. loggedIn = true;
  164. }
  165. if (leftmenu.prop('baseURI') == undefined) {
  166. return;
  167. }
  168. ignoreListContainer.closest('h1').parent().attr('style', ignoreListStyle);
  169. fillList(currentListValues.split(' '));
  170. $('a[class ^= "profileButton"][href $= "/profile"]' + (loggedIn ? ' + a' : ''))
  171. .after(' <a title="В игнор" class = "clIgnore deleteButton inline" href = "#"></a>');
  172. $('.clIgnore').bind('click', magic);
  173. leftmenu.after('<li class="dropdown">'+
  174. '<a aria-expanded="false" class="dropdown-toggle" href="#" data-toggle="dropdown">Игнор <strong class="caret"></strong></a>'+
  175. '<ul class="dropdown-menu" role="menu">'+
  176. '<li><a id="showIgnoreList" href="#">' + (ignoreListStyle == 'display:none' ? 'Показать список' : 'Скрыть список') +'</a></li>'+
  177. '<li><a id="toggleNotices" href="#">' + (noticeStyle == 'display:none' ? 'Показать оповещения' : 'Скрыть оповещения') + '</a></li>'+
  178. '</ul></li>');
  179. $('#showIgnoreList').bind('click', showIgnore);
  180. $('#toggleNotices').bind('click', toggleNotices);
  181. hide(currentListValues.split(' '));
  182. console.log("Ignoring started");
  183. }
  184.  
  185. initSystem();

QingJ © 2025

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