highlight_gaf

Highlights your posts on the NeoGAF

  1. /*
  2.  
  3. Copyright (C) 2013 James Rodrigues
  4.  
  5. Permission is hereby granted, free of charge, to any person obtaining a copy of
  6. this software and associated documentation files (the "Software"), to deal in
  7. the Software without restriction, including without limitation the rights to
  8. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  9. of the Software, and to permit persons to whom the Software is furnished to do
  10. so, subject to the following conditions:
  11.  
  12. The above copyright notice and this permission notice shall be included in all
  13. copies or substantial portions of the Software.
  14.  
  15. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  21. SOFTWARE.
  22.  
  23. */
  24.  
  25. // ==UserScript==
  26. // @name highlight_gaf
  27. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
  28. // @require http://cdnjs.cloudflare.com/ajax/libs/lodash.js/1.0.0/lodash.min.js
  29. // @namespace com.zombie.highlight
  30. // @description Highlights your posts on the NeoGAF
  31. // @include http://www.neogaf.com/forum/*
  32. // @include http://www.neogaf.net/forum/*
  33. // @include http://neogaf.com/forum/*
  34. // @include http://neogaf.net/forum/*
  35. // @version 0.0.1.20140823203554
  36. // ==/UserScript==
  37.  
  38. // Your colors
  39. // Use can use http://www.colorpicker.com/ to get colors in the hex format
  40. // below.
  41. var my_color = '#629bc4';
  42. var friend_color = '#86bf60';
  43. var mod_color = '#c49d9d';
  44.  
  45. // User list in the format:
  46. // "username": color
  47. var highlight_list = {
  48. "YOUR_USER_NAME": my_color,
  49. "FRIEND1": friend_color,
  50. "FRIEND2": friend_color,
  51. "bishoptl": mod_color,
  52. "Stumpokapow": mod_color,
  53. "Aeana": mod_color,
  54. "Blackace": mod_color,
  55. "charlequin": mod_color,
  56. "Cyan": mod_color,
  57. "Dresden": mod_color,
  58. "duckroll": mod_color,
  59. "EatChildren": mod_color,
  60. "GhaleonEB": mod_color,
  61. "Gotchaye": mod_color,
  62. "Hyoushi": mod_color,
  63. "iapetus": mod_color,
  64. "john tv": mod_color,
  65. "Kabouter": mod_color,
  66. "Kagari": mod_color,
  67. "m0dus": mod_color,
  68. "Minsc": mod_color,
  69. "Mumei": mod_color,
  70. "Nirolak": mod_color,
  71. "Opiate": mod_color,
  72. "Seda": mod_color,
  73. "Shouta": mod_color,
  74. "Steve Youngblood": mod_color,
  75. "Teknopathetic": mod_color,
  76. "ThoseDeafMutes": mod_color,
  77. "White Man": mod_color,
  78. "Y2Kev": mod_color,
  79. "Zeliard": mod_color,
  80. "EviLore": mod_color,
  81. "Gromph": mod_color,
  82. "besada": mod_color,
  83. "EmCeeGramr": mod_color,
  84. "icarus-daedelus": mod_color,
  85. "Wes": mod_color,
  86. "Cornballer": mod_color,
  87. "StoOgE": mod_color,
  88. "Timan": mod_color
  89. };
  90.  
  91. // Users you don't care to see.
  92. var block_list = [
  93. "BAD_POSTER1",
  94. "BAD_POSTER2"
  95. ];
  96.  
  97. // Areas to highlight
  98. var highlight_settings = {
  99. avatar: true,
  100. posts: true,
  101. threads: true,
  102. quotes: true,
  103.  
  104. // Enable for NeoGAF Pro Dark compatibility tweaks.
  105. // http://userstyles.org/styles/56218/neogaf-pro-dark
  106. dark_compat: false
  107. };
  108.  
  109.  
  110. //////////////////////////////////////////////////////////////////////////
  111. //////////////////////////////////////////////////////////////////////////
  112. // Don't edit anything below this line, unless you know what you're doing.
  113. function _setClasses(users) {
  114. var script = "<style type='text/css'>";
  115. var colors = _.uniq(_.values(users));
  116. var list = {};
  117.  
  118. _.each(colors, function(v, k) {
  119. var ukey = _.uniqueId("z_");
  120. script += "." + ukey + " { background-color: " + v + "; } ";
  121. list[v] = ukey;
  122. });
  123.  
  124. script += "</style>";
  125. $('head').append(script);
  126.  
  127. return list;
  128. }
  129.  
  130. function manageThreads(users, hl_areas, colors) {
  131. if(hl_areas.threads) {
  132. // var threads = $('form').find('.alt2 > a');
  133. var threads = $('form').find('td > a');
  134.  
  135. _.each(threads, function(v, k) {
  136. var _class = colors[users[v.text]];
  137.  
  138. if(_class) {
  139. $(v).closest('tr').children().removeClass().addClass(_class);
  140. }
  141. });
  142. }
  143. }
  144.  
  145. function managePosts(user_list, block_list, hl_areas, colors) {
  146. if(hl_areas.avatar || hl_areas.posts || !_.isEmpty(block_list)) {
  147. // var _big_name = $('#posts').find('.bigusername');
  148. var _big_name = $('.postbit-details-username').find('a');
  149.  
  150. _.each(_big_name, function(v, key) {
  151. var _valid_color = colors[user_list[v.text]];
  152. var _valid_block = _.contains(block_list, v.text);
  153. // var _name = $(v).closest('td');
  154. var _name = $(v);
  155.  
  156. // Block users
  157. if(_valid_block) {
  158. // _name.closest('table').hide();
  159. _name.closest('.postbit').hide();
  160. }
  161.  
  162. if(_valid_color) {
  163. if(hl_areas.posts) {
  164. // _name.siblings().removeClass().addClass(_valid_color);
  165. _name.closest('.postbit').removeClass('mypost').addClass(_valid_color);
  166. }
  167.  
  168. if(!hl_areas.avatar) {
  169. // _name.removeClass().addClass(_valid_color);
  170. _name.closest('.postbit-details').addClass('mypost');
  171. }
  172. else {
  173. _name.closest('.postbit-details').addClass(_valid_color);
  174. }
  175. }
  176. });
  177. }
  178. }
  179.  
  180. function manageQuotes(user_list, hl_areas, colors) {
  181. if(hl_areas.quotes) {
  182. // var _quotes = $('.post').find('.smallfont').find('strong');
  183. var _quotes = $('blockquote').find('.cite').find('strong');
  184.  
  185. _.each(_quotes, function(v, k) {
  186. // var _valid_color = colors[user_list[v.innerHTML]];
  187.  
  188. // if(_valid_color) {
  189. // var t = $(v).parent().next().find('td').removeClass().addClass(_valid_color);
  190. var t = $(v).parent().parent();
  191. t.attr('data-username', '');
  192. t.css('background-color', user_list[v.innerHTML]);
  193.  
  194. if(hl_areas.dark_compat) {
  195. t.css({
  196. "border-radius": "6px 6px 6px 6px",
  197. "box-shadow": "0 2px 2px #000000"
  198. });
  199. }
  200. // }
  201. });
  202. }
  203. }
  204.  
  205. var color_map = _setClasses(highlight_list);
  206.  
  207. //$(function() {
  208. if(_.contains(location.href, "forumdisplay") || _.contains(location.href, "subscription")) {
  209. manageThreads(highlight_list, highlight_settings, color_map);
  210. return;
  211. }
  212.  
  213. managePosts(highlight_list, block_list, highlight_settings, color_map);
  214. manageQuotes(highlight_list, highlight_settings, color_map);
  215. // });