MTurk 13D Data Extraction

Make it easier to copy/paste data for 13D Data Extraction HITs

  1. // ==UserScript==
  2. // @name MTurk 13D Data Extraction
  3. // @description Make it easier to copy/paste data for 13D Data Extraction HITs
  4. // @namespace http://idlewords.net
  5. // @include https://www.mturkcontent.com/dynamic/hit*
  6. // @include https://www.sec.gov/Archives/*
  7. // @version 0.10
  8. // @require https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
  9. // @grant GM_setClipboard
  10. // ==/UserScript==
  11.  
  12. var datetime = 1; // CHANGE THIS TO 0 (zero) FOR DD/MM/YYYY FORMAT
  13.  
  14. if ($("#PageTitle:contains('Filing Detail')").length) {
  15. var accept_date = $("div.formContent").eq(0).children("div.formGrouping").eq(0).children("div.info").eq(1);
  16. var split_date = accept_date.text().split(" ");
  17. var acc_date = split_date[0].split("-");
  18. if (acc_date[0].length == 1) {
  19. acc_date[0] = '0' + acc_date[0];
  20. }
  21. if (datetime == 1) {
  22. new_date = acc_date[1] + '/' + acc_date[2] + '/' + acc_date[0];
  23. } else {
  24. new_date = acc_date[2] + '/' + acc_date[1] + '/' + acc_date[0];
  25. }
  26. accept_date.text('');
  27. accept_date.wrapInner("<input type='text' style='width: 400px; border: none; font-size: 16px;' id='datetime'></input>");
  28. $("#datetime").val(new_date + ' ' + split_date[1]).mouseover(function() {
  29. //$(this).select();
  30. GM_setClipboard(new_date + ' ' + split_date[1]);
  31. $(this).css('color', 'green').css('font-weight', 'bold').val($(this).val() + ' - COPIED');
  32. });
  33. console.log(link.length);
  34. } else if ($("li:contains('You will be provided')").length) {
  35. $("#acceptance_date").blur(function() {
  36. if ($(this).val() !== '' && $("#acceptance_time").val() === '') {
  37. var date_time = $(this).val().split(" ");
  38. $("#acceptance_time").val(date_time[1]);
  39. $("#acceptance_time").attr('readonly', 'readonly');
  40. $("#acceptance_date").val(date_time[0]);
  41. $("#acceptance_date").attr('readonly', 'readonly');
  42. }
  43. });
  44. $("a[href~='sec.gov']").attr('target', 'stock');
  45. var link = $("a:contains('Archives')").attr('href');
  46. window.parent.postMessage("secpage!!!!!" + link, "https://www.mturk.com");
  47. } else if ($(":contains('Class of Securities)')").length) {
  48. cusipHead = $("font, b, p, td, div").filter(":contains('(CUSIP') :contains('Number)')").first();
  49.  
  50. var cusipNumParent = null;
  51. function getCusipPrev() {
  52. var prevTDs = 0;
  53. if (cusipHead.prev().length) {
  54. if (cusipHead.prev("td").length) {
  55. prevTDs = cusipHead.prevAll("td").length;
  56. cusipNumParent = cusipHead.parent().prev();
  57. } else {
  58. cusipNumParent = cusipHead.prev();
  59. }
  60. } else if (cusipHead.parent().prev().length) {
  61. if (cusipHead.parent().prev("td").length) {
  62. prevTDs = cusipHead.parent().prevAll("td").length;
  63. cusipNumParent = cusipHead.parent().parent().prev();
  64. } else {
  65. cusipNumParent = cusipHead.parent().prev();
  66. }
  67. } else if (cusipHead.parent().parent().prev().length) {
  68. if (cusipHead.parent().parent().prev("td").length) {
  69. prevTDs = cusipHead.parent().parent().prevAll("td").length;
  70. cusipNumParent = cusipHead.parent().parent().parent().prev();
  71. } else {
  72. cusipNumParent = cusipHead.parent().prev();
  73. }
  74. }
  75. return prevTDs;
  76. }
  77.  
  78. prevTDs = getCusipPrev();
  79. if (cusipNumParent.prop("tagName") == "HR" || cusipNumParent.find("hr").length) {
  80. cusipHead = cusipNumParent;
  81. cusipNumParent = null;
  82. prevTDs = getCusipPrev();
  83. }
  84.  
  85. if (cusipNumParent !== null) {
  86. var cusipNum = null;
  87. if (cusipNumParent.children().eq(prevTDs).children().first().children().first().length) {
  88. cusipNum = cusipNumParent.children().eq(prevTDs).children().first().children().first();
  89. }
  90. if (cusipNumParent.children().eq(prevTDs).children().first().length) {
  91. // number is buried 2 deep
  92. cusipNum = cusipNumParent.children().eq(prevTDs).children().first();
  93. } else if (cusipNumParent.children().eq(prevTDs).length) {
  94. // number should only be 1 deep
  95. cusipNum = cusipNumParent.children().eq(prevTDs);
  96. } else {
  97. // number is text within parent
  98. cusipNum = cusipNumParent;
  99. }
  100.  
  101. if (cusipNum !== null) {
  102. cusipNum.attr('id', 'cusipNumField');
  103. cusipText = cusipNum.text();
  104. cusipNum.text('');
  105. cusipNum.append("<input type='text' style='width: 400px; border: none; font-size: 16px;' id='cusipNum' />")
  106. $("#cusipNum").val(cusipText).mouseover(function() {
  107. if ($(this).val().substr(-6) === 'COPIED') {
  108. $(this).val($(this).val().replace(' - COPIED', ''));
  109. }
  110. GM_setClipboard($(this).val());
  111. $(this).css('color', 'green').css('font-weight', 'bold').val($(this).val() + ' - COPIED');
  112. });
  113. }
  114. }
  115. }