FA SubFilter

Enable/Disable custom submission types with keywords

  1. // ==UserScript==
  2. // @name FA SubFilter
  3. // @namespace FurAffinity
  4. // @version 3.0.0
  5. // @description Enable/Disable custom submission types with keywords
  6. // @author JaysonHusky
  7. // @grant GM_getValue
  8. // @grant GM_setValue
  9. // @match *://www.furaffinity.net/msg/submissions*
  10. // @match *://www.furaffinity.net/gallery*
  11. // @match *://www.furaffinity.net/favorites*
  12. // @match *://www.furaffinity.net/browse*
  13. // @match *://www.furaffinity.net/controls/user-settings/*
  14. // @require https://code.jquery.com/jquery-latest.js
  15. // ==/UserScript==
  16. (function() {
  17. 'use strict';
  18.  
  19. var target_mode="on";
  20. var TemplateStyle=$('body').attr('data-static-path');
  21. if(TemplateStyle===undefined){throw new Error("SubFilter: An error occured. [Code: ERR_TPL_VARS_MIS]");}
  22. // Setup keywords
  23. var SubFilter_Keywords;
  24. var sf_ud_keywords;
  25. // Begin loading
  26. function FASFM_Load(){
  27. sf_ud_keywords=GM_getValue('fasfm');
  28. if(sf_ud_keywords>""){
  29. SubFilter_Keywords=sf_ud_keywords.split(",");
  30. $('#fafsm_settings').val(sf_ud_keywords.replace(/,/g,", "));
  31. }
  32. else {
  33. console.log("SubFilter: An error occured while attempting to retrieve keywords. [Code: ERR_KEYS_UNDEFINED]");
  34. }
  35. }
  36. // Add Special Stylesheet for keywords
  37. var JaysCSS=document.createElement('style');
  38. var jayStyle=document.createTextNode(`
  39. i.fafsm{
  40. margin-right:5px;
  41. padding:1px;
  42. }
  43. span.fafx-update-status{
  44. font-weight:bold;
  45. color:#04fd04;
  46. float:right;
  47. clear:right;
  48. display:none;
  49. }
  50. #customfacontrolpanel{
  51. /*border:1px dashed white;
  52. background:rgba(1,0,0,0.1);
  53. padding:5px;
  54. border-radius:5px;*/
  55. margin-top:20px;
  56. }
  57. .JaySB{
  58. background: #36393d;
  59. padding: 7px 14px 14px 14px;
  60. }
  61. #speciallisting li{
  62. margin-left:20px;
  63. }
  64. `);
  65. JaysCSS.appendChild(jayStyle);
  66. document.getElementsByTagName('body')[0].appendChild(JaysCSS);
  67. // Save settings
  68. function FAFSM_SaveSettings(fasfm){
  69. GM_setValue('fasfm',fasfm);
  70. }
  71. // Load Control Panel
  72. var pathx=window.location.pathname;
  73. if(~pathx.indexOf("/controls/user-settings/")){
  74. // Update
  75. $(document.body).on('click','#fafsm_saveit',function(){
  76. var fafsm_set=$("input[name='fafsm_setting']").val().replace(/ /g,"").replace(/ /g,"");
  77. FAFSM_SaveSettings(fafsm_set);
  78. $('.fafx-update-status').fadeIn('slow');
  79. setTimeout(function(){
  80. $('.fafx-update-status').fadeOut('slow');
  81. }, 5000);
  82. });
  83. if(TemplateStyle=="/themes/beta"){
  84. $('.content .section-body').after(`
  85. <div id="customfacontrolpanel" class="JaySB">
  86. <h2>SubFilter Control Panel <span class="fafx-update-status">Update successful!</span></h2>
  87. <br/>
  88. <h4>Custom Keywords to blacklist in submissions inbox</h4>
  89. <div class="control-panel-option">
  90. <div class="control-panel-item-1">
  91. <p>
  92. <ul id="speciallisting">
  93. <li>Keywords must be comma seperated.</li>
  94. <li>Case insensitive</li>
  95. <li>Singular terms will match plurals.</li>
  96. </ul>
  97. </p>
  98. </div>
  99. <div class="control-panel-item-2">
  100. <input type="text" name="fafsm_setting" id="fafsm_settings" class="textbox" placeholder="Example: free,fender,commission" style="height:36px;padding:5px; width:300px" />
  101. </div>
  102. </div>
  103. <div class="button-nav">
  104. <div class="button-nav-item">
  105. <input class="button mobile-button" id="fafsm_saveit" type="button" value="Save SubFilter Settings*">
  106. </div>
  107. </div>
  108. <br/><b>*Updates take effect from the next page load.</b><br/><span style="font-size:10px;position:relative;bottom:0;right:0;">SubFilter (A user controlled FA Blacklisting tool) by <a href="https://www.furaffinity.net/user/feralfrenzy" style="border-bottom:1px dotted white;">JaysonHusky</a></span>
  109. </div><br/><br/>`);
  110. }
  111. else {
  112. $('.footer').before(`<table cellpadding="0" cellspacing="1" border="0" class="section maintable" style="width: 60%; margin: 0 auto;">
  113. <tbody>
  114. <tr>
  115. <td height="22" class="cat links">&nbsp;
  116. <strong>SubFilter - Control Panel</strong>
  117. <span class="fafx-update-status">Update successful!</span>
  118. </td>
  119. </tr>
  120. <tr>
  121. <td class="alt1 addpad ucp-site-settings" align="center">
  122. <table cellpadding="0" cellspacing="1" border="0">
  123. <tbody>
  124. <tr>
  125. <th><strong>Custom Keywords to bblock in submissions inbox</strong></th>
  126. <td>
  127. <input type="text" name="fafsm_setting" id="fafsm_settings" class="textbox" placeholder="Example: free,fender,commission" style="padding:5px; width:250px" />
  128. </td>
  129. <td class="option-description">
  130. <p>Enter keywords here for the addon to identify in journal titles. <br/>Keywords must be comma seperated.<br/>Case insensitive<br/>Singular terms will match plurals.</p>
  131. </td>
  132. </tr>
  133. <th class="noborder">&nbsp;</th>
  134. <td class="noborder">&nbsp;</td>
  135. <td class="option-description noborder">
  136. <br><input class="button mobile-button" id="fafsm_saveit" type="button" value="Save Settings*"><br/>
  137. <span style="font-size:10px;">FA Journal Breakdown by <a href="https://www.furaffinity.net/user/feralfrenzy" style="border-bottom:1px dotted white;">JaysonHusky</a></span><br/><br/>
  138. <b>*Updates take effect from the next page load</b>
  139. </td>
  140. </tr>
  141. </tbody>
  142. </table>`);
  143. }
  144. }
  145. FASFM_Load();
  146. // Setup the hook
  147. // Adapt JQuery :contains to function without case restriction
  148. jQuery.expr[':'].icontains=function(a,i,m){return jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase())>=0;};
  149. // JS equiv of PHPs ucwords() for better presentation (Credit: rickycheers @ Github)
  150. String.prototype.ucwords=function(){
  151. st2uc=this.toLowerCase();
  152. return st2uc.replace(/(^([a-zA-Z\p{M}]))|([ -][a-zA-Z\p{M}])/g,function(s){
  153. return s.toUpperCase();
  154. });
  155. };
  156. function subcount(inp){if(isNaN(inp)===true){return "0";}else{return inp;}}
  157. // Search for custom keywords
  158. if(SubFilter_Keywords===undefined){}
  159. else{
  160. SubFilter_Keywords.forEach(function(keyword){
  161. if(target_mode=="on"){
  162. // Message Center ( Submissions Only )
  163. $("#messagecenter-submissions section figure figcaption").find("label a:icontains('"+keyword+"')").parent().parent().parent().parent().css('display','none');
  164. // User Profile Gallery
  165. $("#gallery-gallery figure figcaption").find("a:icontains('"+keyword+"')").parent().parent().parent().css('display','none');
  166. // User Profile Favourites
  167. $("#gallery-favorites figure figcaption").find("a:icontains('"+keyword+"')").parent().parent().parent().css('display','none');
  168. // Browse Page
  169. $("#gallery-browse figure figcaption").find("a:icontains('"+keyword+"')").parent().parent().parent().css('display','none');
  170. // Deactivate on Search page as the user can filter by themselves there.
  171. }
  172. else {
  173. // Message Center ( Submissions Only )
  174. $("#messagecenter-submissions section figure figcaption").find("label p:first a:icontains('"+keyword+"')").parent().parent().parent().parent().css('display','none');
  175. // User Profile Gallery
  176. $("#gallery-gallery figure figcaption").find("p:first a:icontains('"+keyword+"')").parent().parent().parent().css('display','none');
  177. // User Profile Favourites
  178. $("#gallery-favorites figure figcaption").find("p:first a:icontains('"+keyword+"')").parent().parent().parent().css('display','none');
  179. // Browse Page
  180. $("#gallery-browse figure figcaption").find("p:first a:icontains('"+keyword+"')").parent().parent().parent().css('display','none');
  181. // Deactivate on Search page as the user can filter by themselves there.
  182. }
  183. });
  184. }
  185. })();

QingJ © 2025

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