Fullscreen Shortcut

Add shortcut to enable fullscreen mode of several streaming-media websites

当前为 2020-08-04 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Fullscreen Shortcut
  3. // @version 0.4
  4. // @description Add shortcut to enable fullscreen mode of several streaming-media websites
  5. // @author Fingalzzz
  6. // @namespace https://greasyfork.org/users/673298
  7. // @match https://www.bilibili.com/video/*
  8. // @match https://www.bilibili.com/bangumi/play/*
  9. // @match https://www.iqiyi.com/*
  10. // @match https://v.qq.com/x/*
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. (function () {
  15. 'use strict';
  16. const shortcut = '\\';
  17.  
  18. // var selector = null;
  19. // var btn = null;
  20. // var link = window.location.href;
  21. // if (link.includes("bilibili.com")) {
  22. // selector = ".bilibili-player-iconfont-fullscreen-on";
  23. // } else if (link.includes('iqiyi.com')) {
  24. // selector = ".iqp-btn.iqp-btn-fullscreen";
  25. // } else if (link.includes('v.qq.com')) {
  26. // selector = ".txp_btn.txp_btn_fullscreen";
  27. // }
  28.  
  29. // (new MutationObserver(check)).observe(document, { childList: true, subtree: true });
  30.  
  31. // function check(changes, observer) {
  32. // if (document.querySelector(selector)) {
  33. // observer.disconnect();
  34. // btn = document.querySelector(selector);
  35. // }
  36. // }
  37.  
  38. document.addEventListener('keydown', (e) => {
  39. //if (e.ctrlKey && e.key === shortcut) {
  40. if (e.key === shortcut) {
  41. var selector = null;
  42. var btn = null;
  43. var link = window.location.href;
  44. if (link.includes("bilibili.com")) {
  45. selector = ".bilibili-player-iconfont-fullscreen-on";
  46. } else if (link.includes('iqiyi.com')) {
  47. selector = ".iqp-btn.iqp-btn-fullscreen";
  48. } else if (link.includes('v.qq.com')) {
  49. selector = ".txp_btn.txp_btn_fullscreen";
  50. }
  51. btn = document.querySelector(selector);
  52. btn.click();
  53. }
  54. })
  55.  
  56. })();