Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Revert to PS' old nick colour hashing algorithm
  3. // @version 0.0.1
  4. // @namespace http://play.pokemonshowdown.com/
  5. // https://play.pokemonshowdown.com/
  6. // http://*.psim.us/
  7. // https://*.psim.us/
  8. // @description tl;dr the nick colours are slightly different now and I don't like thing
  9. // @includes *
  10. // ==/UserScript==
  11.  
  12. window.hashColor = function hashColor(name) {
  13. if (colorCache[name]) return colorCache[name];
  14. var hash;
  15. if (window.Config && Config.customcolors && Config.customcolors[name]) {
  16. if (Config.customcolors[name].color) {
  17. return (colorCache[name] = 'color:' + Config.customcolors[name].color + ';');
  18. }
  19. hash = MD5(Config.customcolors[name]);
  20. } else {
  21. hash = MD5(name);
  22. }
  23. var H = parseInt(hash.substr(4, 4), 16) % 360;
  24. var S = parseInt(hash.substr(0, 4), 16) % 50 + 50;
  25. var L = Math.floor(parseInt(hash.substr(8, 4), 16) % 20 / 2 + 30);
  26. colorCache[name] = "color:hsl(" + H + "," + S + "%," + L + "%);";
  27. return colorCache[name];
  28. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement