Unique URL Scripts for Mturk

generates header and unique url for mturk userscripts

  1. // ==UserScript==
  2. // @name Unique URL Scripts for Mturk
  3. // @description generates header and unique url for mturk userscripts
  4. // @author DCI
  5. // @version 1.2
  6. // @namespace www.redpandanetework.org/
  7. // @match https://worker.mturk.com/projects/*
  8. // @grant GM_setClipboard
  9. // ==/UserScript==
  10.  
  11. // Open HIT Details to copy userscript header to clipboard
  12.  
  13. var author = "DCI";
  14. var namespace = "www.redpandanetework.org";
  15. var icon = "http://i.imgur.com/ZITD8b1.jpg";
  16. var description = "I'm so fancy.";
  17.  
  18. var createHeader = function(){
  19. var header =
  20. '// ==UserScript==\n' +
  21. '// @name ' + requester + ' - ' + title + ' - ' + reward + '\n' +
  22. '// @description ' + description + '\n' +
  23. '// @version 1.0\n' +
  24. '// @author ' + author + '\n' +
  25. '// @namespace ' + namespace + '\n' +
  26. '// @icon ' + icon + '\n' +
  27. '// @include ' + parenturl + '\n' +
  28. '// @include ' + includeurl + '\n' +
  29. '// @timer ' + timer + '\n' +
  30. '// @frameurl ' + frameurl + '\n' +
  31. '// @grant GM_setClipboard\n' +
  32. '// @grant GM_openInTab\n' +
  33. '// @grant GM_setValue\n' +
  34. '// @grant GM_getValue\n' +
  35. '// @grant GM_deleteValue\n' +
  36. '// @grant GM_xmlhttpRequest\n' +
  37. '// @require http://code.jquery.com/jquery-latest.min.js\n' +
  38. '// ==/UserScript==\n\n' +
  39. 'if (~window.location.toString().indexOf("https://worker.mturk.com/projects/")){\n' +
  40. ' var groupId = window.location.toString().split("/")[4].split("/")[0];\n' +
  41. ' document.getElementsByTagName("iframe")[0].src = document.getElementsByTagName("iframe")[0].src + "&groupId=" + groupId;\n' +
  42. '}\n\n' +
  43. 'else {\n\n\n\n\n\n\n\n\n\n' +
  44. '}';
  45. GM_setClipboard(header);
  46. };
  47.  
  48. var popup = document.querySelectorAll("a[data-reactid='.2']")[0];
  49. popup.onclick = function(){
  50. setTimeout(function(){
  51. var button = document.createElement("input");
  52. var oldText = document.querySelectorAll("h2[data-reactid='.8.0.0.0.1']")[0];
  53. oldText.innerHTML = "";
  54. oldText.style.color = "black";
  55. button.setAttribute('type','button');
  56. button.setAttribute('name','Scriptify');
  57. button.setAttribute('value','Copy HIT Data to Clipboard');
  58. oldText.appendChild(button);
  59. button.addEventListener("click", function(){
  60. requester = document.querySelectorAll("span[data-reactid='.8.0.0.1.0.0.1']")[0].innerHTML;
  61. title = document.querySelectorAll("span[data-reactid='.8.0.0.1.1.0.1']")[0].innerHTML;
  62. reward = document.querySelectorAll("span[data-reactid='.8.0.0.1.3.4.1']")[0].innerHTML.replace("$","");
  63. timer = document.querySelectorAll("span[data-reactid='.8.0.0.1.3.2.1']")[0].innerHTML;
  64. groupId = window.location.toString().split("/")[4].split("/")[0];
  65. frameurl = document.getElementsByTagName('iframe')[0].src.toString() + "&groupId=" + groupId;
  66. includeurl = frameurl.split("/")[0] + "//" + frameurl.split("/")[1] + frameurl.split("/")[2] + "/*" + window.location.toString().split('/')[4].split('/')[0] + "*";
  67. parenturl = "https://worker.mturk.com/projects/" + window.location.toString().split("/")[4] + "*";
  68. createHeader();
  69. button.setAttribute('value','Data Copied!');
  70. setTimeout(function(){
  71. document.querySelectorAll("button[class='close']")[0].click();
  72. },0500);
  73. });
  74. },0500);
  75. };
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.