Toggleable video and audio html5 elements

Little script to enable video and audio html5 elements play/pause toggle clicking on element itself.

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

  1. // ==UserScript==
  2. // @name Toggleable video and audio html5 elements
  3. // @namespace Violentmonkey Scripts
  4. // @grant none
  5. // @include *
  6. // @author Creec Winceptor
  7. // @description Little script to enable video and audio html5 elements play/pause toggle clicking on element itself.
  8. // @namespace https://greasyfork.org/users/3167
  9. // @run-at document-load
  10. // @version 1
  11. // ==/UserScript==
  12.  
  13. var playpause = function(obj)
  14. {
  15. obj.paused?obj.play():obj.pause();
  16. }
  17. var enableclicktoggle = function(elem)
  18. {
  19. elem.addEventListener("click", function(){playpause(this)});
  20. }
  21.  
  22. var elements = document.getElementsByTagName("VIDEO").concat(document.getElementsByTagName("AUDIO"));
  23. for (var e in elements)
  24. {
  25. var elem = elements[e];
  26. enableclicktoggle(elem);
  27. }