Sharepoint Keyboard Shortcuts

More sensible keyboard shortcuts for SharePoint Stream video player

  1. // ==UserScript==
  2. // @name Sharepoint Keyboard Shortcuts
  3. // @namespace Violentmonkey Scripts
  4. // @match *://*.sharepoint.com/*/stream.aspx*
  5. // @grant none
  6. // @version 1.0
  7. // @author CyrilSLi
  8. // @description More sensible keyboard shortcuts for SharePoint Stream video player
  9. // @license MIT
  10. // ==/UserScript==
  11. function keydown(ev){
  12. const player = document.getElementsByClassName("oneplayer-root")[0];
  13. if (player.contains(ev.target) && ev.target !== player){
  14. ev.stopImmediatePropagation();
  15. const keys = {
  16. "ArrowLeft": document.querySelector('[aria-description*="Alt + J"]'),
  17. " ": document.querySelector('[aria-description*="Alt + K"]'),
  18. "ArrowRight": document.querySelector('[aria-description*="Alt + L"]'),
  19.  
  20. "j": document.querySelector('[aria-description*="Alt + J"]'),
  21. "k": document.querySelector('[aria-description*="Alt + K"]'),
  22. "l": document.querySelector('[aria-description*="Alt + L"]'),
  23.  
  24. "f": document.querySelector('[aria-description*="Alt + Enter"]'),
  25. "m": document.querySelector('[aria-description*="Alt + M"]'),
  26. "c": document.querySelector('[aria-description*="Alt + C"]'),
  27. }
  28. for (const key in keys){
  29. if (ev.key === key){
  30. keys[key].click();
  31. }
  32. }
  33. }
  34. }
  35. window.addEventListener("keydown", keydown, true);