Advertisement
nomcarver

HIT Scraper

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