Youtube Hide Watched

Hides viewed videos from your subscriptions.

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

  1. // ==UserScript==
  2. // @name Youtube Hide Watched
  3. // @namespace https://github.com/ToostInc/userscripts
  4. // @description Hides viewed videos from your subscriptions.
  5. // @include https://www.youtube.com/feed/subscriptions
  6. // @author Joost Bremmer < toost dot b at gmail dot com >
  7. // @copyright 2014, Joost Bremmer
  8. // @license MIT
  9. // @version 1.1.1
  10. // @date 04-08-2014
  11. // @require http://code.jquery.com/jquery-latest.min.js
  12. // @grant none
  13. // ==/UserScript==
  14.  
  15.  
  16. // The MIT License
  17. //
  18. // Copyright (c) 2014 Joost Bremmer
  19. //
  20. // Permission is hereby granted, free of charge, to any person obtaining a
  21. // copy of this software and associated documentation files
  22. // (the "Software"), to deal in the Software without restriction,
  23. // including without limitation the rights to use, copy, modify, merge,
  24. // publish, distribute, sublicense, and/or sell copies of the Software, and
  25. // to permit persons to whom the Software is furnished to do so, subject to
  26. // the following conditions:
  27. //
  28. // The above copyright notice and this permission notice shall be included
  29. // in all copies or substantial portions of the Software.
  30. //
  31. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  32. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  33. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  34. // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  35. // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  36. // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  37. // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  38.  
  39. $(document).ready (function () {
  40. if (MutationObserver) {
  41. var myObserver = new MutationObserver(hideWatched);
  42. }
  43. else {
  44. var myObserver = new WebKitMutationObserver(hideWatched);
  45. }
  46. myObserver.observe(document, { childList : true, subtree : true });
  47. hideWatched();
  48.  
  49. // Add checkbox
  50. var checker = '<li>\n'+
  51. '\t<label id="checker-container">\n'+
  52. '\t\t<input type="checkbox" id="hide-videos" checked="" />'+
  53. '\t\tHide watched videos'+
  54. '\t</label>\n'+
  55. '</li>';
  56. $("#appbar-nav .appbar-nav-menu").prepend(checker);
  57. $("#checker-container").css({
  58. 'color': "#666",
  59. "vertical-align" : "middle",
  60. "text-align" : "center"
  61. });
  62. $("#hide-videos").change(function() {
  63. if ( $(this).is(":not(:checked)") ) {
  64. showWatched();
  65. }
  66. else {
  67. hideWatched();
  68. };
  69. });
  70. //BONUS: always enable load more button.
  71. $("button.load-more-button").removeProp("disabled");
  72. hideWatched();
  73.  
  74.  
  75. });
  76.  
  77.  
  78. function hideWatched () {
  79. if ( $("#hide-videos").is(":checked") ) {
  80. $("div.watched-badge").each(function() {
  81. $(this).closest("li.feed-item-container").hide("200");
  82. });
  83.  
  84. }
  85. };
  86.  
  87. function showWatched() {
  88. $("div.watched-badge").each(function() {
  89. $(this).closest("li.feed-item-container").show("300");
  90. });
  91. }