UL Shuffler

Shuffles li's in UL's

  1. // ==UserScript==
  2. // @name UL Shuffler
  3. // @description Shuffles li's in UL's
  4. // @author ShareDVI
  5. // @license MIT
  6. // @version 1.0
  7. // @include http://*
  8. // @include https://*
  9. // @namespace https://greasyfork.org/users/13692
  10. // ==/UserScript==
  11. (function (window, undefined) {
  12. var w;
  13. if (typeof unsafeWindow != undefined) {
  14. w = unsafeWindow
  15. } else {
  16. w = window;
  17. }
  18. if (w.self != w.top) {
  19. return;
  20. }
  21.  
  22. var ul = document.querySelectorAll('ul');
  23. for (var j = 0; j<ul.length; j++) {
  24. for (var i = ul[j].children.length; i >= 0; i--) {
  25. ul[j].appendChild(ul[j].children[Math.random() * i | 0]);
  26. }
  27. }
  28. })(window);