Facebook HIT Export (regular links)

Export HIT information for posting on Facebook (long link version)

  1. // ==UserScript==
  2. // @name Facebook HIT Export (regular links)
  3. // @description Export HIT information for posting on Facebook (long link version)
  4. // @version 0.82r
  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 + clickhappier + Alden McLaren
  13. // @namespace https://gf.qytechs.cn/en/users/8467
  14. // ==/UserScript==
  15.  
  16. // Based on clickhappier's IRC Export (reformatted output mod) which was a modification of Cristo's IRC Export X script.
  17. // Simple formatting changes made for better readability when posting HIT info to MTurk Members group on Facebook.
  18.  
  19.  
  20.  
  21. var caps = document.getElementsByClassName('capsulelink');
  22. for (var c = 0; c < caps.length/2; c++){
  23. button = document.createElement('button');
  24. button.setAttribute("place",c);
  25. button.textContent = 'FB';
  26. button.style.height = '14px';
  27. button.style.width = '30px';
  28. button.style.fontSize = '8px';
  29. button.style.border = '1px solid';
  30. button.style.padding = '0px';
  31. button.style.backgroundColor = 'transparent';
  32. button.title = 'Click to save Hit information to your clipboard';
  33. button.addEventListener("click", display, false);
  34. document.getElementById('capsule'+c+'-0').parentNode.appendChild(button);
  35. }
  36. function getTO(f){
  37. var toComp = [];
  38. var toUrl = 'https://turkopticon.ucsd.edu/api/multi-attrs.php?ids='+f;
  39. requestTO = new XMLHttpRequest();
  40. requestTO.onreadystatechange = function () {
  41. if ((requestTO.readyState ===4) && (requestTO.status ===200)) {
  42. if(requestTO.responseText.split(':').length > 2){
  43. var toInfo = requestTO.responseText.split('{')[3].split('}')[0].split(',');
  44. for (var t = 0; t < 3; t++){
  45. var arrTo = toInfo[t].split(':');
  46. toComp.push(arrTo[1].substring(1,4));
  47. }
  48. } else {
  49. toComp = ['-','-','-'];
  50. }
  51. }
  52. }
  53. requestTO.open('GET', toUrl, false);
  54. requestTO.send(null);
  55. return toComp;
  56. }
  57.  
  58. function display(e){
  59. var theButton = e.target;
  60. theButton.style.backgroundColor = '#FD2B2B';
  61. setTimeout(function(){theButton.style.backgroundColor = 'transparent';},600);
  62. var capHand = document.getElementById('capsule'+theButton.getAttribute("place")+'-0');
  63. var tBodies = capHand.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode;
  64. var capReq = tBodies.getElementsByClassName('requesterIdentity')[0].textContent;
  65. var capReqId = tBodies.getElementsByClassName('requesterIdentity')[0].parentNode.href.split('requesterId=')[1];
  66. var capTitle = capHand.textContent.trim();
  67. 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>")
  68.  
  69. var capGId = capHand.parentNode.parentNode.getElementsByClassName('capsulelink')[1].firstChild.nextSibling.href.split('=')[1];
  70. capGId = capGId.replace("&hitId", ""); // Amazon messed up the notqualified links, now looking like https://www.mturk.com/mturk/notqualified?hitGroupId=3ID43DSF4IQ1X8LO308D15ZSD5J5GX&hitId=3ID43DSF4IQ1X8LO308D15ZSD5J5GX ; this and the above split happening on = instead of a specific value address that
  71. var capRew = tBodies.getElementsByClassName('reward')[0].textContent;
  72.  
  73. var capTime = tBodies.getElementsByClassName('capsule_field_text')[2].textContent;
  74.  
  75. var capAvailable = tBodies.getElementsByClassName('capsule_field_text')[4].textContent;
  76.  
  77. var qualList = document.getElementById('capsule'+theButton.getAttribute("place")+'target').getElementsByTagName('tbody')[2];
  78. var qualColl = qualList.getElementsByTagName('td');
  79. var masterStat = '';
  80. for ( var m = 3; m < qualColl.length; m++ ) {
  81. if ( qualColl[m].textContent.indexOf('Masters') > -1 ) {
  82. masterStat = 'MASTERS • ';
  83. }
  84. }
  85. var capUrl = 'https://www.mturk.com/mturk/preview?groupId='+capGId;
  86. var capReqUrl = 'https://www.mturk.com/mturk/searchbar?selectedSearchType=hitgroups&requesterId='+capReqId;
  87. var toLink = 'http://turkopticon.ucsd.edu/'+capReqId;
  88. var capToStats = getTO(capReqId);
  89. var exString = masterStat + '\n' + ' • ' + 'Requester: ' + capReq + ' ' + capReqUrl + '\n' + ' • ' + 'HIT: ' + capTitle + ' ' + capUrl + '\n' + ' • ' + 'Pay: ' + capRew + ' • ' + 'Time Limit: ' + capTime + '\n' + ' • ' + 'TO: ' + 'Pay='+capToStats[1] + ' Fair='+capToStats[2] + ' Comm='+capToStats[0] + ' ' + toLink ;
  90. GM_setClipboard(exString);
  91. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址