HIT Scraper (classic version)

Snag HITs.

  1. // ==UserScript==
  2. // @name HIT Scraper (classic version)
  3. // @author Kerek
  4. // @description Snag HITs.
  5. // Based in part on code from mmmturkeybacon Export Mturk History and mmmturkeybacon Color Coded Search with Checkpoints
  6. // @namespace http://userscripts.org/users/536998
  7. // @match https://www.mturk.com/mturk/findhits?match=true#hit_scraper*
  8. // @match https://www.mturk.com/mturk/findhits?match=true?hit_scraper*
  9. // @version 1.3.0.1
  10. // @grant GM_xmlhttpRequest
  11. // @grant GM_getValue
  12. // @grant GM_setValue
  13. // @require http://code.jquery.com/jquery-latest.min.js
  14. // ==/UserScript==
  15.  
  16. //alter the requester ignore last as you desire, just follow the format below and use EXACT capitalization e.g., CrowdSource
  17. var ignore_list = ["Oscar Smith", "Jon Brelig"];
  18.  
  19. //this searches extra pages if you skip too much, helps fill out results if you hit a chunk of ignored HITs. Change to true for this behavior.
  20. var correct_for_skips = false;
  21.  
  22. //weight the four TO ratings for the coloring. Default has pay twice as important as fairness and nothing for communication and fast.
  23. var COMM_WEIGHT = 0;
  24. var PAY_WEIGHT = 10;
  25. var FAIR_WEIGHT = 5;
  26. var FAST_WEIGHT = 0;
  27.  
  28. //display your hitdb records if applicable
  29. var check_hitDB = true;
  30.  
  31. //default text size
  32. var default_text_size=11;
  33.  
  34.  
  35.  
  36. var HITStorage = {};
  37. var indexedDB = window.indexedDB || window.webkitIndexedDB ||
  38. window.mozIndexedDB;
  39. window.IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction || window.mozIDBTransaction;
  40. window.IDBKeyRange = window.IDBKeyRange || window.webkitIDBKeyRange || window.mozIDBKeyRange;
  41. HITStorage.IDBTransactionModes = { "READ_ONLY": "readonly", "READ_WRITE": "readwrite", "VERSION_CHANGE": "versionchange" };
  42. var IDBKeyRange = window.IDBKeyRange;
  43.  
  44. HITStorage.indexedDB = {};
  45. HITStorage.indexedDB = {};
  46. HITStorage.indexedDB.db = null;
  47.  
  48. HITStorage.indexedDB.onerror = function(e) {
  49. console.log(e);
  50. };
  51.  
  52. var v=4;
  53.  
  54. HITStorage.indexedDB.checkTitle = function(title,button) {
  55. var request = indexedDB.open("HITDB", v);
  56. request.onsuccess = function(e) {
  57. HITStorage.indexedDB.db = e.target.result;
  58. var db = HITStorage.indexedDB.db;
  59. if (!db.objectStoreNames.contains("HIT"))
  60. {
  61. db.close();
  62. return;
  63. }
  64. var trans = db.transaction(["HIT"], HITStorage.IDBTransactionModes.READ_ONLY);
  65. var store = trans.objectStore("HIT");
  66.  
  67. var index = store.index("title");
  68. index.get(title).onsuccess = function(event)
  69. {
  70. if (event.target.result === undefined)
  71. {
  72. console.log(title + ' not found');
  73. history[button].titledb=false;
  74. }
  75. else
  76. {
  77. console.log(title + ' found');
  78. history[button].titledb=true;
  79. }
  80. db.close();
  81. };
  82. };
  83. request.onerror = HITStorage.indexedDB.onerror;
  84. };
  85.  
  86. HITStorage.indexedDB.checkRequester = function(id,button) {
  87. var request = indexedDB.open("HITDB", v);
  88. request.onsuccess = function(e) {
  89. HITStorage.indexedDB.db = e.target.result;
  90. var db = HITStorage.indexedDB.db;
  91. if (!db.objectStoreNames.contains("HIT"))
  92. {
  93. db.close();
  94. return;
  95. }
  96. var trans = db.transaction(["HIT"], HITStorage.IDBTransactionModes.READ_ONLY);
  97. var store = trans.objectStore("HIT");
  98.  
  99. var index = store.index("requesterId");
  100. index.get(id).onsuccess = function(event)
  101. {
  102. if (event.target.result === undefined)
  103. {history[button].reqdb=false;
  104. console.log(id + ' not found');
  105. }
  106. else
  107. {
  108. history[button].reqdb=true;
  109. console.log(id + ' found');
  110. }
  111. db.close();
  112. };
  113. };
  114. request.onerror = HITStorage.indexedDB.onerror;
  115. };
  116.  
  117. var PAGES_TO_SCRAPE = 3;
  118. var MINIMUM_HITS = 100;
  119. var SEARCH_REFRESH=0;
  120. var URL_BASE = "/mturk/searchbar?searchWords=&selectedSearchType=hitgroups";
  121. var initial_url = URL_BASE;
  122. var TO_REQ_URL = "http://turkopticon.ucsd.edu/reports?id=";
  123. var found_key_list=[];
  124. var last_clear_time = new Date().getTime();
  125. var searched_once = false;
  126. var save_new_results_time = 120;
  127. var save_results_time = 3600;
  128. var default_type = 0;
  129. var cur_loc = window.location.href;
  130. var time_input = document.createElement("INPUT");
  131. time_input.value = 0;
  132. var page_input = document.createElement("INPUT");
  133. page_input.value = 3;
  134. var min_input = document.createElement("INPUT");
  135. var new_time_display_input = document.createElement("INPUT");
  136. new_time_display_input.value = 300;
  137. var reward_input = document.createElement("INPUT");
  138. var qual_input = document.createElement("INPUT");
  139. qual_input.type = "checkbox";
  140. qual_input.checked = true;
  141. var masters_input = document.createElement("INPUT");
  142. masters_input.type = "checkbox";
  143. var sort_input1 = document.createElement("INPUT");
  144. sort_input1.type = "radio";
  145. sort_input1.name = "sort_type";
  146. sort_input1.value = "latest";
  147. sort_input1.checked = true;
  148. var sort_input2 = document.createElement("INPUT");
  149. sort_input2.type = "radio";
  150. sort_input2.name = "sort_type";
  151. sort_input2.value = "most";
  152. var sort_input3 = document.createElement("INPUT");
  153. sort_input3.type = "radio";
  154. sort_input3.name = "sort_type";
  155. sort_input3.value = "amount";
  156.  
  157. var search_input = document.createElement("INPUT");
  158.  
  159. var LINK_BASE = "https://www.mturk.com";
  160. var BACKGROUND_COLOR = "rgb(19, 19, 19)";
  161. var STATUSDETAIL_DELAY = 250;
  162. var MPRE_DELAY = 3000;
  163.  
  164. var next_page = 1;
  165.  
  166. var GREEN = '#66CC66'; // > 4
  167. var LIGHTGREEN = '#ADFF2F'; // > 3 GREEN YELLOW
  168. var YELLOW = '#FFD700';
  169. var ORANGE = '#FF9900'; // > 2
  170. var RED = '#FF3030'; // <= 2
  171. var BLUE = '#C0D9D9'; // no TO
  172. var GREY = 'lightGrey';
  173. var BROWN = '#94704D';
  174. var DARKGREY = '#9F9F9F';
  175. $('body').css('background', BACKGROUND_COLOR);
  176.  
  177. var API_PROXY_BASE = 'https://mturk-api.istrack.in/';
  178. var API_MULTI_ATTRS_URL = API_PROXY_BASE + 'multi-attrs.php?ids=';
  179. var REVIEWS_BASE = 'http://turkopticon.ucsd.edu/';
  180.  
  181. var control_panel_HTML = '<div id="control_panel" style="margin: 0 auto 0 auto;' +
  182. 'border-bottom: 1px solid #000000; margin-bottom: 5px; ' +
  183. 'background-color: ' + BACKGROUND_COLOR + ';"></div>';
  184. $('body > :not(#control_panel)').hide(); //hide all nodes directly under the body
  185. $('body').prepend(control_panel_HTML);
  186.  
  187. var control_panel = document.getElementById("control_panel");
  188. var big_red_button = document.createElement("BUTTON");
  189. var progress_report = document.createTextNode("Stopped");
  190. var text_area = document.createElement("TABLE");
  191. big_red_button.textContent = "Show Interface";
  192. big_red_button.onclick = function(){show_interface();};
  193. control_panel.appendChild(big_red_button);
  194.  
  195. show_interface();
  196.  
  197. var global_run = false;
  198. var statusdetail_loop_finished = false;
  199. var date_header = "";
  200. var history = {};
  201. var wait_loop;
  202.  
  203. function set_progress_report(text, force)
  204. {
  205. if (global_run == true || force == true)
  206. {
  207. progress_report.textContent = text;
  208. }
  209. }
  210.  
  211. function get_progress_report()
  212. {
  213. return progress_report.textContent;
  214. }
  215.  
  216. function wait_until_stopped()
  217. {
  218. if (global_run == true)
  219. {
  220. if (statusdetail_loop_finished == true)
  221. {
  222. big_red_button.textContent = "Start";
  223. set_progress_report("Finished", false);
  224. }
  225. else
  226. {
  227. setTimeout(function(){wait_until_stopped();}, 500);
  228. }
  229. }
  230. }
  231.  
  232. function display_wait_time(wait_time)
  233. {
  234. if (global_run == true)
  235. {
  236. var current_progress = get_progress_report();
  237. if (current_progress.indexOf("Searching again in")!==-1)
  238. {
  239. set_progress_report(current_progress.replace(/Searching again in \d+ seconds/ , "Searching again in " + wait_time + " seconds"),false);
  240. }
  241. else
  242. set_progress_report(current_progress + " Searching again in " + wait_time + " seconds.", false);
  243. if (wait_time>1)
  244. setTimeout(function(){display_wait_time(wait_time-1);}, 1000);
  245. }
  246. }
  247.  
  248. function dispArr(ar)
  249. {
  250. var disp = "";
  251. for (var z = 0; z < ar.length; z++)
  252. {
  253. disp += "id " + z + " is " + ar[z] + " ";
  254. }
  255. console.log(disp);
  256. }
  257.  
  258. function scrape($src)
  259. {
  260. var $requester = $src.find('a[href^="/mturk/searchbar?selectedSearchType=hitgroups&requester"]');
  261. var $title = $src.find('a[class="capsulelink"]');
  262. var $reward = $src.find('span[class="reward"]');
  263. var $preview = $src.find('a[href^="/mturk/preview?"]');
  264. var $qualified = $src.find('a[href^="/mturk/notqualified?"]');
  265. var not_qualified_group_IDs=[];
  266. $qualified.each(function(){
  267. var groupy = $(this).attr('href');
  268. groupy = groupy.replace("/mturk/notqualified?hitId=","");
  269. not_qualified_group_IDs.push(groupy);
  270. });
  271. var $mixed = $src.find('a[href^="/mturk/preview?"],a[href^="/mturk/notqualified?"]');
  272. var listy =[];
  273. $mixed.each(function(){
  274. var groupy = $(this).attr('href');
  275. groupy = groupy.replace("/mturk/notqualified?hitId=","");
  276. groupy = groupy.replace("/mturk/preview?groupId=","");
  277. listy.push(groupy);
  278. });
  279. listy = listy.filter(function(elem, pos) {
  280. return listy.indexOf(elem) == pos;
  281. });
  282.  
  283. for (var j = 0; j < $requester.length; j++)
  284. {
  285. var $hits = $requester.eq(j).parent().parent().parent().parent().parent().parent().find('td[class="capsule_field_text"]');
  286. var requester_name = $requester.eq(j).text().trim();
  287. var requester_link = $requester.eq(j).attr('href');
  288. var group_ID=listy[j];
  289. var preview_link = "/mturk/preview?groupId=" + group_ID;
  290. var title = $title.eq(j).text().trim();
  291. var reward = $reward.eq(j).text().trim();
  292. var hits = $hits.eq(4).text().trim();
  293. var requester_id = requester_link.replace('/mturk/searchbar?selectedSearchType=hitgroups&requesterId=','');
  294. var accept_link;
  295. accept_link = preview_link.replace('preview','previewandaccept');
  296.  
  297. key = requester_name+title+reward+group_ID;
  298. found_key_list.push(key);
  299. if (history[key] == undefined)
  300. {
  301. history[key] = {requester:"", title:"", reward:"", hits:"", req_link:"", prev_link:"", rid:"", acc_link:"", new_result:"", qualified:"", found_this_time:"", initial_time:"", reqdb:"",titledb:""};
  302. history[key].req_link = requester_link;
  303. history[key].prev_link = preview_link;
  304. history[key].requester = requester_name;
  305. history[key].title = title;
  306. history[key].reward = reward;
  307. history[key].hits = hits;
  308. history[key].rid = requester_id;
  309. history[key].acc_link = accept_link;
  310. HITStorage.indexedDB.checkRequester(requester_id,key);
  311. HITStorage.indexedDB.checkTitle(title,key);
  312. if (searched_once)
  313. {
  314. history[key].initial_time = new Date().getTime();//-1000*(save_new_results_time - SEARCH_REFRESH);
  315. history[key].new_result = 0;
  316. }
  317. else
  318. {
  319. history[key].initial_time = new Date().getTime()-1000*save_new_results_time;
  320. history[key].new_result = 1000*save_new_results_time;
  321. }
  322. if (not_qualified_group_IDs.indexOf(group_ID)!==-1)
  323. history[key].qualified = false;
  324. else
  325. history[key].qualified = true;
  326.  
  327. history[key].found_this_time = true;
  328. }
  329. else
  330. {
  331. history[key].new_result = new Date().getTime() - history[key].initial_time;
  332. history[key].found_this_time = true;
  333. history[key].hits = hits;
  334. }
  335. }
  336. }
  337.  
  338. function statusdetail_loop(next_URL)
  339. {
  340. if (global_run == true)
  341. {
  342. if (next_URL.length != 0)
  343. {
  344. $.get(next_URL, function(data)
  345. {
  346. var $src = $(data);
  347. var maxpagerate = $src.find('td[class="error_title"]:contains("You have exceeded the maximum allowed page request rate for this website.")');
  348. if (maxpagerate.length == 0)
  349. {
  350. set_progress_report("Processing page " + next_page, false);
  351. scrape($src);
  352. $next_URL = $src.find('a[href^="/mturk/viewsearchbar"]:contains("Next")');
  353. next_URL = ($next_URL.length != 0) ? $next_URL.attr("href") : "";
  354. next_page++;
  355. if (default_type == 1)
  356. {
  357. var hmin = MINIMUM_HITS+1;
  358. for (j = 0; j < found_key_list.length; j++)
  359. {
  360. if (history[found_key_list[j]].hits < hmin)
  361. {
  362. next_URL = "";
  363. next_page = -1;
  364. break;
  365. }
  366. }
  367. }
  368. else if (next_page > PAGES_TO_SCRAPE && correct_for_skips)
  369. {
  370. var skipped_hits = 0;
  371. var added_pages = 0;
  372. for (j = 0; j < found_key_list.length; j++)
  373. {
  374. var obj = history[found_key_list[j]];
  375. if (! ignore_check(obj.requester,obj.title))
  376. skipped_hits++;
  377. }
  378. added_pages = Math.floor(skipped_hits/10);
  379. if (skipped_hits%10 >6)
  380. added_pages++;
  381. if (next_page > PAGES_TO_SCRAPE + added_pages)
  382. {
  383. next_URL = "";
  384. next_page = -1;
  385. }
  386. }
  387. else if (next_page > PAGES_TO_SCRAPE)
  388. {
  389. next_URL = "";
  390. next_page = -1;
  391. }
  392. setTimeout(function(){statusdetail_loop(next_URL);}, STATUSDETAIL_DELAY);
  393. }
  394. else
  395. {
  396. console.log("MPRE");
  397. setTimeout(function(){statusdetail_loop(next_URL);}, MPRE_DELAY);
  398. }
  399. });
  400. }
  401. else
  402. {
  403. searched_once = true;
  404. var found_hits = found_key_list.length;
  405. var shown_hits = 0;
  406. var new_hits = 0;
  407. var url = API_MULTI_ATTRS_URL;
  408. var rids = [];
  409. var lastRow = text_area.rows.length - 1;
  410. for (i = lastRow; i>0; i--)
  411. text_area.deleteRow(i);
  412. for (j = 0; j < found_key_list.length; j++)
  413. {
  414. var obj = history[found_key_list[j]];
  415. if (ignore_check(obj.requester,obj.title) && obj.found_this_time){
  416. ++shown_hits;
  417. var col_heads = ["<a href='"+ LINK_BASE+obj.req_link +"' target='_blank'>" + obj.requester + "</a>","<a href='"+ LINK_BASE+obj.prev_link +"' target='_blank'>" + obj.title + "</a>",obj.reward,obj.hits,"TO down","<a href='"+ LINK_BASE+obj.acc_link +"' target='_blank'>Accept</a>"];
  418. var row = text_area.insertRow(text_area.rows.length);
  419. url += obj.rid + ',';
  420. rids.push(obj.rid);
  421. if (check_hitDB)
  422. {
  423. col_heads.push("R");
  424. col_heads.push("T");
  425. }
  426. if (!obj.qualified)
  427. {
  428. col_heads.push("Not Qualified");
  429. }
  430. for (i=0; i<col_heads.length; i++)
  431. {
  432. var this_cell = row.insertCell(i);
  433. row.cells[i].style.fontSize = default_text_size;
  434. this_cell.innerHTML = col_heads[i];
  435. if(i>1)
  436. this_cell.style.textAlign = 'center';
  437. if (check_hitDB)
  438. {
  439. if (i==6)
  440. {
  441. if (obj.reqdb)
  442. this_cell.style.backgroundColor = GREEN;
  443. else
  444. this_cell.style.backgroundColor = RED;
  445. }
  446. else if (i==7)
  447. {
  448. if (obj.titledb)
  449. this_cell.style.backgroundColor = GREEN;
  450. else
  451. this_cell.style.backgroundColor = RED;
  452. }
  453. else if (i==8)
  454. this_cell.style.backgroundColor = DARKGREY;
  455. }
  456. else if (i==6)
  457. this_cell.style.backgroundColor = DARKGREY;
  458. }
  459. if (Object.keys(history).length>0)
  460. {
  461. if (obj.new_result < 1000*save_new_results_time)
  462. {
  463. new_hits++;
  464. for (i in col_heads)
  465. {
  466. row.cells[i].style.fontSize = default_text_size + 1;
  467. row.cells[i].style.fontWeight = "bold";
  468. }
  469. }
  470. }
  471. }
  472. }
  473. set_progress_report("Scrape complete. " + shown_hits + " HITs found (" + new_hits + " new results). " + (found_hits - shown_hits) + " HITs ignored.", false);
  474. url = url.substring(0,url.length - 1);
  475. var success_flag = false;
  476. GM_xmlhttpRequest(
  477. {
  478. method: "GET",
  479. url: url,
  480. onload: function (results)
  481. {
  482. rdata = $.parseJSON(results.responseText);
  483. for (i = 0; i < rids.length; i++)
  484. {
  485. text_area.rows[i+1].style.backgroundColor = GREY;
  486. if (rdata[rids[i]])
  487. {
  488. var pay = rdata[rids[i]].attrs.pay
  489. var reviews = rdata[rids[i]].reviews
  490. var average = 0;
  491. var sum = 0;
  492. var divisor = 0;
  493. var comm = rdata[rids[i]].attrs.comm;
  494. var fair = rdata[rids[i]].attrs.fair;
  495. var fast = rdata[rids[i]].attrs.fast;
  496. if (comm > 0)
  497. {
  498. sum += COMM_WEIGHT*comm;
  499. divisor += COMM_WEIGHT;
  500. }
  501. if (pay > 0)
  502. {
  503. sum += PAY_WEIGHT*pay;
  504. divisor += PAY_WEIGHT;
  505. }
  506. if (fair > 0)
  507. {
  508. sum += FAIR_WEIGHT*fair;
  509. divisor += FAIR_WEIGHT;
  510. }
  511. if (fast > 0)
  512. {
  513. sum += FAST_WEIGHT*fast;
  514. divisor += FAST_WEIGHT;
  515. }
  516. if (divisor > 0)
  517. {
  518. average = sum/divisor;
  519. }
  520. text_area.rows[i+1].cells[4].innerHTML = "<a href='"+ TO_REQ_URL+rids[i] +"' target='_blank'>" + pay + "</a>";
  521. if (reviews > 4)
  522. {
  523. if (average > 4.49)
  524. text_area.rows[i+1].style.backgroundColor = GREEN;
  525. else if (average > 3.49)
  526. text_area.rows[i+1].style.backgroundColor = LIGHTGREEN;
  527. //else if (average > 2.99)
  528. // text_area.rows[i+1].style.backgroundColor = YELLOW;
  529. else if (average > 1.99)
  530. text_area.rows[i+1].style.backgroundColor = ORANGE;
  531. else if (average > 0)
  532. text_area.rows[i+1].style.backgroundColor = RED;
  533. }
  534. }
  535. else
  536. {
  537. text_area.rows[i+1].cells[4].innerHTML = "No data";
  538. }
  539. }
  540. success_flag = true;
  541. }
  542. });
  543. if (!success_flag)
  544. for (i = 0; i < rids.length; i++) text_area.rows[i+1].style.backgroundColor = GREY;
  545. statusdetail_loop_finished = true;
  546. if (SEARCH_REFRESH>0)
  547. {
  548. wait_loop = setTimeout(function(){if (global_run) start_it();}, 1000*SEARCH_REFRESH);
  549. display_wait_time(SEARCH_REFRESH);
  550. }
  551. else
  552. {
  553. global_run = false;
  554. big_red_button.textContent = "Start";
  555. }
  556. }
  557. }
  558. }
  559.  
  560. function ignore_check(r,t){
  561. if (ignore_list.indexOf(r)==-1)
  562. {
  563. return true;
  564. }
  565. return false;
  566. }
  567.  
  568. function start_running()
  569. {
  570. if (big_red_button.textContent == "Start")
  571. {
  572. global_run = true;
  573. initial_url = URL_BASE;
  574. if (search_input.value.length>0)
  575. {
  576. initial_url = initial_url.replace("searchWords=", "searchWords=" + search_input.value);
  577. }
  578. if (time_input.value.replace(/[^0-9]+/g,"") != "")
  579. {
  580. SEARCH_REFRESH = Number(time_input.value);
  581. }
  582. if (page_input.value.replace(/[^0-9]+/g,"") != "")
  583. {
  584. PAGES_TO_SCRAPE = Number(page_input.value);
  585. }
  586. if (min_input.value.replace(/[^0-9]+/g,"") != "")
  587. {
  588. MINIMUM_HITS = Number(min_input.value);
  589. }
  590. if (new_time_display_input.value.replace(/[^0-9]+/g,"") != "")
  591. {
  592. save_new_results_time = Number(new_time_display_input.value);
  593. }
  594. if (reward_input.value.replace(/[^0-9]+/g,"") != "")
  595. {
  596. initial_url += "&minReward=" + reward_input.value;
  597. }
  598. else
  599. {
  600. initial_url += "&minReward=0.00";
  601. }
  602. if (qual_input.checked)
  603. {
  604. initial_url += "&qualifiedFor=on"
  605. }
  606. else
  607. {
  608. initial_url += "&qualifiedFor=off"
  609. }
  610. if (masters_input.checked)
  611. {
  612. initial_url += "&requiresMasterQual=on"
  613. }
  614. if (sort_input1.checked)
  615. {
  616. initial_url+= "&sortType=LastUpdatedTime%3A1";
  617. default_type = 0;
  618. }
  619. else if (sort_input2.checked)
  620. {
  621. initial_url+= "&sortType=NumHITs%3A1";
  622. default_type = 1;
  623. }
  624. else if (sort_input3.checked)
  625. {
  626. initial_url+= "&sortType=Reward%3A1";
  627. default_type = 0;
  628. }
  629. initial_url+="&pageNumber=1&searchSpec=HITGroupSearch"
  630. start_it();
  631. }
  632. else
  633. {
  634. global_run = false;
  635. clearTimeout(wait_loop);
  636. big_red_button.textContent = "Start";
  637. set_progress_report("Stopped", true);
  638. }
  639. }
  640.  
  641. function start_it()
  642. {
  643. statusdetail_loop_finished = false;
  644. big_red_button.textContent = "Stop";
  645. found_key_list=[];
  646. var ctime = new Date().getTime()
  647. if (ctime - last_clear_time > save_results_time*666)
  648. {
  649. var last_history=history;
  650. history = {};
  651. for (var key in last_history)
  652. {
  653. if (last_history[key].new_result<save_results_time*1000)
  654. {
  655. history[key]=last_history[key];
  656. if (last_history[key].found_this_time)
  657. {
  658. last_history[key].found_this_time = false;
  659. if (last_history[key].new_result>save_new_results_time*1000)
  660. last_history[key].initial_time = ctime-1000*save_new_results_time;
  661. }
  662. }
  663.  
  664. }
  665. last_clear_time = ctime;
  666. }
  667. next_page = 1;
  668. statusdetail_loop(initial_url);
  669. }
  670.  
  671.  
  672. function show_interface()
  673. {
  674. control_panel.style.color = BROWN;
  675. control_panel.style.fontSize = 14;
  676. control_panel.removeChild(big_red_button);
  677. control_panel.appendChild(document.createTextNode("Auto-refresh delay: "));
  678. time_input.onkeydown = function(event){if (event.keyCode == 13){start_running();}};
  679. time_input.title = "Enter search refresh delay in seconds\n" + "Enter 0 for no auto-refresh\n" + "Default is 0 (no auto-refresh)";
  680. time_input.size = 3;
  681. control_panel.appendChild(time_input);
  682. control_panel.appendChild(document.createTextNode(" "));
  683. control_panel.appendChild(document.createTextNode("Pages to scrape: "));
  684. page_input.onkeydown = function(event){if (event.keyCode == 13){start_running();}};
  685. page_input.title = "Enter number of pages to scrape\n" + "Default is 4";
  686. page_input.size = 3;
  687. control_panel.appendChild(page_input);
  688. control_panel.appendChild(document.createTextNode(" "));
  689. control_panel.appendChild(document.createTextNode("Minimum batch size: "));
  690. min_input.onkeydown = function(event){if (event.keyCode == 13){start_running();}};
  691. min_input.title = "Enter minimum HITs for batch search\n" + "Default is 100";
  692. min_input.size = 3;
  693. control_panel.appendChild(min_input);
  694. control_panel.appendChild(document.createTextNode(" "));
  695. control_panel.appendChild(document.createTextNode("New HIT highlighting: "));
  696. new_time_display_input.onkeydown = function(event){if (event.keyCode == 13){start_running();}};
  697. new_time_display_input.title = "Enter time (in seconds) to keep new HITs highlighted\n" + "Default is 300 (5 minutes)";
  698. new_time_display_input.size = 6;
  699. control_panel.appendChild(new_time_display_input);
  700. control_panel.appendChild(document.createElement("P"));
  701. control_panel.appendChild(document.createTextNode("Minimum reward: "));
  702. reward_input.size = 6;
  703. control_panel.appendChild(reward_input);
  704. control_panel.appendChild(document.createTextNode(" "));
  705.  
  706. control_panel.appendChild(document.createTextNode("Qualified"));
  707. control_panel.appendChild(qual_input);
  708. control_panel.appendChild(document.createTextNode(" "));
  709. control_panel.appendChild(document.createTextNode("Masters"));
  710. control_panel.appendChild(masters_input);
  711. control_panel.appendChild(document.createTextNode(" "));
  712. control_panel.appendChild(document.createTextNode("Sort types: "));
  713. control_panel.appendChild(sort_input1);
  714. control_panel.appendChild(document.createTextNode("Latest"));
  715. control_panel.appendChild(sort_input2);
  716. control_panel.appendChild(document.createTextNode("Most Available"));
  717. control_panel.appendChild(sort_input3);
  718. control_panel.appendChild(document.createTextNode("Amount"));
  719. control_panel.appendChild(document.createElement("P"));
  720. control_panel.appendChild(search_input);
  721. search_input.size = 20;
  722. search_input.title = "Enter a search term to include\n" + "Default is blank (no included terms)";
  723. search_input.placeholder="Enter search terms here";
  724. control_panel.appendChild(document.createTextNode(" "));
  725. big_red_button.textContent = "Start";
  726. big_red_button.onclick = function(){start_running();};
  727. control_panel.appendChild(big_red_button);
  728. control_panel.appendChild(document.createTextNode(" "));
  729. control_panel.appendChild(progress_report);
  730. control_panel.appendChild(document.createElement("P"));
  731. text_area.style.fontWeight = 400;
  732. text_area.createCaption().innerHTML = "HITs";
  733. var col_heads = ['Requester','Title','Reward','HITs Available','TO pay',"Accept HIT"];
  734. var row = text_area.createTHead().insertRow(0);
  735. text_area.caption.style.fontWeight = 800;
  736. text_area.caption.style.color = BROWN;
  737. if (default_text_size > 10)
  738. text_area.cellPadding=Math.min(Math.max(1,Math.floor((default_text_size-10)/2)),5);
  739. console.log(text_area.cellPadding);
  740. //text_area.cellPadding=2;
  741. text_area.caption.style.fontSize = 28;
  742. text_area.rows[0].style.fontWeight = 800;
  743. text_area.rows[0].style.color = BROWN;
  744. for (i=0; i<col_heads.length; i++)
  745. {
  746. var this_cell = row.insertCell(i);
  747. this_cell.innerHTML = col_heads[i];
  748. this_cell.style.fontSize = 14;
  749. if (i > 1)
  750. this_cell.style.textAlign = 'center';
  751. }
  752. control_panel.appendChild(text_area);
  753. }

QingJ © 2025

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