Shuffle pocket list.

try to take over the world!

  1. // ==UserScript==
  2. // @name Shuffle pocket list.
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description try to take over the world!
  6. // @author You
  7. // @match https://getpocket.com/a/queue/list/
  8. // @grant none
  9. // ==/UserScript==
  10. /* jshint -W097 */
  11. 'use strict';
  12.  
  13. (function($){
  14. $.fn.shuffle = function() {
  15. var allElems = this.get(),
  16. getRandom = function(max) {
  17. return Math.floor(Math.random() * max);
  18. },
  19. shuffled = $.map(allElems, function(){
  20. var random = getRandom(allElems.length),
  21. randEl = $(allElems[random]).clone(true)[0];
  22. allElems.splice(random, 1);
  23. return randEl;
  24. });
  25. this.each(function(i){
  26. $(this).replaceWith($(shuffled[i]));
  27. });
  28. return $(shuffled);
  29. };
  30. })(jQuery);
  31.  
  32. $("body").ready(function() {
  33. var style = "background: url(/a/i/icons_core@1x.png) -475px -281px no-repeat; width: 18px; height: 18px;";
  34. $(".queue_secondarynav ul").prepend('<li class="pagenav_listview pagenav_shuffle"><a style="' + style + '" class="hint-item" data-intro="Shuffle list" data-position="bottom" title="Shuffle list (randomize)">Shuffle</a></li>');
  35. $(".pagenav_shuffle").click(function(e) {
  36. $('#queue li.item').shuffle();
  37. });
  38. });

QingJ © 2025

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