Greasy Fork 支持简体中文。

IRC Export (reformatted output mod)

Export HIT information for IRC chat

目前為 2015-01-07 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name IRC Export (reformatted output mod)
  3. // @description Export HIT information for IRC chat
  4. // @version 3.0c
  5. // @include https://www.mturk.com/mturk/searchbar*
  6. // @include https://www.mturk.com/mturk/findhits*
  7. // @include https://www.mturk.com/mturk/viewhits*
  8. // @include https://www.mturk.com/mturk/viewsearchbar*
  9. // @include https://www.mturk.com/mturk/sortsearchbar*
  10. // @include https://www.mturk.com/mturk/sorthits*
  11. // @grant GM_setClipboard
  12. // @author Cristo
  13. // @namespace mturkgrind
  14. // ==/UserScript==
  15.  
  16. // modified by clickhappier to reformat output in more logical ordering/separating/labeling,
  17. // since I thought it was unnecessarily unclear to read with the separators in the middle of each
  18. // type of information (label, value, separator, relevant url) instead of between the different types,
  19. // and wanted to be clearer about what the TO values represented;
  20. // also wanted to remove unnecessary linebreaks in the output that caused it to spread one HIT's info
  21. // across several IRC comments, which made it hard to tell where one HIT's info stopped and another began
  22. // (though after the version I initially modified, Cristo did later do away with all but one linebreak);
  23. // also fixed Amazon fiddling with HIT name cell contents after Oct 20, 2014 change;
  24. // also fixed Turkopticon mirror API domain to keep working after Oct 27, 2014 change
  25.  
  26.  
  27. var caps = document.getElementsByClassName('capsulelink');
  28. for (var c = 0; c < caps.length/2; c++){
  29. button = document.createElement('button');
  30. button.setAttribute("place",c);
  31. button.textContent = 'IRC';
  32. button.style.height = '14px';
  33. button.style.width = '30px';
  34. button.style.fontSize = '8px';
  35. button.style.border = '1px solid';
  36. button.style.padding = '0px';
  37. button.style.backgroundColor = 'transparent';
  38. button.title = 'Click to save Hit information to your clipboard';
  39. button.addEventListener("click", display, false);
  40. document.getElementById('capsule'+c+'-0').parentNode.appendChild(button);
  41. }
  42. function getTO(f){
  43. var toComp = [];
  44. var toUrl = 'https://mturk-api.istrack.in/multi-attrs.php?ids='+f;
  45. requestTO = new XMLHttpRequest();
  46. requestTO.onreadystatechange = function () {
  47. if ((requestTO.readyState ===4) && (requestTO.status ===200)) {
  48. if(requestTO.responseText.split(':').length > 2){
  49. var toInfo = requestTO.responseText.split('{')[3].split('}')[0].split(',');
  50. for (var t = 0; t < 3; t++){
  51. var arrTo = toInfo[t].split(':');
  52. toComp.push(arrTo[1].substring(1,4));
  53. }
  54. } else {
  55. toComp = ['-','-','-'];
  56. }
  57. }
  58. }
  59. requestTO.open('GET', toUrl, false);
  60. requestTO.send(null);
  61. return toComp;
  62. }
  63.  
  64. function tinyURL(u){
  65. var shortRes;
  66. var urlG = "https://www.googleapis.com/urlshortener/v1/url";
  67. var gimmieG = new XMLHttpRequest();
  68. gimmieG.open("POST", urlG, false);
  69. gimmieG.setRequestHeader("Content-Type", "application/json");
  70. gimmieG.onreadystatechange = function (event) {
  71. if (gimmieG.readyState == 4) {
  72. var title = "Google URL Shortener";
  73. if (gimmieG.status == 200) {
  74. shortRes = JSON.parse(gimmieG.response).id;
  75. } else {
  76. console.log('nothing');
  77. }
  78. }
  79. }
  80. var data = new Object();
  81. data.longUrl = u;
  82. gimmieG.send(JSON.stringify(data));
  83. return shortRes;
  84. }
  85. function display(e){
  86. var theButton = e.target;
  87. theButton.style.backgroundColor = '#FD2B2B';
  88. setTimeout(function(){theButton.style.backgroundColor = 'transparent';},600);
  89. var capHand = document.getElementById('capsule'+theButton.getAttribute("place")+'-0');
  90. var tBodies = capHand.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode;
  91. var capReq = tBodies.getElementsByClassName('requesterIdentity')[0].textContent;
  92. var capReqId = tBodies.getElementsByClassName('requesterIdentity')[0].parentNode.href.split('requesterId=')[1];
  93. var capTitle = capHand.textContent.trim();
  94. capTitle = capTitle.replace(/<(\w+)[^>]*>.*<\/\1>/gi, "").trim(); // addition to strip html tags and their contents, appearing inside the title link (re 10-20-2014 appearance of "<span class="tags"></span>")
  95. var capGId = capHand.parentNode.parentNode.getElementsByClassName('capsulelink')[1].firstChild.nextSibling.href.split('groupId=')[1];
  96. var capRew = tBodies.getElementsByClassName('reward')[0].textContent;
  97.  
  98. var capTime = tBodies.getElementsByClassName('capsule_field_text')[2].textContent;
  99.  
  100. var capAvailable = tBodies.getElementsByClassName('capsule_field_text')[4].textContent;
  101.  
  102. var qualList = document.getElementById('capsule'+theButton.getAttribute("place")+'target').getElementsByTagName('tbody')[2];
  103. var qualColl = qualList.getElementsByTagName('td');
  104. var masterStat = '';
  105. for ( var m = 3; m < qualColl.length; m++ ) {
  106. if ( qualColl[m].textContent.indexOf('Masters') > -1 ) {
  107. masterStat = 'MASTERS • ';
  108. }
  109. }
  110. var capUrl = tinyURL('https://www.mturk.com/mturk/preview?groupId='+capGId);
  111. var capReqUrl = tinyURL('https://www.mturk.com/mturk/searchbar?selectedSearchType=hitgroups&requesterId='+capReqId);
  112. var toLink = tinyURL('http://turkopticon.ucsd.edu/'+capReqId);
  113. var capToStats = getTO(capReqId);
  114. var exString = masterStat + 'Requester: ' + capReq + ' ' + capReqUrl + ' • ' + 'HIT: ' + capTitle + ' ' + capUrl + ' • ' + 'Pay: ' + capRew + ' • ' + 'Avail: ' + capAvailable + ' • ' + 'Time Limit: ' + capTime + ' • ' + 'TO: ' + 'Pay='+capToStats[1] + ' Fair='+capToStats[2] + ' Comm='+capToStats[0] + ' ' + toLink ;
  115. GM_setClipboard(exString);
  116. }