FA Fixes Control Panel

Adds a control panel of fixes to the FurAffinity website, so you can enable/disable them at will.

当前为 2016-11-04 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name FA Fixes Control Panel
  3. // @namespace FurAffinity.net
  4. // @version 1.2
  5. // @description Adds a control panel of fixes to the FurAffinity website, so you can enable/disable them at will.
  6. // @author JaysonHusky
  7. // @match *://www.furaffinity.net/*
  8. // @grant GM_getValue
  9. // @grant GM_setValue
  10. // @require http://code.jquery.com/jquery-latest.js
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15. // Load Current Settings
  16. function FAFCP_LoadCP(i){
  17. var setting_returned = GM_getValue(i);
  18. if(setting_returned=="yes"){
  19. $('#'+i+'_yes').prop("checked", true);
  20. }
  21. else if(setting_returned=="no") {
  22. $('#'+i+'_no').prop("checked", true);
  23. }
  24. else {
  25. console.log('Setting: '+i+' Returned: '+setting_returned+' (Other Result)');
  26. }
  27. }
  28. function FAFCP_Load_Tweaks(i){
  29. var setting_returned = GM_getValue(i);
  30. if(setting_returned=="yes"){
  31. return "yes";
  32. }
  33. else if(setting_returned=="no") {
  34. return "no";
  35. }
  36. else {
  37. return "undefined";
  38. }
  39. }
  40. function FAFCP_SaveSettings(fafcp_nct,fafcp_sbg,fafcp_hs,fafcp_os,fafcp_sst,fafcp_fn,fafcp_tp){
  41. GM_setValue('fafcp_nct',fafcp_nct);GM_setValue('fafcp_sbg',fafcp_sbg);GM_setValue('fafcp_hs',fafcp_hs);GM_setValue('fafcp_os',fafcp_os);
  42. GM_setValue('fafcp_sst',fafcp_sst);GM_setValue('fafcp_fn',fafcp_fn);GM_setValue('fafcp_tp',fafcp_tp);
  43. }
  44. function ExecuteTweak(tweak){
  45. switch(tweak) {
  46. case "NoCustomThumbnails":
  47. $("img[src*='t.facdn.net']").each(function(index){
  48. var thumburl=$(this).attr('src').replace("@150","@400");
  49. $(this).attr("src",thumburl);
  50. });
  51. break;
  52. case "SidebarBeGone":
  53. $("<style>#submission_page .submission-sidebar{position:fixed;top:50px;bottom:0px;right:-290px;z-index:1000000;background:rgba(1,0,0,0.6);transition: 0.5s all;height: 800px;}#submission_page .submission-sidebar:hover{position:absolute;top:50px;bottom:0px;right:0px;z-index:1000000;background:rgba(1,0,0,0.9);transition: 0.5s all;height:800px;}</style>").appendTo("head");
  54. break;
  55. case "HiddenStreams":
  56. $("<style>div#messagecenter-other ul.message-stream li.stream-notification{display:none;}</style>").appendTo("head");
  57. break;
  58. case "ObviousStreams":
  59. $("<style>div#messagecenter-other ul.message-stream li.stream-notification{background: rgba(255,255,255,0.5);color: black;border: 0.5px dashed black;}div#messagecenter-other ul.message-stream li.stream-notification a {color: black;}</style>").appendTo("head");
  60. break;
  61. case "SameSizeThumbnails":
  62. $("<style>.userpage-gallery-item img,.userpage-favorites-item img{height: 150px;width: 150px;}</style>").appendTo("head");
  63. break;
  64. case "FixedNavigation":
  65. $("<style>nav#ddmenu{position:fixed;background:black;}div#news{margin-top:50px;margin-bottom:-50px;}div.user-nav-info{margin-top:50px;}.bg1{margin-top:50px;}</style>").appendTo("head");
  66. break;
  67. case "TidyProfile":
  68. var ProfileSize = 480; // (Defines max amount of profile that should be shown, the rest is still DOM loaded but hidden by overflow)
  69. if ($('.userpage-profile-info').height() > ProfileSize) { // Check for height
  70. $('.userpage-profile-info').css('height',''+ProfileSize+'px'); // Set new height
  71. $('.userpage-profile-info').css('overflow-y','auto'); // Allow overflow of remaining content
  72. }
  73. break;
  74. default:
  75. /* No Code */
  76. }
  77. }
  78. var pathx = window.location.pathname;
  79. if(~pathx.indexOf("/controls/user-settings/")){
  80. // Update
  81. $(document.body).on('click', '#fafcp_saveit', function() {
  82. var fafcp_set_nct = $("input[name='fafcp_nct']:checked").val();
  83. var fafcp_set_sbg = $("input[name='fafcp_sbg']:checked").val();
  84. var fafcp_set_hs = $("input[name='fafcp_hs']:checked").val();
  85. var fafcp_set_os = $("input[name='fafcp_os']:checked").val();
  86. var fafcp_set_sst = $("input[name='fafcp_sst']:checked").val();
  87. var fafcp_set_fn = $("input[name='fafcp_fn']:checked").val();
  88. var fafcp_set_tp = $("input[name='fafcp_tp']:checked").val();
  89. FAFCP_SaveSettings(fafcp_set_nct,fafcp_set_sbg,fafcp_set_hs,fafcp_set_os,fafcp_set_sst,fafcp_set_fn,fafcp_set_tp);
  90. $('.faf-update-status').fadeIn('slow');
  91. setTimeout(function() {
  92. $('.faf-update-status').fadeOut('slow');
  93. }, 5000);
  94. });
  95. if(STATIC_PATH=="/themes/beta"){
  96. $('.button-nav').after(`
  97. <div id="customfacontrolpanel" style="border:1px dashed white; background: rgba(1,0,0,0.1); padding: 5px; border-radius: 5px; margin-top: 20px;">
  98. <h2>FA Fixes Control Panel <span class="faf-update-status" style="font-weight: bold; color: #02cc02; float:right; clear:right; display: none;">Update successful!</span></h2>
  99. <br/>
  100. <strong>No Custom Thumbnails</strong>
  101. <div class="control-panel-option">
  102. <div class="control-panel-item-1">
  103. <p>Disables Furaffinity from showing custom thumbnails on all submissions. Replacing the original thumbnails with a scaled down version of the actual submission.</p>
  104. </div>
  105. <div class="control-panel-item-2">
  106. <input type="radio" id="fafcp_nct_yes" name="fafcp_nct" value="yes" /><label for="fafcp_nct_yes">Enable</label><br/>
  107. <input type="radio" id="fafcp_nct_no" name="fafcp_nct" value="no"/><label for="fafcp_nct_no">Disable</label>
  108. </div>
  109. </div>
  110. <strong>Sidebar-Be-Gone</strong>
  111. <div class="control-panel-option">
  112. <div class="control-panel-item-1">
  113. <p>Relocates the sidebar off the screen, so it can be activated by hovering over it. <br/><i>Fixes the fullscreen submission bug</i></p>
  114. </div>
  115. <div class="control-panel-item-2">
  116. <input type="radio" id="fafcp_sbg_yes" name="fafcp_sbg" value="yes"/><label for="fafcp_sbg_yes">Enable</label><br/>
  117. <input type="radio" id="fafcp_sbg_no" name="fafcp_sbg" value="no"/><label for="fafcp_sbg_no">Disable</label>
  118. </div>
  119. </div>
  120. <strong>No Streams</strong>
  121. <div class="control-panel-option">
  122. <div class="control-panel-item-1">
  123. <p>Hides all stream notifications in the notifications centre.<br/><i><b>Important:</b> Does not change the notifications counter!</i></p>
  124. </div>
  125. <div class="control-panel-item-2">
  126. <input type="radio" id="fafcp_hs_yes" name="fafcp_hs" value="yes"/><label for="fafcp_hs_yes">Enable</label><br/>
  127. <input type="radio" id="fafcp_hs_no" name="fafcp_hs" value="no"/><label for="fafcp_hs_no">Disable</label>
  128. </div>
  129. </div>
  130. <strong>Obvious Streams</strong>
  131. <div class="control-panel-option">
  132. <div class="control-panel-item-1">
  133. <p>Re-styles stream notifications to make them more obvious in the notification's centre.</p>
  134. </div>
  135. <div class="control-panel-item-2">
  136. <input type="radio" id="fafcp_os_yes" name="fafcp_os" value="yes"/><label for="fafcp_os_yes">Enable</label><br/>
  137. <input type="radio" id="fafcp_os_no" name="fafcp_os" value="no"/><label for="fafcp_os_no">Disable</label>
  138. </div>
  139. </div>
  140. <strong>Same Size Thumbnails</strong>
  141. <div class="control-panel-option">
  142. <div class="control-panel-item-1">
  143. <p>Adjusts all thumbnails on profile pages to be of the same size (150px x 150px)</p>
  144. </div>
  145. <div class="control-panel-item-2">
  146. <input type="radio" id="fafcp_sst_yes" name="fafcp_sst" value="yes"/><label for="fafcp_sst_yes">Enable</label><br/>
  147. <input type="radio" id="fafcp_sst_no" name="fafcp_sst" value="no"/><label for="fafcp_sst_no">Disable</label>
  148. </div>
  149. </div>
  150. <strong>Fixed Navigation</strong>
  151. <div class="control-panel-option">
  152. <div class="control-panel-item-1">
  153. <p>Places the navigation bar in a fixed position, so it scrolls with the page</p>
  154. </div>
  155. <div class="control-panel-item-2">
  156. <input type="radio" id="fafcp_fn_yes" name="fafcp_fn" value="yes"/><label for="fafcp_fn_yes">Enable</label><br/>
  157. <input type="radio" id="fafcp_fn_no" name="fafcp_fn" value="no"/><label for="fafcp_fn_no">Disable</label>
  158. </div>
  159. </div>
  160. <strong>Tidy Profile</strong>
  161. <div class="control-panel-option">
  162. <div class="control-panel-item-1">
  163. <p>Add's a scroll bar to the the user profile section, if it's determined to be too long, to avoid unnesscessary scrolling.</p>
  164. </div>
  165. <div class="control-panel-item-2">
  166. <input type="radio" id="fafcp_tp_yes" name="fafcp_tp" value="yes"/><label for="fafcp_tp_yes">Enable</label><br/>
  167. <input type="radio" id="fafcp_tp_no" name="fafcp_tp" value="no"/><label for="fafcp_tp_no">Disable</label>
  168. </div>
  169. </div>
  170. <div class="button-nav">
  171. <div class="button-nav-item">
  172. <input class="button mobile-button" id="fafcp_saveit" type="button" value="Save FAFCP Settings*">
  173. </div>
  174. </div>
  175. <br/><b>*Updates take effect from the next page load</b><br/><span style="font-size:10px;">FAFCP by <a href="https://www.furaffinity.net/user/feralfrenzy" style="border-bottom:1px dotted white;">JaysonHusky</a></span>
  176. </div>
  177. `);
  178. }
  179. else {
  180. $('.footer').before(`<table cellpadding="0" cellspacing="1" border="0" class="section maintable" style="width: 98%; margin: 0 auto;">
  181. <tbody><tr>
  182. <td height="22" class="cat links">&nbsp;<strong>FurAffinity Fixes - Control Panel</strong></td>
  183. </tr>
  184. <tr>
  185. <td class="alt1 addpad" align="center">
  186. <table cellpadding="0" cellspacing="1" border="0">
  187. <tbody><tr>
  188. <td>
  189. <p>FAFCP is currently not available on FurAffinity's Classic Interface
  190. <br/><span style="font-size:10px;">FAFCP by <a href="https://www.furaffinity.net/user/feralfrenzy" style="border-bottom:1px dotted white;">JaysonHusky</a></span></p>
  191. </td>
  192. </tr>
  193. </tbody></table>
  194. </td>
  195. </tr>
  196. </tbody></table>`);
  197. }
  198. }
  199. // Load the users settings
  200. $.each(["fafcp_nct","fafcp_sbg","fafcp_hs","fafcp_os","fafcp_sst","fafcp_fn","fafcp_tp"],function(i,l){
  201. FAFCP_LoadCP(l);
  202. });
  203. // Check and Run the Tweaks if required
  204. if(FAFCP_Load_Tweaks('fafcp_nct')=="yes"){ExecuteTweak('NoCustomThumbnails');} else { /* Do Nothing */ }
  205. if(FAFCP_Load_Tweaks('fafcp_sbg')=="yes"){ExecuteTweak('SidebarBeGone');} else { /* Do Nothing */ }
  206. if(FAFCP_Load_Tweaks('fafcp_hs')=="yes"){ExecuteTweak('HiddenStreams');} else { /* Do Nothing */ }
  207. if(FAFCP_Load_Tweaks('fafcp_os')=="yes"){ExecuteTweak('ObviousStreams');} else { /* Do Nothing */ }
  208. if(FAFCP_Load_Tweaks('fafcp_sst')=="yes"){ExecuteTweak('SameSizeThumbnails');} else { /* Do Nothing */ }
  209. if(FAFCP_Load_Tweaks('fafcp_fn')=="yes"){ExecuteTweak('FixedNavigation');} else { /* Do Nothing */ }
  210. if(FAFCP_Load_Tweaks('fafcp_tp')=="yes"){ExecuteTweak('TidyProfile');} else { /* Do Nothing */ }
  211. })();