mmmturkeybacon Color Coded Search with Checkpoints

Changes the title row of a HIT's description to match the average of it's Turkopticon ratings. Changes the color of the reward amount to match the color of the Turkopticon rating for pay. Adds colored checkboxes to show/hide HITs by color rating. Adds a gray checkbox to show only HITs for which you are not qualified. Changes the background color of the HIT title and link to white for Master's HITs. Changes the color of HITs for which you are not qualified to a darker gray. And more!

目前為 2015-04-18 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name mmmturkeybacon Color Coded Search with Checkpoints
  3. // @author mmmturkeybacon
  4. // @version 3.17
  5. // @namespace http://userscripts.org/users/523367
  6. // @description Changes the title row of a HIT's description to match the average of it's Turkopticon ratings. Changes the color of the reward amount to match the color of the Turkopticon rating for pay. Adds colored checkboxes to show/hide HITs by color rating. Adds a gray checkbox to show only HITs for which you are not qualified. Changes the background color of the HIT title and link to white for Master's HITs. Changes the color of HITs for which you are not qualified to a darker gray. And more!
  7. // Changes the color of visited links to black. Automatically clicks "Show all details". Adds checkboxes next to HIT links so that you can set a checkpoint. A checkpoint will notify you that you've already seen a HIT by changing the HIT link to display the date the checkpoint was set. A well-placed checkpoint is useful when browsing HITs by creation date (newest first) because it will alert you that you've already seen the checkpoint HIT and probably all the HITs that come after it. It's best to place a checkpoint on a HIT that won't be recreated because recreated HITs jump to the first page. This script is not a substitute for actually reading Turkopticon reviews.
  8. // @match https://*.mturk.com/mturk/viewhits*
  9. // @match https://*.mturk.com/mturk/findhits*
  10. // @match https://*.mturk.com/mturk/sorthits*
  11. // @match https://*.mturk.com/mturk/searchbar*
  12. // @match https://*.mturk.com/mturk/viewsearchbar*
  13. // @match https://*.mturk.com/mturk/sortsearchbar*
  14. // @match https://*.mturk.com/mturk/preview?*
  15. // @match https://*.mturk.com/mturk/return*
  16. // @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js
  17. // @grant GM_xmlhttpRequest
  18. // @grant GM_getValue
  19. // @grant GM_setValue
  20. // @grant GM_deleteValue
  21. // @grant GM_addStyle
  22. // ==/UserScript==
  23.  
  24. /**********************************************************************/
  25. /* NB: turkopticon.ucsd.edu (TO website) uses yellow for a rating between 2 and 3,
  26. * but TO extension uses orange
  27. *
  28. * Turkopticon scale
  29. * green : 3 < average <= 5
  30. * orange: 2 < average <= 3
  31. * red : 1 < average <= 2
  32. *
  33. * Color Coded Search scale (so that green represents the very best HITs)
  34. * green : 4 < average <= 5
  35. * yellow: 3 < average <= 4 yellow are OK HITs, that's why the yellow has a touch of green
  36. * orange: 2 < average <= 3
  37. * red : 1 < average <= 2
  38. */
  39. var GREEN = '#66CC66'; // (4,5]
  40. //var YELLOW = '#FFFF00'; // (3,4] yellow
  41. //var YELLOW = '#CDFF2F'; // (3,4] yellow with hint of green
  42. var YELLOW = '#ADFF2F'; // (3,4] green yellow
  43. //var YELLOW = '#9CE62A'; // (3,4] darker green yello
  44. var ORANGE = '#FF9900'; // (2,3]
  45. //var RED = '#FF0000'; // (1,2]
  46. var RED = '#FF3030'; // (1,2]
  47. var BLUE = '#7FAAEB'; // no rating
  48.  
  49. var VISITED_LINK = '#000000'; // black
  50. var MASTERS = '#FFFFFF'; // white
  51. //var MASTERS = '#B56CFF'; // purple
  52.  
  53. var NEW_NOTQUAL_BODY = '#A9AAA4'; // dark grey
  54.  
  55. var COMM_WEIGHT = 1;
  56. var PAY_WEIGHT = 3;
  57. var FAIR_WEIGHT = 3;
  58. var FAST_WEIGHT = 1;
  59.  
  60. var CHECKPOINT_COLOR = '#000000'; // black
  61. //var CHECKPOINT_COLOR = '#00AAAA'; // dark green-blue
  62. var CHECKPOINT_MESSAGE = 'CHECKPOINT REACHED!';
  63. //var CHECKPOINT_MESSAGE = 'YOU SHALL NOT PASS!';
  64.  
  65. var SHOW_ALL_DETAILS = true;
  66.  
  67. /**********************************************************************/
  68.  
  69. //To do: Handle the following error:
  70. //Could Not Connect: (Too many connections)
  71.  
  72. // URLs for testing, learning parameters
  73. //https://turkopticon.ucsd.edu/api/multi-attrs.php?ids=ABSF8UXFZYEK6
  74. //https://mturk-api.istrack.in/multi-attrs.php?ids=ABSF8UXFZYEK6
  75. //https://data.istrack.in/turkopticon.php?data=2.57,2.31,2.89,2.71
  76.  
  77. var TIMEOUT = 10000; // [ms] milliseconds, 0 means wait forever
  78.  
  79. var API_BASE = 'https://turkopticon.ucsd.edu/api/';
  80. var API_MULTI_ATTRS_URL = API_BASE + 'multi-attrs.php?ids=';
  81.  
  82. var API_PROXY_BASE = 'https://mturk-api.istrack.in/';
  83. var API_PROXY_MULTI_ATTRS_URL = API_PROXY_BASE + 'multi-attrs.php?ids=';
  84.  
  85. var REVIEWS_BASE = 'https://turkopticon.ucsd.edu/';
  86. var HIT_GROUPS_BASE_LINK = '/mturk/searchbar?selectedSearchType=hitgroups&requesterId=';
  87.  
  88. var NOTQUAL_BODY = '#F1F3EB';
  89.  
  90. var qual_checkbox;
  91. var notqual_checkbox;
  92. var green_checkbox;
  93. var yellow_checkbox;
  94. var orange_checkbox;
  95. var red_checkbox;
  96. var blue_checkbox;
  97. var $parent_tables;
  98.  
  99. function process_TO_data(requester_data)
  100. {
  101. var average = 0;
  102. var comm_rnd = 0;
  103. var pay_rnd = 0;
  104. var fair_rnd = 0;
  105. var fast_rnd = 0;
  106. var reviews = 0;
  107. var tos = 0;
  108.  
  109. // after the API update, this if isn't necessary. leaving it in until
  110. // sure API is stable
  111. if (requester_data)
  112. {
  113. var comm = requester_data.attrs.comm;
  114. var pay = requester_data.attrs.pay;
  115. var fair = requester_data.attrs.fair;
  116. var fast = requester_data.attrs.fast;
  117. var sum = 0;
  118. var divisor = 0;
  119.  
  120. if (comm > 0)
  121. {
  122. sum += COMM_WEIGHT*comm;
  123. divisor += COMM_WEIGHT;
  124. }
  125. if (pay > 0)
  126. {
  127. sum += PAY_WEIGHT*pay;
  128. divisor += PAY_WEIGHT;
  129. }
  130. if (fair > 0)
  131. {
  132. sum += FAIR_WEIGHT*fair;
  133. divisor += FAIR_WEIGHT;
  134. }
  135. if (fast > 0)
  136. {
  137. sum += FAST_WEIGHT*fast;
  138. divisor += FAST_WEIGHT;
  139. }
  140. if (divisor > 0)
  141. {
  142. average = sum/divisor;
  143. }
  144.  
  145. comm_rnd = Math.round(comm*4)/4;
  146. pay_rnd = Math.round(pay*4)/4;
  147. fair_rnd = Math.round(fair*4)/4;
  148. fast_rnd = Math.round(fast*4)/4;
  149. if (requester_data.reviews)
  150. {
  151. reviews = requester_data.reviews;
  152. }
  153. if (requester_data.tos_flags)
  154. {
  155. tos = requester_data.tos_flags;
  156. }
  157. }
  158.  
  159. comm_rnd = comm_rnd.toFixed(2);
  160. pay_rnd = pay_rnd.toFixed(2);
  161. fair_rnd = fair_rnd.toFixed(2);
  162. fast_rnd = fast_rnd.toFixed(2);
  163.  
  164. return {comm_rnd:comm_rnd, pay_rnd:pay_rnd, fair_rnd:fair_rnd, fast_rnd:fast_rnd, reviews:reviews, tos:tos, average:average};
  165. }
  166.  
  167. function determine_color(rating)
  168. {
  169. // The lowest rating that can be given is a 1.
  170. // green is (4,5]
  171. // yellow is (3,4]
  172. // orange is (2,3]
  173. // red is (1,2]
  174. // blue is 0 (no rating)
  175. // (0,1) is no man's land but I set the lower bound for red to 0 to agree with data.istrack.in
  176.  
  177. var color = BLUE;
  178.  
  179. if (rating > 4)
  180. {
  181. color = GREEN;
  182. }
  183. else if (rating > 3)
  184. {
  185. color = YELLOW;
  186. }
  187. else if (rating > 2 )
  188. {
  189. color = ORANGE;
  190. }
  191. else if (rating > 0)
  192. {
  193. color = RED;
  194. }
  195.  
  196. return color;
  197. }
  198.  
  199. function show_hide_color(color)
  200. {
  201. if (notqual_checkbox.checked == true)
  202. {
  203. var $color_subset_tables = $parent_tables.filter('[title_color='+color+'][qualified_for="false"][hideable!=false]');
  204. }
  205. else
  206. {
  207. var $color_subset_tables = $parent_tables.filter('[title_color='+color+'][hideable!=false]');
  208. }
  209. switch(color)
  210. {
  211. case GREEN:
  212. {
  213. GM_setValue('green_checkbox_checked', green_checkbox.checked);
  214. if (green_checkbox.checked == false)
  215. {
  216. $color_subset_tables.each(function()
  217. {
  218. $(this).hide();
  219. });
  220. }
  221. else
  222. {
  223. $color_subset_tables.each(function()
  224. {
  225. $(this).show();
  226. });
  227. }
  228. break;
  229. }
  230. case YELLOW:
  231. {
  232. GM_setValue('yellow_checkbox_checked', yellow_checkbox.checked);
  233. if (yellow_checkbox.checked == false)
  234. {
  235. $color_subset_tables.each(function()
  236. {
  237. $(this).hide();
  238. });
  239. }
  240. else
  241. {
  242. $color_subset_tables.each(function()
  243. {
  244. $(this).show();
  245. });
  246. }
  247. break;
  248. }
  249. case ORANGE:
  250. {
  251. GM_setValue('orange_checkbox_checked', orange_checkbox.checked);
  252. if (orange_checkbox.checked == false)
  253. {
  254. $color_subset_tables.each(function()
  255. {
  256. $(this).hide();
  257. });
  258. }
  259. else
  260. {
  261. $color_subset_tables.each(function()
  262. {
  263. $(this).show();
  264. });
  265. }
  266. break;
  267. }
  268. case RED:
  269. {
  270. GM_setValue('red_checkbox_checked', red_checkbox.checked);
  271. if (red_checkbox.checked == false)
  272. {
  273. $color_subset_tables.each(function()
  274. {
  275. $(this).hide();
  276. });
  277. }
  278. else
  279. {
  280. $color_subset_tables.each(function()
  281. {
  282. $(this).show();
  283. });
  284. }
  285. break;
  286. }
  287. case BLUE:
  288. {
  289. GM_setValue('blue_checkbox_checked', blue_checkbox.checked);
  290. if (blue_checkbox.checked == false)
  291. {
  292. $color_subset_tables.each(function()
  293. {
  294. $(this).hide();
  295. });
  296. }
  297. else
  298. {
  299. $color_subset_tables.each(function()
  300. {
  301. $(this).show();
  302. });
  303. }
  304. break;
  305. }
  306. }
  307. }
  308.  
  309. function show_hide_all_colors()
  310. {
  311. show_hide_color(GREEN);
  312. show_hide_color(YELLOW);
  313. show_hide_color(ORANGE);
  314. show_hide_color(RED);
  315. show_hide_color(BLUE);
  316. }
  317.  
  318. function show_hide_qual()
  319. {
  320. GM_setValue('notqual_checkbox_checked', notqual_checkbox.checked);
  321. if (notqual_checkbox.checked == true)
  322. {
  323. $parent_tables.filter('[qualified_for="true"][hideable!=false]').each(function()
  324. {
  325. $(this).hide();
  326. });
  327. }
  328. else
  329. {
  330. show_hide_all_colors();
  331. }
  332. }
  333.  
  334. function set_checkpoint(e)
  335. {
  336. var caller = e.target || e.srcElement;
  337.  
  338. if (caller.checked)
  339. {
  340. var d = new Date();
  341. GM_setValue(caller.name+'_checked', caller.checked);
  342. GM_setValue(caller.name+'_date', '['+d.toLocaleDateString()+'] ');
  343. }
  344. else
  345. {
  346. GM_deleteValue(caller.name+'_checked');
  347. GM_deleteValue(caller.name+'_date');
  348. }
  349. }
  350.  
  351. function create_colored_checkboxes()
  352. {
  353. var checkbox_div = document.createElement('DIV');
  354. var notqual_div = document.createElement('DIV');
  355. var green_div = document.createElement('DIV');
  356. var yellow_div = document.createElement('DIV');
  357. var orange_div = document.createElement('DIV');
  358. var red_div = document.createElement('DIV');
  359. var blue_div = document.createElement('DIV');
  360. notqual_div.style.cssText = 'display:inline-block; background-color: '+NEW_NOTQUAL_BODY+';'
  361. green_div.style.cssText = 'display:inline-block; background-color: '+GREEN+';'
  362. yellow_div.style.cssText = 'display:inline-block; background-color: '+YELLOW+';'
  363. orange_div.style.cssText = 'display:inline-block; background-color: '+ORANGE+';'
  364. red_div.style.cssText = 'display:inline-block; background-color: '+RED+';'
  365. blue_div.style.cssText = 'display:inline-block; background-color: '+BLUE+';'
  366.  
  367. notqual_checkbox = document.createElement('INPUT');
  368. green_checkbox = document.createElement('INPUT');
  369. yellow_checkbox = document.createElement('INPUT');
  370. orange_checkbox = document.createElement('INPUT');
  371. red_checkbox = document.createElement('INPUT');
  372. blue_checkbox = document.createElement('INPUT');
  373. notqual_checkbox.type = 'checkbox';
  374. green_checkbox.type = 'checkbox';
  375. yellow_checkbox.type = 'checkbox';
  376. orange_checkbox.type = 'checkbox';
  377. red_checkbox.type = 'checkbox';
  378. blue_checkbox.type = 'checkbox';
  379. notqual_checkbox.checked = GM_getValue('notqual_checkbox_checked', false);
  380. green_checkbox.checked = GM_getValue('green_checkbox_checked', true);
  381. yellow_checkbox.checked = GM_getValue('yellow_checkbox_checked', true);
  382. orange_checkbox.checked = GM_getValue('orange_checkbox_checked', true);
  383. red_checkbox.checked = GM_getValue('red_checkbox_checked', true);
  384. blue_checkbox.checked = GM_getValue('blue_checkbox_checked', true);
  385. notqual_checkbox.name = 'notqual_checkbox';
  386. green_checkbox.name = 'green_checkbox';
  387. yellow_checkbox.name = 'yellow_checkbox';
  388. orange_checkbox.name = 'orange_checkbox';
  389. red_checkbox.name = 'red_checkbox';
  390. blue_checkbox.name = 'blue_checkbox';
  391. notqual_checkbox.title = 'Only show HITs for which you are not qualified';
  392. green_checkbox.title = 'Show/Hide green';
  393. yellow_checkbox.title = 'Show/Hide yellow';
  394. orange_checkbox.title = 'Show/Hide orange';
  395. red_checkbox.title = 'Show/Hide red';
  396. blue_checkbox.title = 'Show/Hide no TO';
  397. notqual_checkbox.addEventListener('click', show_hide_qual);
  398. green_checkbox.addEventListener('click', function(){show_hide_color(GREEN);});
  399. yellow_checkbox.addEventListener('click', function(){show_hide_color(YELLOW);});
  400. orange_checkbox.addEventListener('click', function(){show_hide_color(ORANGE);});
  401. red_checkbox.addEventListener('click', function(){show_hide_color(RED);});
  402. blue_checkbox.addEventListener('click', function(){show_hide_color(BLUE);});
  403.  
  404. notqual_div.appendChild(notqual_checkbox);
  405. green_div.appendChild(green_checkbox);
  406. yellow_div.appendChild(yellow_checkbox);
  407. orange_div.appendChild(orange_checkbox);
  408. red_div.appendChild(red_checkbox);
  409. blue_div.appendChild(blue_checkbox);
  410. checkbox_div.align = 'center';
  411. checkbox_div.appendChild(notqual_div);
  412. checkbox_div.appendChild(green_div);
  413. checkbox_div.appendChild(yellow_div);
  414. checkbox_div.appendChild(orange_div);
  415. checkbox_div.appendChild(red_div);
  416. checkbox_div.appendChild(blue_div);
  417. return checkbox_div;
  418. }
  419.  
  420.  
  421. function turkopticon_error_handler($parent_tables, api_base, requester_IDs_csv)
  422. {
  423. if (api_base == API_MULTI_ATTRS_URL)
  424. { // tried main api server and failed, now try mirror
  425. color_code($parent_tables, API_PROXY_MULTI_ATTRS_URL, requester_IDs_csv);
  426. }
  427. else
  428. {
  429. $parent_tables.each(function()
  430. {
  431. var $requester_ID_link = $(this).find('a[href^="'+HIT_GROUPS_BASE_LINK+'"]').attr('href');
  432. var requester_ID = $requester_ID_link.replace(HIT_GROUPS_BASE_LINK,'');
  433. var title_row = $(this).find('tr').eq(1);
  434. var link_bgcolor = $(this).find('td[width="100%"][valign="middle"][height="20"][align="left"]').attr('bgcolor');
  435.  
  436. var link_href = REVIEWS_BASE + requester_ID;
  437. var link_text = 'Turkopticon reviews';
  438. var link = '<a href="'+link_href+'" target="_blank">'+link_text+'</a>&nbsp;';
  439. title_row.after('<tr><td width="1" valign="middle" bgcolor="#336699" align="center"></td><td width="18" valign="middle" bgcolor="'+link_bgcolor+'" align="center"></td><td width="100%" valign="top" bgcolor="'+link_bgcolor+'" align="right">'+link+'</td><td width="8" valign="middle" bgcolor="'+link_bgcolor+'" align="center"></td><td width="1" valign="middle" bgcolor="#336699" align="center"></td></tr>');
  440.  
  441. // create checkpoints
  442. var $preview_link = $(this).find('a:contains("View a HIT in this group")');
  443. var groupId = $preview_link.attr('href')
  444. groupId = (groupId) ? groupId.split('=')[1] : $(this).find('a[href^="/mturk/notqualified?hitGroupId="]').attr('href').split(/=|&/)[1];
  445. var checkbox = document.createElement('INPUT');
  446. checkbox.type = 'checkbox';
  447. checkbox.name = groupId;
  448. checkbox.title = 'Set a checkpoint to help remember a HIT you\'ve seen before.\nUseful when browsing by HIT Creation Date.';
  449. checkbox.checked = GM_getValue(checkbox.name+'_checked', false);
  450. checkbox.addEventListener('click', set_checkpoint);
  451. checkbox.style.cssText ='vertical-align:middle;';
  452. $preview_link.after(checkbox);
  453. // mark checkpoints
  454. if (checkbox.checked == true)
  455. {
  456. var checkpoint_date = GM_getValue(checkbox.name+'_date');
  457. $preview_link.text(checkpoint_date+CHECKPOINT_MESSAGE);
  458. $(this).attr('hideable', false);
  459. $(this).css('border', '50px solid '+CHECKPOINT_COLOR);
  460. }
  461. });
  462. }
  463. }
  464.  
  465.  
  466. function color_code($parent_tables, api_base, requester_IDs_csv)
  467. {
  468. GM_xmlhttpRequest(
  469. {
  470. method: 'GET',
  471. url: api_base+requester_IDs_csv,
  472. timeout: TIMEOUT,
  473. onload: function (results)
  474. {
  475. if (results)
  476. {
  477. try
  478. {
  479. var rdata = $.parseJSON(results.responseText);
  480. }
  481. catch(e)
  482. {
  483. turkopticon_error_handler($parent_tables, api_base, requester_IDs_csv)
  484. }
  485. }
  486.  
  487. var rdata = $.parseJSON(results.responseText);
  488.  
  489. var checkbox_div = create_colored_checkboxes();
  490. $('table[cellspacing="0"][cellpadding="0"][border="0"][style="margin:5px; clear:both;"]').eq(1).after(checkbox_div);
  491.  
  492. $parent_tables.each(function()
  493. {
  494. var $requester_ID_link = $(this).find('a[href^="'+HIT_GROUPS_BASE_LINK+'"]').attr('href');
  495. var requester_ID = $requester_ID_link.replace(HIT_GROUPS_BASE_LINK,'');
  496. var title_row = $(this).find('tr').eq(1);
  497. var link_bgcolor = $(this).find('td[width="100%"][valign="middle"][height="20"][align="left"]').attr('bgcolor');
  498.  
  499. var pdata = process_TO_data(rdata[requester_ID]);
  500. var title_color = determine_color(pdata.average);
  501. var qualified_for = !($(this).find('a[href^="/mturk/notqualified?"]').length > 0);
  502.  
  503. $(this).attr('title_color', title_color);
  504. $(this).attr('qualified_for', qualified_for);
  505.  
  506. //var $title_line = $(this).find('td[width="100%"][valign="middle"][height="20"][align="left"]');
  507. //$title_line.css('background-color', title_color);
  508. $(this).find('td[valign="middle"][nowrap=""][align="left"]').css('background-color', title_color);
  509. $(this).find('td[valign="middle"][align="left"]').css('background-color', title_color);
  510. $(this).find('td[width="100%"][valign="middle"][nowrap=""][align="right"]').css('background-color', title_color);
  511. //$(this).find('a[href^="/mturk/preview?groupId="]').css('background-color', link_bgcolor);
  512.  
  513. var link_href = REVIEWS_BASE + requester_ID;
  514. var link_text = pdata.reviews + ((pdata.reviews != 1) ? ' reviews ' : ' review ');
  515. //link_text = '['+link_text + '|comm: '+pdata.comm_rnd+'|pay: '+pdata.pay_rnd+'|fair: '+pdata.fair_rnd+'|fast: '+pdata.fast_rnd+'|tos: '+pdata.tos+']';
  516. link_text = '['+link_text + '|pay: '+pdata.pay_rnd+'|fair: '+pdata.fair_rnd+'|comm: '+pdata.comm_rnd+'|fast: '+pdata.fast_rnd+'|tos: '+pdata.tos+']';
  517. var link = '<a href="'+link_href+'" target="_blank">'+link_text+'</a>&nbsp;';
  518. title_row.after('<tr><td width="1" valign="middle" bgcolor="#336699" align="center"></td><td width="18" valign="middle" bgcolor="'+link_bgcolor+'" align="center"></td><td width="100%" valign="top" bgcolor="'+title_color+'" align="right">'+link+'</td><td width="8" valign="middle" bgcolor="'+link_bgcolor+'" align="center"></td><td width="1" valign="middle" bgcolor="#336699" align="center"></td></tr>');
  519.  
  520. // after the API update, this if isn't necessary. leaving it in until
  521. // sure API is stable
  522. var pay = 0;
  523. if (rdata[requester_ID])
  524. {
  525. pay = rdata[requester_ID].attrs.pay;
  526. }
  527. var pay_color = determine_color(pay);
  528. //var pay_color = determine_color(rdata[requester_ID].attrs.pay);
  529. $(this).find('span[class="reward"]').css('background-color', pay_color);
  530.  
  531. // highlight Masters HITs title and link
  532. var is_masters = $(this).find('td[style="padding-right: 2em; white-space: nowrap;"]:contains("Masters")').length > 0;
  533. if (is_masters)
  534. {
  535. $(this).find('td[valign="middle"][nowrap=""][align="left"]').css('background-color', MASTERS);
  536. $(this).find('a[href^="/mturk/preview?groupId="]').css('background-color', MASTERS);
  537. }
  538.  
  539. // create checkpoints
  540. var $preview_link = $(this).find('a:contains("View a HIT in this group")');
  541. //var $preview_link = $(this).find('span[class="capsulelink"] > a');
  542. var groupId = $preview_link.attr('href')
  543. groupId = (groupId) ? groupId.split('=')[1] : $(this).find('a[href^="/mturk/notqualified?hitGroupId="]').attr('href').split(/=|&/)[1];
  544. var checkbox = document.createElement('INPUT');
  545. checkbox.type = 'checkbox';
  546. checkbox.name = groupId;
  547. checkbox.title = 'Set a checkpoint to help remember a HIT you\'ve seen before.\nUseful when browsing by HIT Creation Date.';
  548. checkbox.checked = GM_getValue(checkbox.name+'_checked', false);
  549. checkbox.addEventListener('click', set_checkpoint);
  550. checkbox.style.cssText ='vertical-align:middle;';
  551. $preview_link.after(checkbox);
  552. // mark checkpoints
  553. if (checkbox.checked == true)
  554. {
  555. var checkpoint_date = GM_getValue(checkbox.name+'_date');
  556. $preview_link.text(checkpoint_date+CHECKPOINT_MESSAGE);
  557. $(this).attr('hideable', false);
  558. $(this).css('border', '50px solid '+CHECKPOINT_COLOR);
  559. }
  560. });
  561. show_hide_all_colors();
  562. show_hide_qual();
  563. },
  564. ontimeout: function()
  565. {
  566. turkopticon_error_handler($parent_tables, api_base, requester_IDs_csv)
  567. },
  568. onerror: function()
  569. {
  570. turkopticon_error_handler($parent_tables, api_base, requester_IDs_csv)
  571. }
  572. });
  573. }
  574.  
  575. //$(document).ready(function()
  576. //{
  577. var is_HIT = $('input[type="hidden"][name="isAccepted"]').length > 0;
  578. if (is_HIT)
  579. {
  580. throw new Error('Not on a search page. Exit.');
  581. }
  582.  
  583. GM_addStyle('a:visited {color: '+VISITED_LINK+';}');
  584.  
  585. if (SHOW_ALL_DETAILS)
  586. {
  587. // click 'Show all details'
  588. $(window).load(function(){$('a[id="expandall"][class="footer_links"][href="#"]:contains("Show all details")').get(0).click();});
  589. }
  590.  
  591. // change color of HITs not qualified for to make it easier to differentiate
  592. $('[bgcolor="'+NOTQUAL_BODY+'"]').each(function(){
  593. $(this).attr('bgcolor',$(this).attr('bgcolor').replace(NOTQUAL_BODY, NEW_NOTQUAL_BODY));
  594. });
  595.  
  596. var requester_IDs = new Array();
  597. $parent_tables = $('table[width="100%"][cellspacing="0"][cellpadding="0"][border="0"][height="100%"]');
  598. $parent_tables.each(function()
  599. {
  600. var $requester_ID_link = $(this).find('a[href^="'+HIT_GROUPS_BASE_LINK+'"]').attr('href');
  601. requester_IDs.push($requester_ID_link.replace(HIT_GROUPS_BASE_LINK,''));
  602. });
  603.  
  604. // code snippet from http://stackoverflow.com/questions/5381621/jquery-function-to-get-all-unique-elements-from-an-array
  605. requester_IDs = requester_IDs.filter(function(itm,i,a)
  606. {
  607. return i==a.indexOf(itm);
  608. });
  609. // end snippet
  610.  
  611. var requester_IDs_csv = '';
  612. for (var i = 0; i < requester_IDs.length-1; i++)
  613. {
  614. requester_IDs_csv += requester_IDs[i] + ','
  615. }
  616. requester_IDs_csv += requester_IDs[i];
  617.  
  618. color_code($parent_tables, API_MULTI_ATTRS_URL, requester_IDs_csv);
  619. //});