CH Status Detail Numbering

Displays numbering next to the up-to-25 HITs on each page of MTurk's daily status detail reports. Also shows HIT assignment ID in mouseover text, and copies it on click.

  1. // ==UserScript==
  2. // @name CH Status Detail Numbering
  3. // @author clickhappier
  4. // @namespace clickhappier
  5. // @description Displays numbering next to the up-to-25 HITs on each page of MTurk's daily status detail reports. Also shows HIT assignment ID in mouseover text, and copies it on click.
  6. // @version 1.2c
  7. // @include https://www.mturk.com/mturk/statusdetail*
  8. // @require http://code.jquery.com/jquery-latest.min.js
  9. // @grant GM_setClipboard
  10. // ==/UserScript==
  11.  
  12.  
  13. // get URL variable - from http://css-tricks.com/snippets/javascript/get-url-variables/
  14. function getQueryVariable(variable)
  15. {
  16. var query = window.location.search.substring(1);
  17. var vars = query.split("&");
  18. for ( var i=0; i<vars.length; i++ )
  19. {
  20. var pair = vars[i].split("=");
  21. if ( pair[0] == variable )
  22. { return pair[1]; }
  23. }
  24. return(false);
  25. }
  26. // modified to take arbitrary URL input instead of current location:
  27. function getUrlVariable(url, variable)
  28. {
  29. var query = url.split('?');
  30. var vars = query[1].split("&");
  31. for ( var i=0; i<vars.length; i++ )
  32. {
  33. var pair = vars[i].split("=");
  34. if ( pair[0] == variable )
  35. { return pair[1]; }
  36. }
  37. return(false);
  38. }
  39.  
  40.  
  41. // determine current page number
  42. var pageNum = "";
  43. if ( document.location.href.indexOf('pageNumber') > -1 )
  44. {
  45. pageNum = getQueryVariable("pageNumber");
  46.  
  47. if ( pageNum=='' || isNaN(pageNum) ) // just in case
  48. { pageNum = 1; }
  49. }
  50. else // if pageNumber not present in URL, must be first page
  51. {
  52. pageNum = 1;
  53. }
  54.  
  55.  
  56. // add cell to header row for new column
  57. $('th.statusdetailRequesterColumnHeader').before('<th class="statusdetailNumberColumnHeader" title="Click a number to copy the HIT ID to your clipboard.">#</th>');
  58.  
  59.  
  60. // add numbering cells to lefthand side of each data row
  61. // script concept and basic part of this function were from Kerek: http://www.mturkgrind.com/posts/562667/
  62. $('td.statusdetailRequesterColumnValue').each(function(hitNum){ // uses hitNum+1 inside this function because it starts counting at 0
  63.  
  64. // get HIT ID
  65. //var contactLinkSplit = $(this).find('a[title="Contact this Requester"]').attr('href').split('&');
  66. //var hitID = contactLinkSplit[0].replace('/mturk/contact?subject=Regarding+Amazon+Mechanical+Turk+HIT+', '');
  67. // had to change HIT ID retrieval method after Amazon randomly messed with the contact link URL format on the daily status pages in June 2015
  68. var contactLink = $(this).find('a[title="Contact this Requester"]').attr('href');
  69. var hitID = getUrlVariable(contactLink, 'subject').replace('Regarding+Amazon+Mechanical+Turk+HIT+', '');
  70.  
  71. // calculate multi-page multiplied HIT number
  72. var multiHitNum = ((pageNum-1)*25) + (hitNum+1);
  73.  
  74. // display results
  75. $(this).before('<td class="statusdetailNumberColumnValue" title="' + hitID + '">' + pageNum + '.' + (hitNum+1) + ' (' + multiHitNum + ')' + '</td>');
  76. });
  77.  
  78.  
  79. // copy HIT ID to clipboard when number column value is clicked on
  80. $(".statusdetailNumberColumnValue").click(function(){
  81. if (GM_setClipboard)
  82. {
  83. GM_setClipboard( $(this).attr('title') );
  84. }
  85. });