Greasy Fork 支持简体中文。

Planets.nu Ignore Script

Ignore those pesky other users!

  1. // ==UserScript==
  2. // @name Planets.nu Ignore Script
  3. // @namespace https://greasyfork.org/users/2984
  4. // @version 0.5
  5. // @description Ignore those pesky other users!
  6. // @author Dotman
  7. // @copyright 2014, Dotman
  8. // @license CC BY-NC-ND 4.0 (http://creativecommons.org/licenses/by-nc-nd/4.0/)
  9. // @include http://planets.nu/#/*
  10. // @include http://planets.nu/*
  11. // @grant GM_setValue
  12. // @grant GM_getValue
  13. // ==/UserScript==
  14.  
  15. /*
  16. (function() {
  17. 'use strict';
  18.  
  19. alert("IgnoreScript3!");
  20. alert($('div.eaccountfeedtitle').length);
  21. $(document).ready(function() {
  22. alert($('div.eaccountfeedtitle').length);
  23. $('div.eaccountfeedtitle').remove();
  24. });
  25. })();
  26. */
  27.  
  28. var getIgnoredUserList = function() {
  29. //alert(GM_getValue("ignoredusers"));
  30. return JSON.parse(GM_getValue("ignoredusers"));
  31. };
  32.  
  33.  
  34. var addUserToIgnoreList = function(uname) {
  35. var userIgnoreList = getIgnoredUserList();
  36. if (userIgnoreList === null) {
  37. userIgnoreList = [];
  38. }
  39. userIgnoreList.push(uname);
  40. GM_setValue("ignoredusers",JSON.stringify(userIgnoreList));
  41. };
  42.  
  43. var clearUserIgnoreList = function() {
  44. GM_setValue("ignoredusers",JSON.stringify([]));
  45. alert("User Ignore List Cleared.");
  46. location.reload();
  47. };
  48.  
  49.  
  50. var getIgnoredThreadList = function() {
  51. alert(GM_getValue("ignoredthreads"));
  52. return JSON.parse(GM_getValue("ignoredthreads"));
  53. };
  54.  
  55.  
  56. var addThreadToIgnoreList = function(tname) {
  57. var threadIgnoreList = getIgnoredThreadList();
  58. if (threadIgnoreList === null) {
  59. threadIgnoreList = [];
  60. }
  61. threadIgnoreList.push(tname);
  62. GM_setValue("ignoredthreads",JSON.stringify(threadIgnoreList));
  63. };
  64.  
  65. var clearThreadIgnoreList = function() {
  66. GM_setValue("ignoredthreads",JSON.stringify([]));
  67. alert("Thread Ignore List Cleared.");
  68. };
  69.  
  70. var hideMessages = function() {
  71.  
  72. // Check the ignored user list and clear anything that should be ignored
  73. var ignoredUsers = getIgnoredUserList();
  74. // Handle the activity feed
  75. $('div.eaccountfeedline:has(div.etimeago:has(a[href^="#/account/"]:has(span)))').each(function(index, elem) {
  76. //console.log($(this > div.etimeago).text());
  77. //console.log("INDEX: " + index + " >>> Timeagoelems: " + $('this > div.etimeago:has(a[href^="#/account/"]:has(span)', elem).text());
  78. // console.log("INDEX: " + index + " >>> Timeagoelems: " + $('div.etimeago',elem));
  79. // console.log($('div.etimeago:has(a):has(span)',elem));
  80. console.log("Index: " + index + ">>>");
  81. console.log($('div.eaccountfeedline:has(div.etimeago:has(a[href^="#/account/"]:has(span)))',elem));
  82. $('div.etimeago > a[href^="#/account/"] > span',elem).each(function(ind,e) {
  83. console.log("***");
  84. console.log($(e).text());
  85. //if ($(e).text() == "rsk") {
  86. if (ignoredUsers.indexOf($(e).text()) >= 0) {
  87. console.log("FOUNDFOUNDFOUND: " + $(e).text());
  88. //$(elem).remove();
  89. console.log($(e).parent().parent().next('div.efeedmessage'));
  90. $(e).parent().parent().next('div.efeedmessage').remove();
  91. $(e).parent().parent().remove();
  92. }
  93. });
  94. console.log($('div.etimeago > a[href^="#/account/"] > span',elem).text());
  95. console.log($('div.etimeago > a[href^="#/account/"] > span',elem).length);
  96. console.log("<<<");
  97. });
  98. console.log("Handling full feed.");
  99. // Handle the full activity feed
  100. //$('div.efeedline:has(div:has(div.etimeago:has(a[href^="#/account/"]:has(span))))').each(function(index, elem) {
  101. $('div.efeedtitle:has(a[href^="#/account/"]:has(span))').each(function(index,elem) {
  102. //console.log(elem);
  103. //console.log($('a[href^="#/account/"] > span',elem).text());
  104. //if ($('a[href^="#/account/"] > span',elem).text() == "ace rimmer") {
  105. if (ignoredUsers.indexOf($('a[href^="#/account/"] > span',elem).text()) >= 0) {
  106. if ($(elem).parent().parent().prop('className') == "efeedline") {
  107. console.log("****** IN ");
  108. $(elem).next().next().remove();
  109. $(elem).next().remove();
  110. $(elem).parent().prev().html("");
  111. $(elem).remove();
  112. }
  113. else {
  114. $(elem).parent().parent().remove();
  115. }
  116. }
  117. });
  118. /*
  119. $('div.efeedline:has(div:has(div.etimeago:has(a[href^="#/account/"])))').each(function(index, elem) {
  120. //console.log($(this > div.etimeago).text());
  121. //console.log("INDEX: " + index + " >>> Timeagoelems: " + $('this > div.etimeago:has(a[href^="#/account/"]:has(span)', elem).text());
  122. // console.log("INDEX: " + index + " >>> Timeagoelems: " + $('div.etimeago',elem));
  123. // console.log($('div.etimeago:has(a):has(span)',elem));
  124. console.log("EFIndex: " + index + ">>>");
  125. console.log($('div.efeedline:has(div.etimeago:has(a[href^="#/account/"]:has(span)))',elem));
  126. $('div.etimeago > a[href^="#/account/"] > span',elem).each(function(ind,e) {
  127. console.log("***");
  128. console.log($(e).text());
  129. //if ($(e).text() == "rsk") {
  130. if (ignoredUsers.indexOf($(e).text()) >= 0) {
  131. console.log("FOUNDFOUNDFOUND: " + $(e).text());
  132. //$(elem).remove();
  133. console.log($(e).parent().parent().next('div.efeedmessage'));
  134. $(e).parent().parent().next('div.efeedmessage').remove();
  135. $(e).parent().parent().remove();
  136. }
  137. });
  138. console.log($('div.etimeago > a[href^="#/account/"] > span',elem).text());
  139. console.log($('div.etimeago > a[href^="#/account/"] > span',elem).length);
  140. console.log("<<<");
  141. });
  142. */
  143. };
  144.  
  145. var addIgnoreKeys = function() {
  146. $('div.eaccountstartfeed').after("<a class='dotclearuignore'>Clear Ignored Userlist</a>");
  147. //$('div.etimeago').append(" ");
  148. //$('div.etimeago').append("<a class='dottignore'>Ignore Thread</a>");
  149. $('div.etimeago').append(" ");
  150. $('div.etimeago').append("<a class='dotuignore'>Ignore User</a>");
  151. $('.dotclearuignore').click(function() {
  152. clearUserIgnoreList();
  153. });
  154. $('.dottignore').click(function() {
  155. var thread = $(this).parent();
  156. //$('div.eaccountfeedline').remove();
  157. });
  158. $('.dotuignore').click(function() {
  159. var parparclass = $(this).parent().parent().parent().prop('className').trim();
  160. console.log("ParPar: >>" + parparclass + "<<");
  161. if (parparclass === "ereply" || parparclass === "efeedline") {
  162. console.log("In parparclass");
  163. var user = $(this).parent().parent().children('div.efeedtitle').children('a:first-child').children('span').text();
  164. }
  165. else {
  166. var user = $(this).parent().children('a:first-child').children('span').text();
  167. }
  168. // alert(user);
  169. //GM_setValue("ignoredusers",user);
  170. addUserToIgnoreList(user);
  171. //var tt = GM_getValue("ignoredusers");
  172. var tt = getIgnoredUserList();
  173. // alert(tt);
  174. hideMessages();
  175. //$('div.eaccountfeedline').remove();
  176. });
  177. hideMessages();
  178. /*
  179. // Check the ignored user list and clear anything that should be ignored
  180. var ignoredUsers = getIgnoredUserList();
  181. $('div.eaccountfeedline:has(div.etimeago:has(a[href^="#/account/"]:has(span)))').each(function(index, elem) {
  182. //console.log($(this > div.etimeago).text());
  183. //console.log("INDEX: " + index + " >>> Timeagoelems: " + $('this > div.etimeago:has(a[href^="#/account/"]:has(span)', elem).text());
  184. // console.log("INDEX: " + index + " >>> Timeagoelems: " + $('div.etimeago',elem));
  185. // console.log($('div.etimeago:has(a):has(span)',elem));
  186. console.log("Index: " + index + ">>>");
  187. console.log($('div.eaccountfeedline:has(div.etimeago:has(a[href^="#/account/"]:has(span)))',elem));
  188. $('div.etimeago > a[href^="#/account/"] > span',elem).each(function(ind,e) {
  189. console.log("***");
  190. console.log($(e).text());
  191. //if ($(e).text() == "rsk") {
  192. if (ignoredUsers.indexOf($(e).text()) >= 0) {
  193. console.log("FOUNDFOUNDFOUND: " + $(e).text());
  194. //$(elem).remove();
  195. console.log($(e).parent().parent().next('div.efeedmessage'));
  196. $(e).parent().parent().next('div.efeedmessage').remove();
  197. $(e).parent().parent().remove();
  198. }
  199. });
  200. console.log($('div.etimeago > a[href^="#/account/"] > span',elem).text());
  201. console.log($('div.etimeago > a[href^="#/account/"] > span',elem).length);
  202. console.log("<<<");
  203. });
  204. */
  205. };
  206.  
  207.  
  208. //alert("IgnoreScript6!");
  209. //GM_setValue("ignoredusers","aguy");
  210. //addUserToIgnoreList("aguy");
  211. //alert(getIgnoredUserList());
  212.  
  213. $(document).ready(function() {
  214. $(window).hashchange( function(){
  215. // Alerts every time the hash changes!
  216. //alert("Hash change!");
  217. setTimeout(addIgnoreKeys, 1000);
  218. });
  219. setTimeout(addIgnoreKeys, 2000);
  220. });
  221.  
  222.  
  223. /*
  224. var a = [1, 2, 3];
  225. GM_setValue("key", JSON.stringify(a));
  226.  
  227. var b = JSON.parse(GM_getValue("key"));
  228. */
  229.  
  230. /*
  231.  
  232. function wrapper() {
  233. alert("IgnoreScript5!");
  234. //GM_setValue("ignoredusers","aguy");
  235. addUserToIgnoreList("aguy");
  236. alert(getIgnoredUserList());
  237. $(document).ready(function() {
  238. setTimeout(function() {
  239. //alert($('div.eaccountfeedline').length);
  240. // $('div.eaccountfeedtitle').empty();
  241. // $('div.eaccountfeedline').remove();
  242. //$('div#eactivitycol').remove();
  243. //alert($('div.eaccountfeedtitle').length);
  244. $('div.etimeago').append(" ");
  245. $('div.etimeago').append("<a class='dottignore'>Ignore Thread</a>");
  246. $('div.etimeago').append(" ");
  247. $('div.etimeago').append("<a class='dotuignore'>Ignore User</a>");
  248. $('.dottignore').click(function() {
  249. var thread = $(this).parent();
  250. //$('div.eaccountfeedline').remove();
  251. });
  252. $('.dotuignore').click(function() {
  253. var user = $(this).parent().children('a:first-child').children('span').text();
  254. alert(user);
  255. GM_setValue("ignoredusers",user);
  256. var tt = GM_getValue("ignoredusers");
  257. alert(tt);
  258. //$('div.eaccountfeedline').remove();
  259. });
  260.  
  261. }, 2000);
  262. });
  263. }
  264.  
  265. var script = document.createElement("script");
  266. script.type = "application/javascript";
  267. script.textContent = "(" + wrapper + ")();";
  268.  
  269. document.body.appendChild(script);
  270. document.body.removeChild(script);
  271.  
  272. */