Greasy Fork镜像 还支持 简体中文。

dd-ignore-tempermonkey

Hide blacklisted users and their data.

目前為 2014-11-15 提交的版本,檢視 最新版本

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

QingJ © 2025

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