script.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. var $ = require('jQuery');
  2. const remote = require('electron').remote
  3. const shell = require('electron').shell
  4. /* Open web links in the user's default browser. */
  5. $(document).on('click', 'a[href^="http"]', function(event) {
  6. event.preventDefault();
  7. shell.openExternal(this.href);
  8. });
  9. /*Opens DevTools window if you type "wcdev" in sequence.
  10. This will crash the program if you are using multiple
  11. DevTools, for example the chrome debugger in VS Code. */
  12. const match = [87, 67, 68, 69, 86]
  13. let at = 0;
  14. document.addEventListener('keydown', function (e) {
  15. switch(e.keyCode){
  16. case match[0]:
  17. if(at === 0) ++at
  18. break
  19. case match[1]:
  20. if(at === 1) ++at
  21. break
  22. case match[2]:
  23. if(at === 2) ++at
  24. break
  25. case match[3]:
  26. if(at === 3) ++at
  27. case match[4]:
  28. if(at === 4) ++at
  29. break
  30. default:
  31. at = 0
  32. }
  33. if(at === 5) {
  34. var window = remote.getCurrentWindow()
  35. window.toggleDevTools()
  36. at = 0
  37. }
  38. })