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!

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

QingJ © 2025

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