Flat Darkness Hack Forums Theme

Custom theme for Hack Forums. Base theme by Sasori.

  1. // ==UserScript==
  2. // @name Flat Darkness Hack Forums Theme
  3. // @namespace https://github.com/TaylerKing
  4. // @version 0.0.5
  5. // @description Custom theme for Hack Forums. Base theme by Sasori.
  6. // @include http://www.hackforums.net/*
  7. // @include http://hackforums.net/*
  8. // @include http://nsfw.hackforums.net/*
  9. // @include http://www.nsfw.hackforums.net/*
  10. // @author iHydra/Kondax/Sasori
  11. // @resource CustomCSS https://raw.githubusercontent.com/iHydra/flatdarkness/master/stylesheet_v.0.0.5.css
  12. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js
  13. // @grant GM_addStyle
  14. // @grant GM_getResourceText
  15. // @run-at document-start
  16. // ==/UserScript==
  17. /*
  18. * Copyright (c) 2011 Pete Boere (the-echoplex.net)
  19. * Free under terms of the MIT license: http://www.opensource.org/licenses/mit-license.php
  20. */
  21. (function ( $ ) {
  22. $.fn.alterClass = function ( removals, additions ) {
  23. var self = this;
  24. if ( removals.indexOf( '*' ) === -1 ) {
  25. self.removeClass( removals );
  26. return !additions ? self : self.addClass( additions );
  27. }
  28. var patt = new RegExp( '\\s' +
  29. removals.
  30. replace( /\*/g, '[A-Za-z0-9-_]+' ).
  31. split( ' ' ).
  32. join( '\\s|\\s' ) +
  33. '\\s', 'g' );
  34. self.each( function ( i, it ) {
  35. var cn = ' ' + it.className + ' ';
  36. while ( patt.test( cn ) ) {
  37. cn = cn.replace( patt, ' ' );
  38. }
  39. it.className = $.trim( cn );
  40. });
  41. return !additions ? self : self.addClass( additions );
  42. };
  43. })( jQuery );
  44.  
  45. /*
  46. * Document Begins
  47. */
  48. var ThemeCSS = GM_getResourceText ("CustomCSS");
  49. GM_addStyle (ThemeCSS);
  50. $(window).load(function(){
  51. var cp = $("<div class='cp'/>");
  52. var select = $("<div class='select'/>");
  53. $("body").append(cp, select);
  54. var colours = {'black': '#000', 'white': '#fff', 'blue': '#0C8CE8', 'green': '#93cd2b', 'red': '#da3f3f'};
  55. $("body").addClass(localStorage.getItem('theme') ? localStorage.getItem('theme') : 'cl-' + Object.keys(colours)[0]);
  56. $.each(colours, function(key, value) {
  57. select.append($("<div class='part' style='background: " + value + " !important;' cid='" + key + "'/>"));
  58. });
  59. $(".cp").click(function(){
  60. $(".select").toggleClass("show");
  61. });
  62. $(".part").click(function(){
  63. var cl = "cl-" + $(this).attr('cid');
  64. $(".cp").css("background", colours[$(this).attr('cid')]);
  65. $("body").alterClass('cl-*', cl);
  66. localStorage.setItem('theme', cl);
  67. });
  68. });

QingJ © 2025

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