Categorization Map

enter something useful

目前为 2015-08-18 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Categorization Map
  3. // @version 0.12
  4. // @description enter something useful
  5. // @match https://s3.amazonaws.com/mturk_bulk/hits*
  6. // @require http://code.jquery.com/jquery-latest.min.js
  7. // @copyright 2014+, Tjololo
  8. // @namespace https://greasyfork.org/users/710
  9. // ==/UserScript==
  10.  
  11. var api = "";
  12.  
  13. API_js_callback = "https://maps.google.com/maps/api/js?sensor=false&callback=initialize";
  14. if (api != "")
  15. API_js_callback += "&key="+api;
  16.  
  17. var script = document.createElement('script');
  18. script.src = API_js_callback;
  19. var head = document.getElementsByTagName("head")[0];
  20. (head || document.body).appendChild(script);
  21.  
  22. var elem = $("p.ng-scope:last").text();
  23. var addy = elem.split(':')[1];
  24. console.log(addy);
  25. var api = "AIzaSyCZlzXfRd-QhtiVg-FSDue_N4RXNrvSF5E";
  26. var zoomlevel = 20;
  27.  
  28. var DIVmapa = document.createElement('div');
  29. DIVmapa.id = 'DIVmapa';
  30. DIVmapa.style.border = '2px coral solid';
  31. DIVmapa.style.cursor = 'pointer';
  32. DIVmapa.style.display = '';
  33. DIVmapa.style.height = '75%';
  34. DIVmapa.style.margin = '1';
  35. DIVmapa.style.position = 'fixed';
  36. DIVmapa.style.padding = '1';
  37. DIVmapa.style.left = '1%';
  38. DIVmapa.style.bottom = '1%';
  39. DIVmapa.style.width = '30%';
  40. DIVmapa.style.zIndex = '99';
  41.  
  42. var DIVinterna = document.createElement('div');
  43. DIVinterna.id = 'DIVinterna';
  44. DIVinterna.style.height = '100%';
  45. DIVinterna.style.width = '100%';
  46. DIVinterna.style.zIndex = '999';
  47.  
  48. $("div.row").append(DIVmapa);
  49. DIVmapa.appendChild(DIVinterna);
  50.  
  51. $("[id='Completely Shaded']").text("A - Completely Shaded");
  52. $("[id='Mostly Shaded']").text("B - Mostly Shaded");
  53. $("[id='Mostly Not Shaded']").text("C - Mostly not Shaded");
  54. $("[id='Completely NOT Shaded']").text("D - Completely NOT Shaded");
  55. $("[id='House Not Visible']").text("E - House Not Visible");
  56. $("#guidelines").hide();
  57.  
  58. var content = document.getElementById("wrapper");
  59. content.tabIndex = "0";
  60. content.focus();
  61.  
  62. var element = document.getElementById('preview_overlay');
  63. if (element)
  64. element.parentNode.removeChild(element);
  65.  
  66. initialize = setTimeout(function () {
  67. google = unsafeWindow.google;
  68.  
  69. var PortoAlegre = new google.maps.LatLng(-30.034176,-51.229212);
  70. var myOptions = {
  71. zoom: zoomlevel,
  72. mapTypeId: google.maps.MapTypeId.SATELLITE
  73. }
  74.  
  75. var map = new google.maps.Map(document.getElementById("DIVinterna"), myOptions);
  76. var geocoder = new google.maps.Geocoder();
  77.  
  78. geocodeAddress(geocoder, map);
  79.  
  80. function geocodeAddress(geocoder, resultsMap) {
  81. var address = addy;
  82. geocoder.geocode({'address': address}, function(results, status) {
  83. if (status === google.maps.GeocoderStatus.OK) {
  84. resultsMap.setCenter(results[0].geometry.location);
  85. var marker = new google.maps.Marker({
  86. map: resultsMap,
  87. position: results[0].geometry.location
  88. });
  89. } else {
  90. alert('Geocode was not successful for the following reason: ' + status);
  91. }
  92. });
  93. }
  94. }, 500);
  95.  
  96. document.onkeydown = showkeycode;
  97. function showkeycode(evt){
  98. var keycode = evt.keyCode;
  99. switch (keycode) {
  100. case 65: //a
  101. $("[id='Completely Shaded']").click();
  102. document.getElementById("mturk_form").submit();
  103. break;
  104. case 66: //b
  105. $("[id='Mostly Shaded']").click();
  106. document.getElementById("mturk_form").submit();
  107. break;
  108. case 67: //c
  109. $("[id='Mostly Not Shaded']").click();
  110. document.getElementById("mturk_form").submit();
  111. break;
  112. case 68: //d
  113. $("[id='Completely NOT Shaded']").click();
  114. document.getElementById("mturk_form").submit();
  115. break;
  116. case 69: //e
  117. $("[id='House Not Visible']").click();
  118. document.getElementById("mturk_form").submit();
  119. break;
  120. }
  121. }