Flat Darkness - Stable

Custom theme for Hack Forums. Base theme by Sasori.

当前为 2015-10-20 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Flat Darkness - Stable
  3. // @namespace https://github.com/iHydra
  4. // @version 1.5.0
  5. // @description Custom theme for Hack Forums. Base theme by Sasori.
  6. // @include http://www.hackforums.net/*
  7. // @include http://hackforums.net/*
  8. // @author iHydra/Kondax/Sasori
  9. // @require https://code.jquery.com/jquery-2.1.4.min.js
  10. // @require https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.8.0/highlight.min.js
  11. // @resource MainCSS https://raw.githubusercontent.com/iHydra/flatdarkness/master/stylesheet_1.5.0.css
  12. // @resource HLCSS https://github.com/isagalaev/highlight.js/raw/master/src/styles/monokai_sublime.css
  13. // @grant GM_addStyle
  14. // @grant GM_getResourceText
  15. // @run-at document-start
  16. // ==/UserScript==
  17.  
  18. /* INFORMATION - READ */
  19. // You can change Highlighter Theme: https://github.com/isagalaev/highlight.js/tree/master/src/styles || Demo of Themes: https://highlightjs.org/static/demo/
  20. // You can change the preview button shortcut key if you scroll down to USER EDITING.
  21.  
  22. /*
  23. * Copyright (c) 2011 Pete Boere (the-echoplex.net)
  24. * Free under terms of the MIT license: http://www.opensource.org/licenses/mit-license.php
  25. */
  26.  
  27. (function ($) {
  28. $.fn.alterClass = function (removals, additions) {
  29. var self = this;
  30. if (removals.indexOf('*') === - 1) {
  31. self.removeClass(removals);
  32. return !additions ? self : self.addClass(additions);
  33. }
  34. var patt = new RegExp('\\s' +
  35. removals.replace(/\*/g, '[A-Za-z0-9-_]+').split(' ').join('\\s|\\s') +
  36. '\\s', 'g');
  37. self.each(function (i, it) {
  38. var cn = ' ' + it.className + ' ';
  39. while (patt.test(cn)) {
  40. cn = cn.replace(patt, ' ');
  41. }
  42. it.className = $.trim(cn);
  43. });
  44. return !additions ? self : self.addClass(additions);
  45. };
  46. }) (jQuery);
  47.  
  48. var MainCSS = GM_getResourceText('MainCSS');
  49. GM_addStyle(MainCSS);
  50. var HLCSS = GM_getResourceText('HLCSS');
  51. GM_addStyle(HLCSS);
  52.  
  53. /*
  54. * USER EDITING
  55. */
  56.  
  57. $(document).ready(function () {
  58. $('.button2[name="previewpost"]').attr('accesskey', 'w'); // CHANGE "W" TO KEY YOU PREFER - Chrome Only
  59. });
  60.  
  61. /*
  62. * END OF USER EDITING
  63. */
  64.  
  65. $(window).load(function () { // Theme Color Scheme Changer
  66. var cp = $('<div class=\'cp\'/>');
  67. var select = $('<div class=\'select\'/>');
  68. $('body').append(cp, select);
  69. var colours = {
  70. 'black': '#393939',
  71. 'blue': '#619ECB',
  72. 'green': '#7ECB61',
  73. 'orange': '#D29C2D',
  74. 'purple': '#724FAD',
  75. 'red': '#CB6161',
  76. 'darkblue': '#00528f',
  77. 'darkgreen': '#35713F',
  78. 'darkorange': '#9A782E',
  79. 'darkpurple': '#4D2D5E',
  80. 'darkred': '#641C1C'
  81. };
  82. if (!localStorage.getItem('theme'))
  83. localStorage.setItem('theme', 'cl-' + Object.keys(colours) [0]);
  84. $('body').addClass(localStorage.getItem('theme') ? localStorage.getItem('theme') : 'cl-' + Object.keys(colours) [0]);
  85. $('.cp').css('background', colours[$('body').attr('class').split(' ') [0].substring(3, $('body').attr('class').split(' ') [0].length)]);
  86. $.each(colours, function (key, value) {
  87. select.append($('<div class=\'part\' style=\'background: ' + value + ' !important;\' cid=\'' + key + '\'/>'));
  88. });
  89. $('.cp').click(function () {
  90. $('.select').toggleClass('show');
  91. });
  92. $('.part').click(function () {
  93. var cl = 'cl-' + $(this).attr('cid');
  94. $('.cp').css('background', colours[$(this).attr('cid')]);
  95. $('body').alterClass('cl-*', cl);
  96. localStorage.setItem('theme', cl);
  97. });
  98. });
  99.  
  100. /** Custom Functions **/
  101.  
  102. $(document).ready(function() { // Highlight Syntax
  103. $('code').each(function(i, block) {
  104. hljs.highlightBlock(block);
  105. });
  106. });
  107.  
  108. copyLink = function (element) { // Working on adding a copy url for Post # links
  109. var $temp = $("<input />");
  110. $("body").append($temp);
  111. $temp.val($(element).attr('href')).select();
  112. var result = false;
  113. try {
  114. result = document.execCommand("copy");
  115. console.log("Copy Success? " + result);
  116. } catch (err) {
  117. console.log("Copy error: " + err);
  118. }
  119.  
  120. $temp.remove();
  121. return result;
  122. }
  123.  
  124.  
  125. /*
  126. * CSS Modification (jQuery/jS for multi-browser support)
  127. */
  128.  
  129. $(document).ready(function () {
  130. $('img[src$="hackforums.net/images/modern_bl/starstaff.png"]').attr('style', 'filter: hue-rotate(5deg) saturate(8); -webkit-filter: hue-rotate(5deg) saturate(8)'); // Staff Stars Color Change
  131. $('img[src$="hackforums.net/images/modern_bl/dismiss_notice.gif"]').attr('src', 'http://i.imgur.com/uxvQQDI.png'); // PM Notif Dismiss Icon
  132. $('img[src$="hackforums.net/images/modern_bl/add_buddy.gif"]').attr('src', 'http://i.imgur.com/3d5FKNX.png'); // Add Buddy Icon
  133. $('img[src$="hackforums.net/images/modern_bl/remove_buddy.gif"]').attr('src', 'http://i.imgur.com/zDwBkq5.png'); // Remove Buddy Icon
  134. $('img[src$="hackforums.net/images/modern_bl/add_ignore.gif"]').attr('src', 'http://i.imgur.com/u3NZbDu.png'); // Add Ignore Icon
  135. $('img[src$="hackforums.net/images/modern_bl/remove_ignore.gif"]').attr('src', 'http://i.imgur.com/zDwBkq5.png'); // Remove Ignore Icon
  136. $('img[src$="/img/disable.png"]').attr('src', 'http://i.imgur.com/LXGekE9.png'); // Disable icon for multi-page loader userscript(not included)
  137. $('img[src$="/img/enable.png"]').attr('src', 'http://i.imgur.com/YHDATSF.png'); // Enable icon for multi-page loader userscript(not included)
  138. $('img[src$="hackforums.net/images/modern_bl/minioff.gif"]').attr('src', 'http://i.imgur.com/AP6vLRo.png').attr('style', 'padding-bottom: 2px;'); // No Posts SF Icon
  139. $('img[src$="hackforums.net/images/modern_bl/miniofflock.gif"]').attr('src', 'http://i.imgur.com/AP6vLRo.png').attr('style', 'padding-bottom: 2px;'); // No Posts SF Icon Locked
  140. $('img[src$="hackforums.net/images/modern_bl/minion.gif"]').attr('src', 'http://i.imgur.com/Wsl1Gfc.png').attr('style', 'padding-bottom: 3px;'); // New Posts SF icon
  141. $('img[src$="http://hackforums.net/images/modern_bl/spinner_big.gif"]').attr('src', 'http://i.imgur.com/y3wDcUA.gif'); // Quick Reply Spinner Change
  142. $('span:contains("Moderated")').addClass('sevenpad'); // Padding fix
  143. $('link[href*="star_ratings"]').remove(); // Star Ratings Change
  144. $('#pm_notice').removeClass('pm_alert').addClass('pm_alert2'); // Group vs. PM Alert
  145. $('.button').removeClass('button').addClass('button2'); // Button fix
  146. $('div[id="quickreply_multiquote"]').remove(); // Remove Multiquote - Disabled by Omni and it's showing because of some CSS changes
  147. if(window.location.href == "http://hackforums.net/misc.php?action=buddypopup"){ // Buddy List Online Status Fix
  148. $('img[src$="hackforums.net/images/modern_bl/buddy_away.gif"]').attr('src', 'http://i.imgur.com/x7dAaGE.png').attr('style', ''); // Away Status
  149. $('img[src$="hackforums.net/images/modern_bl/buddy_online.gif"]').attr('src', 'http://i.imgur.com/lpKaTIB.png').attr('style', ''); // Online Status
  150. $('img[src$="hackforums.net/images/modern_bl/buddy_offline.gif"]').attr('src', 'http://i.imgur.com/EKt4fXk.png').attr('style', ''); // Offline Status
  151. }else if(window.location.href == "http://hackforums.net/usercp.php?action=editlists"){
  152. $('img[src$="hackforums.net/images/modern_bl/buddy_away.gif"]').attr('src', 'http://i.imgur.com/x7dAaGE.png').attr('style', ''); // Away Status
  153. $('img[src$="hackforums.net/images/modern_bl/buddy_online.gif"]').attr('src', 'http://i.imgur.com/lpKaTIB.png').attr('style', ''); // Online Status
  154. $('img[src$="hackforums.net/images/modern_bl/buddy_offline.gif"]').attr('src', 'http://i.imgur.com/EKt4fXk.png').attr('style', ''); // Offline Status
  155. }else{
  156. $('img[src$="hackforums.net/images/modern_bl/buddy_away.gif"]').attr('src', 'http://i.imgur.com/x7dAaGE.png').attr('style', 'position: absolute; padding-top: 4px;'); // Away Status
  157. $('img[src$="hackforums.net/images/modern_bl/buddy_online.gif"]').attr('src', 'http://i.imgur.com/lpKaTIB.png').attr('style', 'position: absolute; padding-top: 4px;'); // Online Status
  158. $('img[src$="hackforums.net/images/modern_bl/buddy_offline.gif"]').attr('src', 'http://i.imgur.com/EKt4fXk.png').attr('style', 'position: absolute; padding-top: 4px;'); // Offline Status
  159. }
  160.  
  161. if(window.location.href == "http://hackforums.net/gauth.php"){
  162. $('span[class="float_right smalltext"]').attr('style','display: block !important'); // Gauth Reset Link Reveal
  163. }
  164. if(window.location.pathname == "/reputation.php"){
  165. $('a[href$="&show=positive"]').attr('style','font-size: 14px; background-color: #2DA546; border: 1px solid #2CC330; padding: 5px 10px 5px 10px; font-weight: bold; color: white;').after("<br/>"); // Positive Rep Box
  166. $('a[href$="&show=neutral"]').attr('style','font-size: 14px; background-color: #777777; border: 1px solid #949494; padding: 5px 10px 5px 10px; font-weight: bold; color: white;').after("<br/>"); // Neutral Rep Box
  167. $('a[href$="&show=negative"]').attr('style','font-size: 14px; background-color: #CC4444; border: 1px solid #FF5656; padding: 5px 10px 5px 10px; font-weight: bold; color: white;'); // Negative Rep Box
  168. $('strong[class="reputation_positive"]:contains("Positives")').remove(); // Legend Text Remove
  169. $('strong[class="reputation_neutral"]:contains("Neutrals")').remove(); // Legend Text Remove
  170. $('strong[class="reputation_negative"]:contains("Negatives")').remove(); // Legend Text Remove
  171. $('span[class="smalltext"]:contains("Total Reputation:")').find("br").remove(); // Received Rep Boxes Layout
  172. $('strong:contains("Total Reputation:")').before("<br/><br/>"); // Received Rep Boxes Layout
  173. $('span[class="repbox _plus"]').after("<br/><br/>"); // Received Rep Boxes Layout
  174. }
  175.  
  176. $('img[src$="hackforums.net/images/modern_bl/groupimages/english/ub3r.png"]').attr('style', '-webkit-filter: hue-rotate(15deg); filter: hue-rotate(15deg);'); // Uber Userbar Color Change
  177. $('img[src$="hackforums.net/images/modern_bl/starub3r2.png"]').attr('style', '-webkit-filter: hue-rotate(15deg); filter: hue-rotate(15deg);'); // Uber Stars Color Change
  178. $('strong span[style="rgb(56, 56, 56)"]').addClass("closedGroup"); // Changes Closed Usergroup Color
  179. $('strong:contains("Post:") > a[href^="showthread.php?tid="]').attr('id','postLink').attr('style','padding-top: 3px; padding-right: 5px; display: inline-block;'); // Post # Centered
  180. });