Flat Darkness Hack Forums Theme

Custom theme for Hack Forums. Base theme by Sasori.

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

  1. // ==UserScript==
  2. // @name Flat Darkness Hack Forums Theme
  3. // @namespace https://github.com/iHydra
  4. // @version 0.1.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. // @resource MainCSS https://github.com/iHydra/flatdarkness/raw/master/stylesheet_v.0.1.0.css
  10. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js
  11. // @grant GM_addStyle
  12. // @grant GM_getResourceText
  13. // @run-at document-start
  14. // ==/UserScript==
  15. /*
  16. * Copyright (c) 2011 Pete Boere (the-echoplex.net)
  17. * Free under terms of the MIT license: http://www.opensource.org/licenses/mit-license.php
  18. */
  19. (function ( $ ) {
  20. $.fn.alterClass = function ( removals, additions ) {
  21. var self = this;
  22. if ( removals.indexOf( '*' ) === -1 ) {
  23. self.removeClass( removals );
  24. return !additions ? self : self.addClass( additions );
  25. }
  26. var patt = new RegExp( '\\s' +
  27. removals.
  28. replace( /\*/g, '[A-Za-z0-9-_]+' ).
  29. split( ' ' ).
  30. join( '\\s|\\s' ) +
  31. '\\s', 'g' );
  32. self.each( function ( i, it ) {
  33. var cn = ' ' + it.className + ' ';
  34. while ( patt.test( cn ) ) {
  35. cn = cn.replace( patt, ' ' );
  36. }
  37. it.className = $.trim( cn );
  38. });
  39. return !additions ? self : self.addClass( additions );
  40. };
  41. })( jQuery );
  42.  
  43. /*
  44. * Document Begins
  45. */
  46.  
  47.  
  48. var MainCSS = GM_getResourceText ("MainCSS");
  49. GM_addStyle (MainCSS);
  50.  
  51. $(window).load(function(){
  52. var cp = $("<div class='cp'/>");
  53. var select = $("<div class='select'/>");
  54. $("body").append(cp, select);
  55. var colours = {'black':'#393939', 'blue':'#619ECB', 'green':'#7ECB61', 'orange':'#D29C2D', 'purple':'#724FAD', 'red':'#CB6161'};
  56. if(!localStorage.getItem('theme'))
  57. localStorage.setItem('theme', 'cl-' + Object.keys(colours)[0]);
  58. $("body").addClass(localStorage.getItem('theme') ? localStorage.getItem('theme') : 'cl-' + Object.keys(colours)[0]);
  59. $(".cp").css("background", colours[$("body").attr('class').split(" ")[0].substring(3, $("body").attr('class').split(" ")[0].length)]);
  60. $.each(colours, function(key, value) {
  61. select.append($("<div class='part' style='background: " + value + " !important;' cid='" + key + "'/>"));
  62. });
  63. $(".cp").click(function(){
  64. $(".select").toggleClass("show");
  65. });
  66. $(".part").click(function(){
  67. var cl = "cl-" + $(this).attr('cid');
  68. $(".cp").css("background", colours[$(this).attr('cid')]);
  69. $("body").alterClass('cl-*', cl);
  70. localStorage.setItem('theme', cl);
  71. });
  72. });
  73.  
  74. /*
  75. *Javascript Editing
  76. */
  77.  
  78. $(document).ready(function(){
  79. $('span:contains("Moderated")').addClass("sevenpad");
  80. });
  81.  
  82. $(document).ready(function(){
  83. $('link[href*="star_ratings"]').remove();
  84. });
  85.  
  86. $(document).ready(function(){
  87. $('#pm_notice').removeClass("pm_alert").addClass("pm_alert2");
  88. });
  89.  
  90. $(document).ready(function(){
  91. $('.button').removeClass("button").addClass("button2");
  92. });
  93.  
  94. $(document).ready(function(){
  95. $('.button2[name="previewpost"]').attr('accesskey','w'); // CHANGE "W" TO KEY YOU PREFER
  96. });