Greasy Fork 还支持 简体中文。

YouTube - Add "Stop Video" Button

Adds a 'Stop Video' button below the video

  1. // ==UserScript==
  2. // @name YouTube - Add "Stop Video" Button
  3. // @namespace https://greasyfork.org/en/users/321-joesimmons
  4. // @description Adds a 'Stop Video' button below the video
  5. // @include http://*.youtube.com/watch*v=*
  6. // @include https://*.youtube.com/watch*v=*
  7. // @include http://youtube.com/watch*v=*
  8. // @include https://youtube.com/watch*v=*
  9. // @include http://youtube.com/user/*
  10. // @include https://youtube.com/user/*
  11. // @include http://youtube.com/channel/*
  12. // @include https://youtube.com/channel/*
  13. // @include http://*.youtube.com/user/*
  14. // @include https://*.youtube.com/user/*
  15. // @include http://*.youtube.com/channel/*
  16. // @include https://*.youtube.com/channel/*
  17. // @copyright JoeSimmons
  18. // @version 1.1.0
  19. // @license GPL version 3 or any later version; http://www.gnu.org/copyleft/gpl.html
  20. // @require https://greasyfork.org/scripts/2104-youtube-button-container-require/code/YouTube%20-%20Button%20Container%20(@require).js?version=5493
  21. // @grant GM_addStyle
  22. // ==/UserScript==
  23.  
  24. /* CHANGELOG
  25.  
  26. 1.1.0 (12/13/2013)
  27. - changed license to GPLv3
  28.  
  29. 1.0.9 (12/13/2013)
  30. - started using my new @require for adding buttons to the page
  31.  
  32. 1.0.8 (12/11/2013)
  33. - started adding the stop button to a div under the movie player
  34. so other scripts can use that space to add buttons to also
  35.  
  36. 1.0.7 (11/23/2013)
  37. - fixed something I missed in 1.0.6
  38.  
  39. 1.0.6 (11/23/2013)
  40. - adapted to site change
  41.  
  42. 1.0.5 (9/6/2013)
  43. - made it work on user/channel pages
  44.  
  45. 1.0.4 (9/1/2013)
  46. - made it support the YouTube 'red bar' feature
  47.  
  48. 1.0.3 (8/31/2013)
  49. - included https pages
  50.  
  51. 1.0.2 (8/30/2013)
  52. - now supports native Chrome & Opera
  53.  
  54. 1.0.1
  55. - made it more cross-browser compatible
  56.  
  57. 1.0.0
  58. - created
  59.  
  60. */
  61.  
  62. (function () {
  63. 'use strict';
  64.  
  65. var verif = /youtube\.com\/((watch\?[a-zA-Z]+=)|(user|channel))/,
  66. button_id = 'movie_stop_button';
  67.  
  68. function run(t) {
  69. var s = document.createElement('script');
  70. s.innerHTML = t;
  71. document.body.appendChild(s);
  72. document.body.removeChild(s);
  73. }
  74.  
  75. function stopVideo() {
  76. run('' +
  77. '(function () {' +
  78. 'var player = document.querySelector("#c4-player, #movie_player");' +
  79. 'if (player.stopVideo) {' +
  80. 'player.stopVideo();' +
  81. '} else if (player.pauseVideo) {' +
  82. 'player.pauseVideo();' +
  83. '} else if (player.pause) {' +
  84. 'player.pause();' +
  85. '}' +
  86. '}());' +
  87. '');
  88. }
  89.  
  90. function addButton() {
  91. var button = document.getElementById(button_id);
  92.  
  93. if (button == null) {
  94. addButtonToContainer('Stop Video', stopVideo, button_id);
  95. }
  96. }
  97.  
  98. // make sure the page is not in a frame
  99. if (window !== window.top) { return; }
  100.  
  101. window.setInterval(addButton, 1000);
  102.  
  103. }());