Sort/Remove YouTube Watch Later List

Adds sort and remove button for the Youtube Watch Later page

当前为 2016-05-05 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @id SortRemoveYouTubeWatchLaterlist
  3. // @namespace https://gf.qytechs.cn/users/42190
  4. // @name Sort/Remove YouTube Watch Later List
  5. // @Author Jus7ForFun
  6. // @version 0.2.1
  7. // @description Adds sort and remove button for the Youtube Watch Later page
  8. // @match https://www.youtube.com/*
  9. // @match http://www.youtube.com/*
  10. // @license GNU GPL v3
  11. // @require https://code.jquery.com/jquery-latest.min.js
  12. // @require https://gf.qytechs.cn/scripts/1003-wait-for-key-elements/code/Wait%20for%20key%20elements.js?version=49342
  13. // ==/UserScript==
  14.  
  15.  
  16. waitForKeyElements ("#pl-video-table", SortButton);
  17.  
  18. waitForKeyElements(".playlist-actions", RemoveButton);
  19.  
  20.  
  21. function qselector(query, context) {
  22. return (context || document).querySelector(query);
  23. }
  24.  
  25. function MakeButton(text, action) {
  26. var btn = document.createElement('button');
  27. btn.className = 'yt-uix-button yt-uix-button-size-default yt-uix-button-default';
  28. btn.innerHTML = '<span class="yt-uix-button-content">' + text + '</span>';
  29. btn.addEventListener('click', action, false);
  30. qselector('.playlist-actions').appendChild(btn);
  31. }
  32.  
  33.  
  34. function RemoveButton () {
  35. MakeButton ('Clear The List', function(evt) {
  36. Removelist ();
  37. });
  38. }
  39.  
  40.  
  41. function SortButton () {
  42. MakeButton ('Sort Alphabetically', function(evt) {
  43. SortList ();
  44. });
  45. }
  46.  
  47.  
  48. function Removelist(){
  49. var el = document.getElementsByClassName('pl-video-edit-remove');
  50. if (el.length > 0) {
  51. el[el.length-1].click();
  52. setTimeout(Removelist,200);
  53. }
  54. }
  55.  
  56. function SortList () {
  57. $('html, body').css('display', 'none');
  58. var WatchLaterListRows = [],
  59. SortedList = '';
  60. $('#pl-video-table > tbody > tr').each(function() {
  61. var video = $(this);
  62. WatchLaterListRows.push(video[0]);
  63. video.remove();
  64. });
  65. var Sorted = $.makeArray(WatchLaterListRows).sort(function(a,b){
  66. return ( $(a).attr('data-title') < $(b).attr('data-title') ) ? -1 : 1;
  67. });
  68. $.each(Sorted, function(index, video) {
  69. SortedList += video.outerHTML;
  70. });
  71. $('#pl-load-more-destination').append(SortedList);
  72. $('html, body').css('display', 'block');
  73. }

QingJ © 2025

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