HTML5 YouTube F key fullscreen

Make YouTube's HTML5 player go fullscreen when pressing F

  1. // ==UserScript==
  2. // @name HTML5 YouTube F key fullscreen
  3. // @namespace http://vincent.tengudev.com/
  4. // @version 2014-02-18
  5. // @description Make YouTube's HTML5 player go fullscreen when pressing F
  6. // @include http://www.youtube.com/watch?*
  7. // @include https://www.youtube.com/watch?*
  8. // @include http://www.youtube.com/results?*
  9. // @include https://www.youtube.com/results?*
  10. // @include http://www.youtube.com/feed/*
  11. // @include https://www.youtube.com/feed/*
  12. // @include http://www.youtube.com/?*
  13. // @include https://www.youtube.com/?*
  14. // @include http://www.youtube.com/
  15. // @include https://www.youtube.com/
  16. // @match http://www.youtube.com/watch?*
  17. // @match https://www.youtube.com/watch?*
  18. // @match http://www.youtube.com/results?*
  19. // @match https://www.youtube.com/results?*
  20. // @match http://www.youtube.com/feed/*
  21. // @match https://www.youtube.com/feed/*
  22. // @match http://www.youtube.com/?*
  23. // @match https://www.youtube.com/?*
  24. // @match http://www.youtube.com/
  25. // @match https://www.youtube.com/
  26. // @match http://s.ytimg.com/yts/jsbin/html5player*
  27. // @match https://s.ytimg.com/yts/jsbin/html5player*
  28. // @copyright 2013+, DaVince
  29. // ==/UserScript==
  30.  
  31.  
  32. function EnableFKey() {
  33. var elems = document.getElementsByTagName("video");
  34. if (elems.length > 0) { //video tag exists?
  35. document.getElementById("player-api").addEventListener("keypress", function(e) {
  36. if (e.which == 102 || e.which == 70) { //f or F key pressed?
  37. var elem = document.getElementById("player-api");
  38. if (elem.requestFullscreen) {
  39. elem.requestFullscreen();
  40. }
  41. else if (elem.mozRequestFullScreen) {
  42. elem.mozRequestFullScreen();
  43. }
  44. else if (elem.webkitRequestFullscreen) {
  45. elem.webkitRequestFullscreen();
  46. }
  47. }
  48. });
  49. }
  50. }
  51.  
  52.  
  53. document.addEventListener('DOMContentLoaded', function() { EnableFKey() });
  54. document.addEventListener('DOMNodeInserted', function() { EnableFKey() }); //Inefficient, but whatever

QingJ © 2025

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