Mapillary Keybindings

Add more keyboard shortcuts to Mapillary

  1. // ==UserScript==
  2. // @name Mapillary Keybindings
  3. // @namespace http://affeali.bit
  4. // @version 1
  5. // @description Add more keyboard shortcuts to Mapillary
  6. // @author AffeAli
  7. // @match https://www.mapillary.com/*
  8. // ==/UserScript==
  9.  
  10. setTimeout(exe, 1000);
  11.  
  12. function exe() {
  13. if(window.location.href.startsWith("https://www.mapillary.com/verification/p/")) {
  14. if(document.querySelectorAll(".justify-around").length < 1) {
  15. setTimeout(exe, 500);
  16. return;
  17. }
  18. var control = document.querySelectorAll(".justify-around")[0];
  19. window.onkeypress = function(e) {
  20. if(e.keyCode == 38) { //UP = positive
  21. control.children[2].click();
  22. e.preventDefault();
  23. return false;
  24. }
  25. if(e.keyCode == 40) { //DOWN = negative
  26. control.children[1].click();
  27. e.preventDefault();
  28. return false;
  29. }
  30. if(e.keyCode == 39) { //LEFT = skip
  31. control.children[3].click();
  32. e.preventDefault();
  33. return false;
  34. }
  35. if(e.keyCode == 37) { //RIGHT = revert
  36. control.children[0].click();
  37. e.preventDefault();
  38. return false;
  39. }
  40. };
  41. }
  42. if(window.location.href.startsWith("https://www.mapillary.com/app/blur")) {
  43. if(document.querySelectorAll("div.TagSymbol").length < 1) {
  44. setTimeout(exe, 500);
  45. return;
  46. }
  47. window.onkeypress = function(e) {
  48. if(e.key == "c") {
  49. var tags = document.querySelectorAll("div.TagSymbol");
  50. for(var i = 0; i < tags.length; i++) {
  51. tags[i].click();
  52. }
  53. }
  54. if(e.key == "n") {
  55. document.querySelectorAll("div.SequenceStepNext")[0].click();
  56. }
  57. if(e.key == "p") {
  58. document.querySelectorAll("div.SequenceStepPrev")[0].click();
  59. }
  60. if(e.key == "s") {
  61. document.getElementById("submitButton").click();
  62. }
  63. };
  64. }
  65. }