dd-ignore-tempermonkey

Hide blacklisted users and their data.

当前为 2019-02-06 提交的版本,查看 最新版本

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

QingJ © 2025

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