Pop Up Hotkeys

relays key presses from pop up to hit

  1. // ==UserScript==
  2. // @name Pop Up Hotkeys
  3. // @description relays key presses from pop up to hit
  4. // @author DCI
  5. // @namespace https://www.redpandanetwork.org
  6. // @version 1.1
  7. // @include *
  8. // @icon https://i.imgur.com/gTzrm0n.jpg
  9. // @grant GM_setValue
  10. // @run-at document-start
  11. // ==/UserScript==
  12.  
  13. if (window.opener){
  14. window.opener.postMessage({popUp: "here"},"*");
  15. }
  16. window.onload = function(){
  17. if (window.name.match("popUp")){
  18. document.addEventListener("keydown", function(e){
  19. if (window.getSelection) {
  20. let text = window.getSelection().toString();
  21. window.opener.postMessage({text: text, key: e.keyCode, url: location.href},"*");
  22.  
  23. }
  24. else {
  25. window.opener.postMessage({key: e.keyCode, url: location.href},"*");
  26. }
  27. });
  28. }
  29. }