Guest User

Untitled

a guest
May 13th, 2024
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.47 KB | None | 0 0
  1. // ==UserScript==
  2. // @name NFOHump Hidden Users (Phill test)
  3. // @namespace com.LeoNatan.hideusers
  4. // @version 1.5.6
  5. // @description Adds proper ignore list in NFOHump forums, where posts actually disappear.
  6. // @author Leo Natan
  7. // @match *://nfohump.com/forum/*
  8. // @match *://www.nfohump.com/forum/*
  9. // @grant none
  10. // @downloadURL https://raw.githubusercontent.com/LeoNatan/NFOHump/master/IgnoreList/NFOHumpIgnoreList.user.js
  11. // @updateURL https://raw.githubusercontent.com/LeoNatan/NFOHump/master/IgnoreList/NFOHumpIgnoreList.user.js
  12. // @position 1
  13. // @noframes
  14. // @run-at document-end
  15. // ==/UserScript==
  16.  
  17. if(window.$ == undefined) {
  18. return;
  19. }
  20.  
  21. const className = "hiddenByNFOHumpIgnore";
  22. const supportClassName = "supportForNFOHumpIgnore";
  23.  
  24. if(localStorage.blocklist === null || localStorage.blocklist === undefined)
  25. {
  26. localStorage.blocklist = "";
  27. }
  28.  
  29. if(localStorage.isBlocklistEnabled === null || localStorage.isBlocklistEnabled === undefined)
  30. {
  31. localStorage.isBlocklistEnabled = "true";
  32. }
  33.  
  34. const anchor = $('<a class="mainmenu" style="cursor: pointer;">Hidden users</a>').click(function() {
  35. var q = prompt("Ignored users are hidden automatically.\n\nEnter a comma-separated list of additional users to hide:", localStorage.blocklist);
  36. if(q === null)
  37. {
  38. return;
  39. }
  40.  
  41. if (q != localStorage.blocklist)
  42. {
  43. localStorage.blocklist = q;
  44. resetAndHideElements();
  45. }
  46. });
  47.  
  48. const checkbox = $('<input style="margin: 0px; margin-left: 31px; margin-top: 1px;" type="checkbox" ' + (localStorage.isBlocklistEnabled == "true" ? 'checked' : '') + ' />').click(function () {
  49. localStorage.isBlocklistEnabled = (localStorage.isBlocklistEnabled == "true" ? "false" : "true");
  50. resetAndHideElements();
  51. });
  52.  
  53. const ul = $('#leftdiv > div.menuLeftContainer:first > ul');
  54. const hiddenThreads = ul.find(".hiddethreadsli").first();
  55. const newMenuItem = $('<li class="hiddenusersli" style="vertical-align: middle;"></li>').append(anchor).append(checkbox);
  56. if(hiddenThreads[0] != undefined)
  57. {
  58. hiddenThreads.before(newMenuItem);
  59. }
  60. else
  61. {
  62. ul.append(newMenuItem);
  63. }
  64.  
  65. const ignoreUser = $('<li style="padding-right: 3px;"><a href="about:blank">Hide User</a></li>').click(function(e) {
  66. const clickedUserName = $(e.target).parent().parent().parent().parent().parent().parent().parent().parent().parent().find("a[title^='click to insert']").text();
  67.  
  68. var arr = $.grep($.map(localStorage.blocklist.split(','), function(v) {
  69. return $.trim(v);
  70. }), function(e) { return e !== clickedUserName; });
  71.  
  72. arr.push(clickedUserName);
  73.  
  74. localStorage.blocklist = arr.join(', ');
  75.  
  76. resetAndHideElements();
  77.  
  78. return false;
  79. });
  80.  
  81. const userParents = $("a:contains('Ignore User')").parent();
  82. userParents.before(ignoreUser);
  83. const userParentsAlreadyIgnored = $("a:contains('Un-ignore User')").parent();
  84. userParentsAlreadyIgnored.before(ignoreUser);
  85.  
  86. function hideElements() {
  87. if(window.location.href.includes('/viewtopic.php') == false) {
  88. return;
  89. }
  90.  
  91. if(!(localStorage['blocklist'] && localStorage['blocklist'].length > 0))
  92. {
  93. return;
  94. }
  95.  
  96. $.each(localStorage.blocklist.split(','), function(k,v) {
  97. v = $.trim(v);
  98. $('span.genmed:contains("' + v + '")').each(function() {
  99. if($(this).text().startsWith(v) != true) {
  100. return;
  101. }
  102.  
  103. const x = $(this).parent().parent().parent().parent();
  104.  
  105. if(x.hasClass(className)) {
  106. return;
  107. }
  108.  
  109. x.addClass(className);
  110. if($(x[0]).parents('#userSig').length == 0) {
  111. $.getJSON('https://uselessfacts.jsph.pl/api/v2/facts/random', function(data) {
  112. const y = $('<div class="fact"><div class="fact-text"><span>Random fact</span>' + data.text + '</div></div>');
  113. y.addClass(supportClassName);
  114. y.insertBefore(x);
  115. });
  116. }
  117. x.hide();
  118. });
  119. $('span.nav > b > a:contains("' + v + '")').each(function() {
  120. if($(this).text() !== v) {
  121. return;
  122. }
  123.  
  124. const x = $(this).parents('td:eq(0)').parent();
  125.  
  126. if(x.hasClass(className)) {
  127. return;
  128. }
  129.  
  130. x.addClass(className);
  131. x.hide();
  132. x.next().addClass(className);
  133. x.next().hide();
  134. x.next().next().addClass(className);
  135. x.next().next().hide();
  136. });
  137. });
  138. }
  139.  
  140. function resetHiddenElements() {
  141. $('.' + supportClassName).remove();
  142. $('.' + className).each(function () {
  143. $(this).removeClass(className);
  144. $(this).show();
  145. });
  146. }
  147.  
  148. function resetAndHideElements() {
  149. resetHiddenElements();
  150. if (localStorage.isBlocklistEnabled == "true") {
  151. hideElements();
  152. }
  153.  
  154. //Rerun the video embedding script to fixup hidden posts.
  155. if(window.__api_applyEmbedding)
  156. {
  157. window.__api_applyEmbedding();
  158. }
  159. }
  160.  
  161. resetAndHideElements();
  162.  
  163. // Add CSS styles
  164. const styles = `
  165. .fact {
  166. font-size: 12px;
  167. color: #ffd700;
  168. border-left: 5px solid #ffd700;
  169. padding: 15px;
  170. background: rgba(0,0,0,.25);
  171. }
  172. .fact span {
  173. display: block;
  174. margin-bottom: 4px;
  175. font-size: 10px;
  176. text-transform: uppercase;
  177. color: #fff;
  178. font-weight: bold;
  179. }
  180. `;
  181.  
  182. $('<style>').text(styles).appendTo('head');
  183.  
Advertisement
Add Comment
Please, Sign In to add comment