HIT Forker

Monitors mturk.com for HITs

目前为 2018-02-08 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name HIT Forker
  3. // @version 0.6.4
  4. // @description Monitors mturk.com for HITs
  5. // @author ThisPoorGuy
  6. // @icon http://nopurpose.org/stuff/avatars/Lj21396.gif
  7. // @include https://worker.mturk.com/?finder_beta
  8. // @include https://worker.mturk.com/?hit_forker
  9. // @grant GM_log
  10. // @grant GM_setClipboard
  11. // @grant GM_xmlhttpRequest
  12. // @connect turkerview.com
  13. // @require https://code.jquery.com/jquery-3.1.0.min.js
  14.  
  15. // @namespace https://gf.qytechs.cn/users/163167
  16. // ==/UserScript==
  17.  
  18. // Acknowledgements
  19. // The core of this script was forked/stolen/adapted from Kadauchi's Hit Finder Beta script. Coding assistance in spots
  20. // provided by Salem Beats and ChrisTurk. TurkerView was created by ChrisTurk. This script hooks into JR Panda Crazy
  21.  
  22. // Changelog
  23. // 0.6.4 - Send RequesterID over to PandaCrazy along with the other info.
  24. // 0.6.3 - Bringing PC functionality in house
  25. // 0.6.1 - Fixed panda button shading
  26. // 0.6.0 - Re-jiggered panda crazy integration code to use Salem's PC library. Now detects if panda crazy is actually running when you click.
  27. // 0.5.3 - Slight modifications to break integration with JR Panda Crazy, due to a memory leak issue. Will reach out to dev to see if we can clear it up and be happy together...
  28. // 0.5.2 - Code cleanup.
  29. // 0.5.1 - Fixed the panda buttons on the Found hits table.
  30. // 0.5.0 - Hitting the panda button now sends full HIT name, pay and requester name info to panda crazy too. Have you noticed these version number leaps are pretty arbitratry?
  31. // - Fixed a stupid typo in a variable name.
  32. // 0.4.3 - Switched TO request from a .get call to a .ajax call with a timeout to prevent the entire thing from exploding when TO's servers do.
  33. // 0.4.2 - Link to TV Requester profile in export.
  34. // 0.4.1 - Show/Hide HITs and Logged Hits settings are now saved across sessions
  35. // 0.4.0 - Blocking a HIT or a Requester will now remove that Hit or all hits from said requester from display in the Hit Log
  36. // 0.3.5 - Added a button to hide the new HITS table. Moved the button to hide the logged hits for consistancy.
  37. // 0.3.2 - Modified icon for desktop notifications. Added Requester TV score to hit export
  38. // 0.3.1 - Fix for amazon screwing with things. Thanks ChrisTurk!
  39. // 0.3.0 - Under the hood changes, removed code for running on www, added new launch URL, old ?finder_beta will be phased out eventually
  40. // 0.2.9 - Now acceptable to people with red/green color blindness!
  41. // 0.2.6 - Fixed a minor error which caused colors to not work properly.
  42. // 0.2.5 - Changed Coloration to respect TV reviews FIRST and then fall back on TO Values. Also changed colors.
  43. // 0.2.0 - Added TurkerView Hourly ratings to HIT results, fixed export links.
  44. // 0.1.5 - Some minor UI tweaks
  45. // 0.1.4 - Added some indication that you have already clicked a button to send HIT to PC. Only works in log currently.
  46. // 0.1.3 - Fixed issue with the Panda buttons in the HIT log not having the right GID
  47. // 0.1.2 - Fixed an issue with HITs that have double quotes in the title not working with the ignore hit by title button. I think.
  48. // 0.1.1 - Cleaned up the header, removed unused audio files
  49. // 0.1.0 - Made modifications to launch links with worker website. Added buttons to send information to PandaCrazy directly instead of copying link
  50. // TODO:
  51. // Remove www code
  52. // Clean up interface
  53. // Delete the above todos because they're already done.
  54.  
  55. var worker = true;
  56.  
  57. var _config = JSON.parse(localStorage.getItem('_finder')) || {};
  58. var blocklist = JSON.parse(localStorage.getItem('_finder_bl')) || {};
  59. var includelist = JSON.parse(localStorage.getItem('_finder_il')) || {};
  60.  
  61. // Compatability check
  62. if (_config.version !== '1.1') { _config = {}; }
  63.  
  64. var config = {
  65. version : _config.version || '1.1',
  66. delay : _config.delay || '3',
  67. type : _config.type || 'LastUpdatedTime%3A1&pageSize=',
  68. size : _config.size || '25',
  69. rew : _config.rew || '0.00',
  70. avail : _config.avail || '0',
  71. mto : _config.mto || '0.00',
  72. alert : _config.alert || '0',
  73. qual : _config.hasOwnProperty('qual') ? _config.qual : true,
  74. new : _config.hasOwnProperty('new') ? _config.new : true,
  75. newaudio : _config.newaudio || 'beep',
  76. pb : _config.hasOwnProperty('pb') ? _config.pb : false,
  77. to : _config.hasOwnProperty('to') ? _config.to : true,
  78. nl : _config.hasOwnProperty('nl') ? _config.nl : false,
  79. bl : _config.hasOwnProperty('bl') ? _config.bl : false,
  80. m : _config.hasOwnProperty('m') ? _config.m : false,
  81. push : _config.push || 'access_token_here',
  82. theme : _config.theme || 'default',
  83. custom : _config.custom || {main: 'FFFFFF', primary: 'CCCCCC', secondary: '111111', text: '000000', link: '0000EE', visited: '551A8B', prop : false},
  84. to_theme : _config.to_theme || '1',
  85. h_hidden : _config.h_hidden || '0',
  86. l_hidden : _config.l_hidden || '0'
  87. };
  88.  
  89. var themes = {
  90. 'default' : {main: 'FFFFFF', primary: 'CCCCCC', secondary: '111111', menu: '373b44', menutext: 'FFFFFF', text: '000000', link: '0000EE', visited: '551A8B', prop : true},
  91. 'light' : {main: 'FFFFFF', primary: 'CCCCCC', secondary: '111111', menu: '373b44', menutext: 'FFFFFF', text: '000000', link: '0000EE', visited: '551A8B', prop : true},
  92. 'dark' : {main: '404040', primary: '666666', secondary: 'FFFFFF', menu: '202020', menutext: 'FFFFFF', text: 'FFFFFF', link: 'FFFFFF', visited: 'B3B3B3', prop : true},
  93. 'darker' : {main: '000000', primary: '262626', secondary: 'FFFFFF', menu: '373b44', menutext: 'FFFFFF', text: 'FFFFFF', link: 'FFFFFF', visited: 'B3B3B3', prop : true},
  94. 'custom' : config.custom
  95. };
  96.  
  97. var turkerview = { };
  98. var turkerview_update = 0;
  99.  
  100. var searches = 0,
  101. logged = 0,
  102. hitlog = {},
  103. noti_delay = [],
  104. push_delay = [];
  105.  
  106. // General Configuration variables
  107. var url, upd, num, rew, minrew, searchqual, pandaurl;
  108.  
  109. url = 'https://worker.mturk.com/?';
  110. pandaurl = 'https://worker.mturk.com';
  111. upd = '&sort=updated_desc&page_size=';
  112. num = '&sort=num_hits_desc&page_size=';
  113. rew = '&sort=reward_desc&page_size=';
  114. minrew = '&filters%5Bmin_reward%5D=';
  115. searchqual = '&filters%5Bqualified=';
  116.  
  117. var PandaCrazy = (function createPandaCrazy() {
  118. let _self = this;
  119.  
  120. let _lastSentPingTime;
  121. let _lastReceivedPongTime;
  122.  
  123. let _onlineSinceLastPing;
  124.  
  125. let _pcListener;
  126.  
  127. const MAX_WAIT_FOR_PANDA_CRAZY_RESPONSE_MS = 1000;
  128.  
  129. function ping() {
  130. _lastSentPingTime = Date.now();
  131. localStorage.setItem("JR_message_ping_pandacrazy", `{"theTarget": "${Math.random()}"}`);
  132. }
  133.  
  134. function hasIndicatedOnlineSinceLastPing() {
  135. if(_lastSentPingTime !== undefined && _lastReceivedPongTime !== undefined) {
  136. return _lastReceivedPongTime >= _lastSentPingTime;
  137. }
  138. else {
  139. return undefined;
  140. }
  141. }
  142.  
  143. function online() {
  144.  
  145. function respondToStorage(resolve, reject, e) {
  146. if(e.key.includes("JR_message_pong") && Boolean(e.newValue)) {
  147.  
  148. _lastReceivedPongTime = Date.now();
  149.  
  150. let pongData = JSON.parse(e.newValue);
  151.  
  152. let lag = Number(pongData.time) - Number(_lastReceivedPongTime);
  153.  
  154. if(hasIndicatedOnlineSinceLastPing()) {
  155. resolve("online");
  156. }
  157. }
  158. }
  159.  
  160. let isOnlinePromise = new Promise((resolve, reject) => {
  161.  
  162. setTimeout(() => {reject("timeout");}, MAX_WAIT_FOR_PANDA_CRAZY_RESPONSE_MS);
  163.  
  164. if(_pcListener) {window.removeEventListener("storage", _pcListener);}
  165.  
  166. _pcListener = respondToStorage.bind(window, resolve, reject);
  167.  
  168. window.addEventListener("storage", _pcListener);
  169.  
  170. /*
  171. window.addEventListener("storage", e => {
  172.  
  173. // console.log("Storage Event", e);
  174.  
  175. if(e.key.includes("JR_message_pong") && Boolean(e.newValue)) {
  176.  
  177. _lastReceivedPongTime = Date.now();
  178.  
  179. let pongData = JSON.parse(e.newValue);
  180.  
  181. let lag = Number(pongData.time) - Number(_lastReceivedPongTime);
  182.  
  183. if(hasIndicatedOnlineSinceLastPing()) {
  184. resolve("online");
  185. }
  186. }
  187. });
  188. */
  189. });
  190.  
  191. ping();
  192.  
  193. return isOnlinePromise;
  194. }
  195.  
  196. function addJob(gid, once, metadata) {
  197. let commandString = once ? "addOnceJob" : "addJob";
  198.  
  199. localStorage.setItem("JR_message_pandacrazy", JSON.stringify({
  200. time: Date.now(),
  201. command: commandString,
  202. data: {
  203. groupId: gid,
  204. title: (metadata ? metadata.hitTitle || metadata.title : undefined),
  205. requesterName: (metadata ? metadata.requesterName : undefined),
  206. requesterId: (metadata ? metadata.requesterID || metadata.requesterId || metadata.rid : undefined),
  207. pay: (metadata ? metadata.hitValue || metadata.pay : undefined),
  208. duration: (metadata ? metadata.duration : undefined),
  209. hitsAvailable: (metadata ? metadata.hitsAvailable : undefined)
  210. }
  211. }));
  212. }
  213.  
  214. function startJob(gid) {
  215. localStorage.setItem("JR_message_pandacrazy", JSON.stringify({
  216. time: Date.now(),
  217. command: "startcollect",
  218. data: {
  219. groupId: gid
  220. }
  221. }));
  222. }
  223.  
  224. return {
  225. addJob,
  226. startJob,
  227. ping,
  228. online
  229. };
  230. })();
  231.  
  232. $('head').html(
  233. '<title>HIT Forker</title>' +
  234. '<link rel="icon" type="image/jpg" href="http://nopurpose.org/stuff/avatars/Lj21396.gif">' +
  235. '<base target="_blank">' +
  236.  
  237. '<audio id="audio_1"><source src="http://www.soundjay.com/button/sounds/button-1.mp3" type="audio/mpeg"></audio>' +
  238. '<audio id="audio_2"><source src="http://www.soundjay.com/button/sounds/button-3.mp3" type="audio/mpeg"></audio>' +
  239. '<audio id="audio_3"><source src="http://www.soundjay.com/button/sounds/button-4.mp3" type="audio/mpeg"></audio>' +
  240. '<audio id="audio_4"><source src="http://www.soundjay.com/button/sounds/button-5.mp3" type="audio/mpeg"></audio>' +
  241. '<audio id="audio_beep"><source src="http://www.soundjay.com/button/sounds/beep-21.mp3" type="audio/mpeg"></audio>' +
  242. '<audio id="audio_beepbeep"><source src="http://www.soundjay.com/button/sounds/beep-24.mp3" type="audio/mpeg"></audio>' +
  243. '<audio id="audio_click"><source src="http://www.soundjay.com/button/sounds/button-20.mp3" type="audio/mpeg"></audio>' +
  244.  
  245. '<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">' +
  246. '<style id="css" type="text/css">'
  247. );
  248.  
  249. $('body').html(
  250. // Main
  251. '<div style="margin-bottom: 5px; text-align:right;" id="menubar">' +
  252. '<div style="position: absolute; top: 32px width: 100px; font-size: 14pt; font-weight: bold;" id="menu_title">HIT Forker</div>'+
  253. '<div style="line-height: 30px; margin-right:5px;">'+
  254. '<button id="scan_button" style="margin-right: 5px;">Start</button>' +
  255. '<button id="bloc_button" style="margin-right: 5px;">Block List</button>' +
  256. '<button id="incl_button" style="margin-right: 5px;">Include List</button>' +
  257. '<button id="sett_button" style="margin-right: 5px;">Advanced Settings</button>' +
  258. '<button id="conf_button" style="margin-right: 5px;">Show Config</button>' +
  259.  
  260. '</div></div>' +
  261.  
  262. // Config
  263. '<div id="config" style="position: absolute; top: 37px; right: 5px; margin-bottom: 5px;" class="hidden">' +
  264.  
  265. '<div style="margin-bottom: 5px;">' +
  266. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;" title="Delay in seconds between searches.">Search Delay: ' +
  267. '<input id="delay" style="width: 50px;" type="number" step="1" min="1" value="' + config.delay + '">' +
  268. '</label>' +
  269.  
  270. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;" title="Filter HITs by minimum reward.">Min Reward: ' +
  271. '<input id="min_rew" style="width: 50px;" type="number" step="0.01" min="0" value="' + config.rew + '">' +
  272. '</label>' +
  273.  
  274. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;" title="Filter HITs by minimum available.">Min Avail: ' +
  275. '<input id="min_avail" style="width: 50px;" type="number" step="1" min="0" value="' + config.avail + '">' +
  276. '</label>' +
  277.  
  278. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;" title="Filter HITs by minimum TO pay.">Min TO: ' +
  279. '<input id="min_to" style="width: 50px;" type="number" step="0.1" min="0" max="5" value="' + config.mto + '">' +
  280. '</label>' +
  281.  
  282. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;" title="Search for this many HITs.">Size: ' +
  283. '<input id="size" style="width: 50px;" type="number" step="1" min="1" max="100" value="' + config.size + '">' +
  284. '</label>' +
  285.  
  286. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;" title="Sort HITs by (Latest / Most Available / Highest Reward)">Sort by: ' +
  287. '<select id="type" value="' + config.type + '">' +
  288. '<option value="' + upd + '">Latest</option>' +
  289. '<option value="' + num + '">Most Available</option>' +
  290. '<option value="' + rew + '">Reward (Most)</option>' +
  291. '</select>' +
  292. '</label>' +
  293.  
  294. '<label style="margin-right: 0px; display: inline-block; border-bottom: 1px solid;" title="Only show HITs that you are for.">Qualified' +
  295. '<input id="qual" type="checkbox" ' + (config.qual ? 'checked' : '') + '>' +
  296. '</label>' +
  297. '</div>' +
  298.  
  299. '<div style="margin-bottom: 5px;">' +
  300. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;" title="Delay in seconds between desktop notifications and sound alerts for an include list match.">Alert Delay: ' +
  301. '<input id="alert_delay" style="width: 50px;" type="number" step="1" min="0" value="' + config.alert + '">' +
  302. '</label>' +
  303.  
  304. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;" title="Make a sound when a new HIT is found.">Sound On New HIT ' +
  305. '<input id="new_sound" type="checkbox" ' + (config.new ? 'checked' : '') + '>' +
  306. '<select id="new_audio" value="' + config.newaudio + '">' +
  307. //'<option value="default">Default</option>' +
  308. '<option value="beep">Beep</option>' +
  309. '<option value="beepbeep">Beep Beep</option>' +
  310. //'<option value="ding">Ding</option>' +
  311. //'<option value="squee">Squee</option>' +
  312. '<option value="click">Click</option>' +
  313. '</select>' +
  314. '</label>' +
  315.  
  316. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;" title="Allow inludelist matches to send Pushbullet notifications if enabled for that match.">Pushbullet ' +
  317. '<input id="pb" type="checkbox" ' + (config.pb ? 'checked' : '') + '>' +
  318. '</label>' +
  319.  
  320. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;" title="Use turkopticon.">Enable TO ' +
  321. '<input id="to" type="checkbox" ' + (config.to ? 'checked' : '') + '>' +
  322. '</label>' +
  323.  
  324. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;" title="Hide all HITs that do not match your include list.">Hide Non Include List ' +
  325. '<input id="nl_hide" type="checkbox" ' + (config.nl ? 'checked' : '') + '>' +
  326. '</label>' +
  327.  
  328. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;" title="Hide HITs that match your block list.">Hide Block List ' +
  329. '<input id="bl_hide" type="checkbox" ' + (config.bl ? 'checked' : '') + '>' +
  330. '</label>' +
  331.  
  332. '<label style="margin-right: 0px; display: inline-block; border-bottom: 1px solid;" title="Hide masters HITs.">Hide Masters ' +
  333. '<input id="m_hide" type="checkbox" ' + (config.m ? 'checked' : '') + '>' +
  334. '</label>' +
  335. '</div>' +
  336.  
  337. '</div>' +
  338.  
  339. // HITs
  340. '<div id="latest_hits">' +
  341. '<div style="border-bottom: 3px solid; margin-bottom: 5px;">' +
  342. '<span style="font-size: 20px; font-weight: bold;">HITs</span>' +
  343. '<span id="hits_data" style="font-size: 11px;"></span>' +
  344. '<span id="hits_controls" style="float: right"><button id="hits_button" style="margin-right: 5px;">Hide New HITs</button></span>' +
  345. '</div>' +
  346. '<div id="hits_hidden" style="text-align: center; display: none;">--- HITS HIDDEN ---</div>' +
  347. '<div id="hits_table">' +
  348. '<div>' +
  349. '<div style="overflow: hidden; white-space: nowrap;">' +
  350. '<div style="float: left; width: calc(100% - 330px);">' +
  351. '<span style="width: 34%; float: left; display:inline-block; overflow: hidden;">Requester</span>' +
  352. '<span style="width: 64%; float: right; display:inline-block; overflow: hidden;">Project</span>' +
  353. '</div>' +
  354.  
  355. '<div style="float: right;">' +
  356. '<span style="width: 60px; display:inline-block; text-align: center;">Tasks</span>' +
  357. '<span style="width: 60px; display:inline-block; text-align: center;">Accept</span>' +
  358. '<span style="width: 60px; display:inline-block; text-align: center;">TV</span>' +
  359. '<span style="width: 60px; display:inline-block; text-align: center;">TO</span>' +
  360. '<span style="width: 30px; display:inline-block; text-align: center;">M</span>' +
  361. '<span style="width: 60px; display:inline-block; text-align: center;">PANDA</span>' +
  362. '</div>' +
  363. '</div>' +
  364. '</div>' +
  365. '<div id="new_hits_"></div>' +
  366. '</div>' +
  367. '</div>' +
  368.  
  369. '<br>' +
  370.  
  371. //Logged HITs
  372. '<div id="logged_hits">' +
  373. '<div style="border-bottom: 3px solid; margin-bottom: 5px;">' +
  374. '<span style="font-size: 20px; font-weight: bold;">Logged HITs</span>' +
  375. '<span id="logged_hits_data" style="font-size: 11px;"></span>' +
  376. '<span id="log_controls" style="float: right"><button id="logg_button" style="margin-right: 0px;">Hide Logged HITs</button></span>' +
  377. '</div>' +
  378. '<div id="log_hidden" style="text-align: center; display: none;">--- LOGGED HITS HIDDEN ---</div>' +
  379. '<div id="log_table">' +
  380. '<div>' +
  381. '<div style="overflow: hidden; white-space: nowrap;">' +
  382.  
  383. '<div style="float: left;">' +
  384. '<span style="width: 80px; display:inline-block;">Time</span>' +
  385. '</div>' +
  386.  
  387. '<div style="float: left; width: calc(100% - 3500px);">' +
  388. '<span style="width: 34%; float: left; display:inline-block; overflow: hidden;">Requester</span>' +
  389. '<span style="width: 64%; float: right; display:inline-block; overflow: hidden;">Project</span>' +
  390.  
  391. '</div>' +
  392.  
  393. '<div style="float: right;">' +
  394. '<span style="width: 60px; display:inline-block; text-align: center;">Accept</span>' +
  395. '<span style="width: 60px; display:inline-block; text-align: center;">TV</span>' +
  396. '<span style="width: 60px; display:inline-block; text-align: center;">TO</span>' +
  397. '<span style="width: 30px; display:inline-block; text-align: center;">M</span>' +
  398. '<span style="width: 60px; display:inline-block; text-align: center;">PANDA</span>' +
  399. '</div>' +
  400. '</div>' +
  401. '</div>' +
  402. '<div id="log_hits_"></div>' +
  403. '</div>' +
  404. '</div>' +
  405.  
  406. // Block List
  407. '<div id="bl_div" style="z-index: 99; position: fixed; width: 80%; height: 80%; left: 10%; top: 300px; margin-top: -250px; display: none;">' +
  408. '<div style="position: relative; width: 80%; left: 10%; border-bottom: 3px solid; padding: 2px; text-align: center;">Block List</div>' +
  409. '<div id="bl_items"></div>' +
  410. '<div style="text-align: center;">' +
  411. '<button id="bl_add" style="margin-right: 5px;">Add</button>' +
  412. '<button id="bl_close" style="margin-right: 5px;">Close</button>' +
  413. '<button id="bl_import" style="margin-right: 5px;">Import</button>' +
  414. '<button id="bl_export" style="margin-right: 0px;">Export</button>' +
  415. '</div>' +
  416. '</div>' +
  417.  
  418. // Add Block List Popup
  419. '<div id="bl" class="add" style="z-index: 100; position: fixed; width: 520px; top: 300px; left: 50%; margin: -250px; padding: 5px; text-align: center; display: none;">' +
  420. '<div style="position: relative; width: 80%; left: 10%; border-bottom: 3px solid; padding: 2px; text-align: center;">Add To Block List</div>' +
  421.  
  422. '<div>' +
  423. '<p><label>Term: </label><input id="bl_term" value=""></p>' +
  424. '<p><label>Name: </label><input id="bl_name" value=""></p>' +
  425. '<input id="bl_gid" value="0" type="hidden">' +
  426. '</div>' +
  427.  
  428. '<div>' +
  429. '<button id="bl_add_save" style="margin-right: 5px;">Save</button>' +
  430. '<button id="bl_add_cancel" style="margin-right: 0px;">Cancel</button>' +
  431. '</div>' +
  432. '</div>' +
  433.  
  434. // Edit Block List Popup
  435. '<div id="edit_bl" class="add" class="add" style="z-index: 100; position: fixed; width: 520px; top: 300px; left: 50%; margin: -250px; padding: 5px; text-align: center; display: none;">' +
  436. '<div style="position: relative; width: 80%; left: 10%; border-bottom: 3px solid; padding: 2px; text-align: center;">Edit Block List Item</div>' +
  437.  
  438. '<div>' +
  439. '<p><label>Term: </label><input id="edit_bl_term" value=""disabled></p>' +
  440. '<p><label>Name: </label><input id="edit_bl_name" value=""></p>' +
  441. '</div>' +
  442.  
  443. '<div>' +
  444. '<button id="edit_bl_save" style="margin-right: 5px;">Save</button>' +
  445. '<button id="edit_bl_delete" style="margin-right: 5px;">Delete</button>' +
  446. '<button id="edit_bl_cancel" style="margin-right: 0px;">Cancel</button>' +
  447. '</div>' +
  448. '</div>' +
  449.  
  450. // Include List
  451. '<div id="il_div" style="z-index: 99; position: fixed; width: 80%; height: 80%; left: 10%; top: 300px; margin-top: -250px; display: none;">' +
  452. '<div style="position: relative; width: 80%; left: 10%; border-bottom: 3px solid; padding: 2px; text-align: center;">Include List</div>' +
  453. '<div id="il_items"></div>' +
  454. '<div style="text-align: center;">' +
  455. '<button id="il_add" style="margin-right: 5px;">Add</button>' +
  456. '<button id="il_close" style="margin-right: 5px;">Close</button>' +
  457. '<button id="il_import" style="margin-right: 5px;">Import</button>' +
  458. '<button id="il_export" style="margin-right: 0px;">Export</button>' +
  459. '</div>' +
  460. '</div>' +
  461.  
  462. // Add Include List Popup
  463. '<div id="il" class="add" style="z-index: 100; position: fixed; width: 520px; top: 300px; left: 50%; margin: -250px; padding: 5px; text-align: center; display: none;">' +
  464. '<div style="position: relative; width: 80%; left: 10%; border-bottom: 3px solid; padding: 2px; text-align: center;">Add To Include List</div>' +
  465.  
  466. '<div>' +
  467. '<p><label>Term: </label><input id="il_term" value=""></p>' +
  468. '<p><label>Name: </label><input id="il_name" value=""></p>' +
  469. '</div>' +
  470.  
  471. '<div style="position: relative; width: 80%; left: 10%; border-bottom: 3px solid; padding: 2px; text-align: center;">Alerts</div>' +
  472.  
  473. '<p>' +
  474. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;">Sound: ' +
  475. '<select id="il_sound">' +
  476. '<option value="1">Sound 1</option>' +
  477. '<option value="2">Sound 2</option>' +
  478. '<option value="3">Sound 3</option>' +
  479. '<option value="4">Sound 4</option>' +
  480. '</select>' +
  481. '</label>' +
  482.  
  483. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;">Desktop Notifications' +
  484. '<input id="il_noti_cb" type="checkbox">' +
  485. '</label>' +
  486.  
  487. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;">Play Sound' +
  488. '<input id="il_sound_cb" type="checkbox">' +
  489. '</label>' +
  490.  
  491. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;">Send Pushbullet' +
  492. '<input id="il_push_cb" type="checkbox">' +
  493. '</label>' +
  494. '</p>' +
  495.  
  496. '<div>' +
  497. '<button id="il_add_save" style="margin-right: 5px;">Save</button>' +
  498. '<button id="il_add_cancel" style="margin-right: 0px;">Cancel</button>' +
  499. '</div>' +
  500. '</div>' +
  501.  
  502. // Edit Include List Popup
  503. '<div id="edit_il" class="add" style="z-index: 100; position: fixed; width: 520px; top: 300px; left: 50%; margin: -250px; padding: 5px; text-align: center; display: none;">' +
  504. '<div style="position: relative; width: 80%; left: 10%; border-bottom: 3px solid; padding: 2px; text-align: center;">Edit Include List Item</div>' +
  505.  
  506. '<div>' +
  507. '<p><label>Term: </label><input id="edit_il_term" value="" disabled></p>' +
  508. '<p><label>Name: </label><input id="edit_il_name" value=""></p>' +
  509. '</div>' +
  510.  
  511. '<div style="position: relative; width: 80%; left: 10%; border-bottom: 3px solid; padding: 2px; text-align: center;"">Alerts</div>' +
  512.  
  513. '<p>' +
  514. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;">Sound: ' +
  515. '<select id="edit_il_sound">' +
  516. '<option value="1">Sound 1</option>' +
  517. '<option value="2">Sound 2</option>' +
  518. '<option value="3">Sound 3</option>' +
  519. '<option value="4">Sound 4</option>' +
  520. '</select>' +
  521. '</label>' +
  522.  
  523. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;">Desktop Notifications' +
  524. '<input id="edit_il_noti_cb" type="checkbox">' +
  525. '</label>' +
  526.  
  527. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;">Play Sound' +
  528. '<input id="edit_il_sound_cb" type="checkbox">' +
  529. '</label>' +
  530.  
  531. '<label style="margin-right: 0px; display: inline-block; border-bottom: 1px solid;">Send Pushbullet' +
  532. '<input id="edit_il_push_cb" type="checkbox">' +
  533. '</label>' +
  534. '</p>' +
  535.  
  536. '<div>' +
  537. '<button id="edit_il_save" style="margin-right: 5px;">Save</button>' +
  538. '<button id="edit_il_delete" style="margin-right: 5px;">Delete</button>' +
  539. '<button id="edit_il_cancel" style="margin-right: 0px;">Cancel</button>' +
  540. '</div>' +
  541. '</div>' +
  542.  
  543. // Advanced Settings
  544. '<div id="sett" class="add" style="z-index: 100; position: fixed; width: 520px; top: 300px; left: 50%; margin: -250px; padding: 5px; text-align: center; display: none;">' +
  545. '<div style="position: relative; width: 80%; left: 10%; border-bottom: 3px solid; padding: 2px; text-align: center;">Advanced Settings</div>' +
  546.  
  547. '<div>' +
  548. '<p><label>Pushbullet Token: </label><input id="push" value="' + config.push + '"></p>' +
  549. '</div>' +
  550.  
  551. '<div style="position: relative; width: 80%; left: 10%; border-bottom: 3px solid; padding: 2px; text-align: center;">Theme</div>' +
  552.  
  553. '<p>' +
  554. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;">Theme: ' +
  555. '<select id="adv_theme" value="' + config.theme + '">' +
  556. '<option value="default">Default (Light)</option>' +
  557. '<option value="light">Pastel</option>' +
  558. '<option value="dark">Dark</option>' +
  559. '<option value="darker">Darker</option>' +
  560. '<option value="custom">Custom</option>' +
  561. '</select>' +
  562. '</label>' +
  563.  
  564. '<label style="margin-right: 0px; display: inline-block; border-bottom: 1px solid;">TO Theme: ' +
  565. '<select id="to_theme" value="' + config.to_theme + '">' +
  566. '<option value="1">Default</option>' +
  567. '<option value="2">Column Only</option>' +
  568. '<option value="3">Text Only</option>' +
  569. '</select>' +
  570. '</label>' +
  571. '</p>' +
  572.  
  573. '<p>' +
  574. '<label style="width: 150px; margin-right: 5px; display: inline-block; border-bottom: 1px solid; text-align: left;">Main: #' +
  575. '<input id="theme_main" style="width: 55px; float: right;" maxlength="6">' +
  576. '</label>' +
  577.  
  578. '<label style="width: 150px; margin-right: 5px; display: inline-block; border-bottom: 1px solid; text-align: left;">Primary: #' +
  579. '<input id="theme_primary" style="width: 55px; float: right;" maxlength="6">' +
  580. '</label>' +
  581.  
  582. '<label style="width: 150px; margin-right: 0px; display: inline-block; border-bottom: 1px solid; text-align: left;">Secondary: #' +
  583. '<input id="theme_secondary" style="width: 55px; float: right;" maxlength="6">' +
  584. '</label>' +
  585. '</p>' +
  586.  
  587. '<p>' +
  588. '<label style="width: 150px; margin-right: 5px; display: inline-block; border-bottom: 1px solid; text-align: left;">Text: #' +
  589. '<input id="theme_text" style="width: 55px; float: right;" maxlength="6">' +
  590. '</label>' +
  591.  
  592. '<label style="width: 150px; margin-right: 5px; display: inline-block; border-bottom: 1px solid; text-align: left;">Link: #' +
  593. '<input id="theme_link" style="width: 55px; float: right;" maxlength="6">' +
  594. '</label>' +
  595.  
  596. '<label style="width: 150px; margin-right: 0px; display: inline-block; border-bottom: 1px solid; text-align: left;">Visited: #' +
  597. '<input id="theme_visited" style="width: 55px; float: right;" maxlength="6">' +
  598. '</label>' +
  599. '</p>' +
  600.  
  601. '<div>' +
  602. '<button id="sett_save" style="margin-right: 5px;">Save</button>' +
  603. '<button id="sett_close" style="margin-right: 0px;">Close</button>' +
  604. '</div>' +
  605. '</div>'
  606. );
  607.  
  608. // Click functions
  609. $('#scan_button').click(function () {
  610. if ($(this).text() === 'Start') {
  611. $(this).text('Stop');
  612. _scan();
  613. }
  614. else {
  615. $(this).text('Start');
  616. }
  617. });
  618.  
  619. $('#sett_button').click(function () {
  620. $('#sett').toggle();
  621. });
  622.  
  623. $('#conf_button').click(function () {
  624. if ($(this).text() === 'Hide Config') {
  625. $(this).text('Show Config');
  626. }
  627. else {
  628. $(this).text('Hide Config');
  629. }
  630. $('#config').toggleClass('hidden');
  631. });
  632.  
  633. $('#logg_button').click(function () {
  634. _hide_log_list( $(this).text() === 'Hide Logged HITs' ? true : false );
  635. });
  636.  
  637. $('#hits_button').click(function () {
  638. _hide_hit_list( $(this).text() === 'Hide New HITs' ? true : false );
  639. });
  640.  
  641. $('#bloc_button').click(function () {
  642. $('#bl_div').toggle();
  643. });
  644.  
  645. $('#bl_add').click(function () {
  646. $('#bl').show();
  647. });
  648.  
  649. $('#bl_close').click(function () {
  650. $('#bl_div').hide();
  651. });
  652.  
  653. $('#bl_import').click(function () {
  654. _import_block();
  655. });
  656.  
  657. $('#bl_export').click(function () {
  658. _export_block();
  659. });
  660.  
  661. $('#bl_add_save').click(function () {
  662. var obj = {
  663. term : $('#bl_term').val(),
  664. name : $('#bl_name').val() === '' ? $('#bl_term').val() : $('#bl_name').val(),
  665. gid : $('#bl_gid').val() === '' ? 'X' : $('#bl_gid').val()
  666. };
  667.  
  668. _add_block(obj);
  669.  
  670. if ( obj.gid != 'X' ) {
  671. $('.loggid_' + obj.gid ).remove();
  672. }
  673. else {
  674. $('.logreqid_' + obj.term ).remove();
  675. }
  676.  
  677. $('#bl_term, #bl_name').val('');
  678. $('#bl').hide();
  679. });
  680.  
  681. $('#bl_add_cancel').click(function () {
  682. $('#bl_term, #bl_name').val('');
  683. $('#bl').hide();
  684. });
  685.  
  686. $('#edit_bl_save').click(function () {
  687. _update_block($(this).val());
  688. $('#edit_bl_term, #edit_bl_name').val('');
  689. $('#edit_bl').hide();
  690. });
  691.  
  692. $('#edit_bl_delete').click(function () {
  693. _delete_block($(this).val());
  694. $('#edit_bl_term, #edit_bl_name').val('');
  695. $('#edit_bl').hide();
  696. });
  697.  
  698. $('#edit_bl_cancel').click(function () {
  699. $('#edit_bl_term, #edit_bl_name').val('');
  700. $('#edit_bl').hide();
  701. });
  702.  
  703. $('#incl_button').click(function () {
  704. $('#il_div').toggle();
  705. });
  706.  
  707. $('#il_add').click(function () {
  708. $('#il').show();
  709. });
  710.  
  711. $('#il_close').click(function () {
  712. $('#il_div').hide();
  713. });
  714.  
  715. $('#il_import').click(function () {
  716. _import_include();
  717. });
  718.  
  719. $('#il_export').click(function () {
  720. _export_include();
  721. });
  722.  
  723. $('#il_add_save').click(function () {
  724. var obj = {
  725. term : $('#il_term').val().trim(),
  726. name : $('#il_name').val().trim() === '' ? $('#il_term').val().trim() : $('#il_name').val().trim(),
  727. sound : $('#il_sound').val(),
  728. noti_cb : $('#il_noti_cb').prop('checked'),
  729. sound_cb : $('#il_sound_cb').prop('checked'),
  730. push_cb : $('#il_push_cb').prop('checked')
  731. };
  732.  
  733. _add_include(obj);
  734.  
  735. $('#il_term, #il_name').val('');
  736. $('#il').hide();
  737. });
  738.  
  739. $('#il_add_cancel').click(function () {
  740. $('#il_term, #il_name').val('');
  741. $('#il').hide();
  742. });
  743.  
  744. $('#edit_il_save').click(function () {
  745. _update_include($(this).val());
  746. $('#edit_il_term, #edit_il_name, #edit_il_sound').val('');
  747. $('#edit_il_noti_cb, #edit_il_sound_cb, #edit_il_push_cb').prop('checked', false);
  748. $('#edit_il').hide();
  749. });
  750.  
  751. $('#edit_il_delete').click(function () {
  752. _delete_include($(this).val());
  753. $('#edit_il_term, #edit_il_name, #edit_il_sound').val('');
  754. $('#edit_il_noti_cb, #edit_il_sound_cb, #edit_il_push_cb').prop('checked', false);
  755. $('#edit_il').hide();
  756. });
  757.  
  758. $('#edit_il_cancel').click(function () {
  759. $('#edit_il_term, #edit_il_name, #edit_il_sound').val('');
  760. $('#edit_il_noti_cb, #edit_il_sound_cb, #edit_il_push_cb').prop('checked', false);
  761. $('#edit_il').hide();
  762. });
  763.  
  764. $('.on, .off').click(function () {
  765. $(this).toggleClass('on off');
  766. _save();
  767. });
  768.  
  769. $('#sett_save').click(function () {
  770. _save('custom');
  771. _theme();
  772. });
  773.  
  774. $('#sett_close').click(function () {
  775. $('#sett').hide();
  776. });
  777.  
  778. $('#time').click(function () {
  779. $('.new').removeClass('new');
  780. });
  781.  
  782. // Delegated click functions
  783. $('body').on('click', '.blockit', function () {
  784. _edit_block($(this).val());
  785. });
  786.  
  787. $('body').on('click', '.includeit', function () {
  788. _edit_include($(this).val());
  789. });
  790.  
  791. $('body').on('click', '.rt', function () {
  792. _block($(this).data('term'), $(this).data('name'), $(this).attr('id'));
  793. });
  794.  
  795. $('body').on('click', '.pc', function () {
  796. _panda($(this).data('term'), $(this).data('reqname'), $(this).data('reqid'), $(this).data('title'), $(this).data('value'), $(this).data('name'), $(this))
  797. });
  798.  
  799. $('body').on('click', '.vb', function () {
  800. _export_vb($(this).val());
  801. });
  802.  
  803. $('body').on('click', '.irc', function () {
  804. _export_irc($(this).val());
  805. });
  806.  
  807. $('body').on('click', '.details', function () {
  808. $(this).toggleClass('fa-plus-circle fa-minus-circle');
  809. $('.info[value="' + $(this).val() + '"]').toggle();
  810. });
  811.  
  812. // Delegated mouseover functions
  813. $('body').on('mouseover', '.new', function () {
  814. $(this).removeClass('new');
  815. });
  816.  
  817. // On change events
  818. $('#new_audio').change(function () {
  819. _save();
  820. _sound('new');
  821. });
  822.  
  823. $('#il_sound').change(function () {
  824. _sound('il');
  825. });
  826.  
  827. $('#edit_il_sound').change(function () {
  828. _sound('il_edit');
  829. });
  830.  
  831. $('#type, #size, #adv_theme, #to_theme, #c_theme, :checkbox').change(function () {
  832. _save();
  833. });
  834.  
  835. $('#adv_theme, #to_theme, #c_theme').change(function () {
  836. _theme();
  837. });
  838.  
  839. // On input events
  840. $('#delay, #min_rew, #min_avail, #min_to, #alert_delay').on('input', function () {
  841. _save();
  842. });
  843.  
  844. function _scan () {
  845. var searchqualvar
  846. searchqualvar = (config.qual ? 'on' : 'off');
  847.  
  848.  
  849. if ($('#scan_button').text() === 'Stop') {
  850. var _url = url + $('#type').val() + $('#size').val() + minrew + $('#min_rew').val() + searchqual + searchqualvar;
  851. var _scanurl = _url + '&format=json';
  852.  
  853. var date = new Date(), h = date.getHours(), m = date.getMinutes(), s = date.getSeconds(), ampm = h >= 12 ? 'pm' : 'am';
  854. h = h % 12; h = h ? h : 12; m = m < 10 ? '0' + m : m; s = s < 10 ? '0' + s : s;
  855. var timeis = [h, m, s, ampm];
  856. $.get(_scanurl, function (data) {
  857. _scrape_new(data, timeis);
  858. }).fail(function () {
  859. setTimeout(function () { _scan(); }, 2500);
  860. });
  861. }
  862.  
  863. if (turkerview_update > 700 ) {
  864. turkerview_update = 0;
  865. _loadTVData();
  866. }
  867. else {
  868. turkerview_update += 1;
  869. }
  870. }
  871.  
  872. function _scrape_new (data, timeis) {
  873. var keys = [], log_keys = [], to = [], logged_in = true;
  874.  
  875. var hits = data.results;
  876.  
  877. for (var i = 0; i < hits.length; i ++) {
  878. var hit = hits[i],
  879. req_name = hit.requester_name,
  880. req_id = hit.requester_id,
  881. req_link = hit.requester_url.replace(/\.json/, ''),
  882. //req_link = 'https://www.mturk.com/mturk/searchbar?selectedSearchType=hitgroups&requesterId=' + hit.requester_id,
  883. con_link = 'https://www.mturk.com/mturk/contact?requesterId=' + hit.requester_id,
  884. group_id = hit.hit_set_id,
  885. prev_link = hit.project_tasks_url.replace(/\.json/, ''),
  886. //prev_link = 'https://www.mturk.com/mturk/preview?groupId=' + hit.hit_set_id,
  887. pand_link = hit.accept_project_task_url.replace(/\.json/, ''),
  888. //pand_link = 'https://www.mturk.com/mturk/previewandaccept?groupId=' + hit.hit_set_id,
  889. title = hit.title,
  890. safetitle = title.replace(/"/g, "&quot;" ),
  891. desc = hit.description,
  892. time = _convert_seconds(hit.assignment_duration_in_seconds),
  893. reward = '$' + hit.monetary_reward.amount_in_dollars.toFixed(2),
  894. avail = hit.assignable_hits_count;
  895.  
  896. var key = req_id + title + reward + group_id;
  897. keys.push(key);
  898.  
  899.  
  900. var qualif = 'None';
  901. var quals = hit.project_requirements;
  902.  
  903. if (quals.length) {
  904. qualif = ''
  905. for (var j = 0; j < quals.length; j ++) {
  906. var q_comp = quals[j].comparator + ' ';
  907. var q_name = quals[j].qualification_type.name + ' ';
  908.  
  909. var q_valu = quals[j].qualification_values;
  910. var q_values = '';
  911. for (var k = 0; k < quals.length; k ++) {
  912. if (quals[j].qualification_values[k]) {
  913. q_values += quals[j].qualification_values[k];
  914. q_values += k === quals.length ? ', ' : '';
  915. }
  916. }
  917. qualif += (q_name + q_comp + q_values).trim() + '; ';
  918. }
  919. qualif = qualif.trim();
  920. }
  921.  
  922. if (!hitlog[key]) {
  923. hitlog[key] = {
  924. reqname : req_name,
  925. reqid : req_id,
  926. reqlink : req_link,
  927. conlink : con_link,
  928. groupid : group_id,
  929. prevlink : prev_link,
  930. pandlink : pand_link,
  931. title : title,
  932. safetitle: safetitle,
  933. desc : desc,
  934. time : time,
  935. reward : reward,
  936. avail : avail,
  937. quals : qualif,
  938. masters : '?',
  939. key : key,
  940. tolink : 'https://turkopticon.ucsd.edu/' + req_id,
  941. to : { comm : 'N/A', fair : 'N/A', fast : 'N/A', pay : 'N/A' },
  942. tvlink : 'https://turkerview.com/requesters/' + req_id,
  943. tv : _getTVHourly( req_id )
  944. };
  945. to.push([key, req_id]);
  946. log_keys.push(key);
  947. }
  948. else {
  949. hitlog[key].avail = avail;
  950. }
  951. }
  952. _to(keys, log_keys, logged_in, to, timeis);
  953. }
  954.  
  955. function _loadTVData () {
  956. GM_xmlhttpRequest ({
  957. method: "GET",
  958. url: 'https://turkerview.com/api/v1/hindsight/?t=30',
  959. onload: function(response) {
  960. turkerview = JSON.parse(response.responseText);
  961. }
  962. });
  963. }
  964.  
  965. function _getTVHourly( reqid ) {
  966. var tvHourly;
  967. if( reqid in turkerview ) {
  968. tvHourly = '$' + turkerview[reqid]['ratings']['hourly'];
  969. }
  970. else {
  971. tvHourly = 'N/A';
  972. }
  973.  
  974. return tvHourly;
  975. }
  976.  
  977. function _to (keys, log_keys, logged_in, to, timeis) {
  978. var ids = [];
  979.  
  980. if (logged_in && to.length && config.to) {
  981. for (var i = 0; i < to.length; i++) {
  982. ids.push(to[i][1]);
  983. }
  984. $.ajax( {
  985. url: 'https://turkopticon.ucsd.edu/api/multi-attrs.php?ids=' + ids,
  986. success: function (data) {
  987. var to_data = JSON.parse(data);
  988.  
  989. for (i = 0; i < to.length; i++) {
  990. if (!to_data[to[i][1]].length && typeof to_data[to[i][1]].attrs != 'undefined') {
  991. hitlog[to[i][0]].to = to_data[to[i][1]].attrs;
  992. }
  993. }
  994. },
  995. timeout: 5000
  996. }).always(function () {
  997. _build(keys, log_keys, timeis);
  998. });
  999. }
  1000. else {
  1001. _build(keys, log_keys, timeis);
  1002. }
  1003. }
  1004.  
  1005. function _build (keys, log_keys, timeis) {
  1006. var hit_html = '', log_html = '';
  1007.  
  1008. for (var i = 0; i < keys.length; i++) {
  1009. var hit = hitlog[keys[i]], blocked = _check_block(hit), included = _check_include(hit), remove = false, classes, tvHourly;
  1010.  
  1011. rowcolor = hit.tv != 'N/A' ? _color_tv(hit) : _color_to(hit)
  1012.  
  1013. classes = rowcolor;
  1014.  
  1015. if (hit.masters === 'Y') {
  1016. classes += config.m ? ' m_hidden' : ' m';
  1017. }
  1018.  
  1019. if (Number(config.avail) > Number(hit.avail) || Number(config.mto) > Number(hit.to.pay)) {
  1020. classes += ' hidden';
  1021. remove = true;
  1022. }
  1023.  
  1024. if (blocked) {
  1025. classes += config.bl ? ' bl_hidden' : ' bl';
  1026. remove = true;
  1027. }
  1028.  
  1029. if (included) {
  1030. classes += ' il';
  1031. _included(included, hit);
  1032. }
  1033. else {
  1034. classes += config.nl ? ' nl_hidden' : ' nl';
  1035. }
  1036.  
  1037. hit_html +=
  1038. '<div class="cont" style="margin-bottom: 2px;">' +
  1039. '<div class="' + classes + ' " style="overflow: hidden; white-space: nowrap; margin-bottom: 2px;">' +
  1040.  
  1041. '<div style="float: left; width: calc(100% - 330px);">' +
  1042.  
  1043. '<span style="width: 34%; float: left; display:inline-block; overflow: hidden;">' +
  1044. '<button data-term="' + hit.reqid + '" data-name="' + hit.reqname + '" class="rt">R</button>' +
  1045. '<button id="'+ hit.groupid + '" data-term="' + hit.safetitle + '" data-name="' + hit.safetitle + '" class="rt">T</button>' +
  1046. '<a href="' + hit.reqlink + '">' + hit.reqname + '</a>' +
  1047. '</span>' +
  1048.  
  1049. '<span style="width: 64%; float: right; display:inline-block; overflow: hidden;">' +
  1050. '<button value="' + hit.key + '" class="vb">vB</button>' +
  1051. '<button value="' + hit.key + '" class="irc">IRC</button>' +
  1052. '<a href="' + hit.prevlink + '">' + hit.title + '</a>' +
  1053. '</span>' +
  1054.  
  1055. '</div>' +
  1056.  
  1057. '<div style="float: right;">' +
  1058.  
  1059. '<span style="width: 60px; display:inline-block; text-align: center;">' +
  1060. hit.avail +
  1061. '</span>' +
  1062.  
  1063. '<span style="width: 60px; display:inline-block; text-align: center;">' +
  1064. '<a href="' + hit.pandlink + '">' + hit.reward + '</a>' +
  1065. '</span>' +
  1066.  
  1067. '<span class="to" style="width: 60px; display:inline-block; text-align: center;">' +
  1068. '<a href="' + hit.tvlink + '">' + hit.tv + '</a>' +
  1069. '</span>' +
  1070.  
  1071. '<span class="to" style="width: 60px; display:inline-block; text-align: center;">' +
  1072. '<a href="' + hit.tolink + '">' + hit.to.pay + '</a>' +
  1073. '</span>' +
  1074.  
  1075. '<span style="width: 30px; display:inline-block; text-align: center;">' +
  1076. hit.masters +
  1077. '</span>' +
  1078.  
  1079. '<span style="width: 60px; display:inline-block; text-align: center;">' +
  1080. '<button data-term="' + hit.groupid + '" data-reqid="' + hit.reqid + '" data-reqname="' + hit.reqname.replace(/"/g, "&quot;" ) + '" data-title="' + hit.safetitle + '" data-value="' + hit.reward.replace(/\$/g, '') + '" data-name="panda" class="pc">P</button>' +
  1081. '<button data-term="' + hit.groupid + '" data-reqid="' + hit.reqid + '" data-reqname="' + hit.reqname.replace(/"/g, "&quot;" ) + '" data-title="' + hit.safetitle + '" data-value="' + hit.reward.replace(/\$/g, '') + '" data-name="once" class="pc">O</button>' +
  1082. '</span>' +
  1083.  
  1084. '</div>' +
  1085. '</div>' +
  1086. '</div>'
  1087. ;
  1088.  
  1089. if (remove) {
  1090. var index = log_keys.indexOf(keys[i]);
  1091.  
  1092. if (index > -1) {
  1093. log_keys.splice(index, 1);
  1094. }
  1095. }
  1096. }
  1097.  
  1098. if (log_keys.length) {
  1099. for (var j = 0; j < log_keys.length; j ++) {
  1100. var hit_log = hitlog[log_keys[j]], included_log = _check_include(hit_log), rowcolor, classes_log, tvHourly;
  1101.  
  1102. rowcolor = hit_log.tv != 'N/A' ? _color_tv(hit_log) : _color_to(hit_log);
  1103.  
  1104. classes_log = rowcolor;
  1105.  
  1106. if (hit_log.masters === 'Y') {
  1107. classes_log += config.m ? ' m_hidden' : ' m';
  1108. }
  1109.  
  1110. if (included_log) {
  1111. classes_log += ' il';
  1112. }
  1113. else {
  1114. classes_log += config.nl ? ' nl_hidden' : ' nl';
  1115. }
  1116.  
  1117. var quals = hit_log.quals.split(';');
  1118. var qualif = '';
  1119.  
  1120. for (var k = 0; k < quals.length; k ++) {
  1121. if (quals[k] !== '') {
  1122. qualif += '<li style="padding: 2px;">' + quals[k] + '</li>';
  1123. }
  1124. }
  1125.  
  1126.  
  1127.  
  1128. log_html +=
  1129. '<div class="cont loggid_' + hit_log.groupid +' logreqid_' + hit_log.reqid + '" style="margin-bottom: 2px;">' +
  1130. '<div class="' + classes_log + '" style="overflow: hidden; white-space: nowrap;">' +
  1131.  
  1132. '<div style="float: left;">' +
  1133. '<span style="width: 80px; display:inline-block;">' +
  1134. '<button class="fa fa-plus-circle fa-2 details" aria-hidden="true" value="' + hit_log.key + '" style="background-color: transparent; border: 0px; padding: 1px;"></button>' +
  1135. timeis[0] + ':' + timeis[1] + timeis[3] + '</span>' +
  1136. '</div>' +
  1137.  
  1138. '<div style="float: left; width: calc(100% - 350px);">' +
  1139.  
  1140. '<span style="width: 34%; float: left; display:inline-block; overflow: hidden;">' +
  1141. '<button data-term="' + hit_log.reqid + '" data-name="' + hit_log.reqname + '" class="rt">R</button>' +
  1142. '<button id="'+ hit_log.groupid + '" data-term="' + hit_log.safetitle + '" data-name="' + hit_log.safetitle + '" class="rt">T</button>' +
  1143. '<a href="' + hit_log.reqlink + '">' + hit_log.reqname + '</a>' +
  1144. '</span>' +
  1145.  
  1146. '<span style="width: 64%; float: right; display:inline-block; overflow: hidden;">' +
  1147. '<button value="' + hit_log.key + '" class="vb">vB</button>' +
  1148. '<button value="' + hit_log.key + '" class="irc">IRC</button>' +
  1149. '<a href="' + hit_log.prevlink + '">' + hit_log.title + '</a>' +
  1150. '</span>' +
  1151.  
  1152. '</div>' +
  1153.  
  1154. '<div style="float: right;">' +
  1155.  
  1156. '<span style="width: 60px; display: inline-block; text-align: center;">' +
  1157. '<a href="' + hit_log.pandlink + '">' + hit_log.reward + '</a>' +
  1158. '</span>' +
  1159.  
  1160. '<span class="to" style="width: 60px; display:inline-block; text-align: center;">' +
  1161. '<a href="' + hit_log.tvlink + '">' + hit_log.tv + '</a>' +
  1162. '</span>' +
  1163.  
  1164. '<span class="to" style="width: 60px; display:inline-block; text-align: center;">' +
  1165. '<a href="' + hit_log.tolink + '">' + hit_log.to.pay + '</a>' +
  1166. '</span>' +
  1167.  
  1168. '<span style="width: 30px; display:inline-block; text-align: center;">' +
  1169. hit_log.masters +
  1170. '</span>' +
  1171.  
  1172. '<span style="width: 60px; display:inline-block; text-align: center;">' +
  1173. '<button data-term="' + hit_log.groupid + '" data-reqid="' + hit_log.reqid + '" data-reqname="' + hit_log.reqname.replace(/"/g, "&quot;" ) + '" data-title="' + hit_log.safetitle + '" data-value="' + hit_log.reward.replace(/\$/g, '') + '" data-name="panda" class="pc">P</button>' +
  1174. '<button data-term="' + hit_log.groupid + '" data-reqid="' + hit_log.reqid + '" data-reqname="' + hit_log.reqname.replace(/"/g, "&quot;" ) + '" data-title="' + hit_log.safetitle + '" data-value="' + hit_log.reward.replace(/\$/g, '') + '" data-name="once" class="pc">O</button>' +
  1175. '</span>' +
  1176.  
  1177. '</div>' +
  1178. '</div>'+
  1179.  
  1180. '<div class="info ' + rowcolor + '" value="' + hit_log.key + '" style="overflow: hidden; display: none; font-size: 11px;">' +
  1181.  
  1182. '<div style="border-bottom: 1px solid #000000;"></div>' +
  1183.  
  1184. '<span style="width: 33%; float: left; display:inline-block; padding: 5px;">' +
  1185. '<span style="text-decoration: underline;">Description</span>' +
  1186. '<div style="padding: 2px;">' + hit_log.desc +'</div>' +
  1187. '<span style="text-decoration: underline;">Time</span>' +
  1188. '<div style="padding: 2px;">' + hit_log.time +'</div>' +
  1189. '</span>' +
  1190.  
  1191. '<span style="width: 33%; float: left; display:inline-block; padding: 5px;">' +
  1192. '<span style="text-decoration: underline;">Qualifications</span>' +
  1193. qualif +
  1194. '</span>' +
  1195.  
  1196. '<span style="width: calc(34% - 30px); float: right; display:inline-block; padding: 5px;">' +
  1197. '<span style="text-decoration: underline;">Turkopticon</span>' +
  1198. '<br>' +
  1199. '<span style="width: 70px; display:inline-block; padding: 2px;">Pay : ' + hit_log.to.pay +'</span>' +
  1200. '<span style="width: 70px; display:inline-block; padding: 2px;">Fair : ' + hit_log.to.fair +'</span>' +
  1201. '<br>' +
  1202. '<span style="width: 70px; display:inline-block; padding: 2px;">Comm : ' + hit_log.to.comm +'</span>' +
  1203. '<span style="width: 70px; display:inline-block; padding: 2px;">Fast : ' + hit_log.to.fast +'</span>' +
  1204. '</span>' +
  1205.  
  1206. '</div>' +
  1207. '</div>';
  1208.  
  1209. logged ++;
  1210. }
  1211. if (config.new) {
  1212. _sound('new');
  1213. }
  1214. }
  1215. $('#new_hits_').html(hit_html);
  1216. $('#log_hits_').prepend(log_html);
  1217.  
  1218. searches ++;
  1219. var hits_data = '<span> ' + timeis[0] + ':' + timeis[1] + ':' + timeis[2] + timeis[3] + ' Scanned HITs: ' + keys.length + '</span><span style="float: right;">' + searches + '</span>';
  1220. var logged_hits_data = '<span style="float: right;">' + logged + '</span>';
  1221.  
  1222. $('#hits_data').html(hits_data);
  1223. $('#logged_hits_data').html(logged_hits_data);
  1224.  
  1225. if ($('#scan_button').text() === 'Stop') {
  1226. setTimeout(function () {
  1227. _scan();
  1228. }, $('#delay').val() * 1000);
  1229. }
  1230. }
  1231.  
  1232. function _sound (sound) {
  1233. if (sound === 'new') { $('#audio_' + config.newaudio) [0].play(); }
  1234. if (sound === 'include') { $('#audio_' + config.newaudio) [0].play(); }
  1235. if (sound === 'il') { $('#audio_' + $('#il_sound').val()) [0].play(); }
  1236. if (sound === 'il_edit') { $('#audio_' + $('#edit_il_sound').val()) [0].play(); }
  1237. }
  1238.  
  1239. function _check_block (hit) {
  1240. for (var key in blocklist) {
  1241. var obj = blocklist[key];
  1242. if (obj.term.toLowerCase() === hit.reqname.toLowerCase() || obj.term.toLowerCase() === hit.title.toLowerCase() || obj.term.toLowerCase() === hit.reqid.toLowerCase() || obj.term.toLowerCase() === hit.groupid.toLowerCase()) {
  1243. return obj;
  1244. }
  1245. }
  1246. }
  1247.  
  1248. function _check_include (hit) {
  1249. for (var key in includelist) {
  1250. var obj = includelist[key];
  1251. if (obj.term.toLowerCase() === hit.reqname.toLowerCase() || obj.term.toLowerCase() === hit.title.toLowerCase() || obj.term.toLowerCase() === hit.reqid.toLowerCase() || obj.term.toLowerCase() === hit.groupid.toLowerCase()) {
  1252. return obj;
  1253. }
  1254. }
  1255. }
  1256.  
  1257. function _included (obj, hit) {
  1258. var check = noti_delay.indexOf(hit.key) !== -1;
  1259. var pushcheck = push_delay.indexOf(hit.key) !== -1;
  1260.  
  1261. if (!check) {
  1262. noti_delay.unshift(hit.key);
  1263. setTimeout(function () { noti_delay.pop(); }, config.alert * 1000);
  1264. }
  1265. if (obj.noti_cb && !check) {
  1266. Notification.requestPermission();
  1267. var n = new Notification(hit.reqname + ' | ' + hit.reward, {
  1268. icon : 'http://nopurpose.org/stuff/avatars/Lj21396.gif',
  1269. body : hit.title,
  1270. });
  1271. setTimeout(n.close.bind(n), 5000);
  1272.  
  1273. n.onclick = function(e) {
  1274. e.preventDefault();
  1275. window.open(hit.prevlink, '_blank');
  1276. };
  1277.  
  1278. }
  1279. if (obj.sound_cb && !check) {
  1280. $('#audio_' + obj.sound)[0].play();
  1281. }
  1282. if (obj.push_cb && !pushcheck && config.pb) {
  1283. push_delay.unshift(hit.key);
  1284. setTimeout(function () { push_delay.pop(); }, 900000);
  1285.  
  1286. var push = {};
  1287.  
  1288. push['type'] = 'note';
  1289. push['title'] = 'HIT Finder';
  1290. push['body'] = '[' + hit.reqname + ']\n[' + hit.title + ']\n[' + hit.reward + ']\n[' + hit.prevlink + ']';
  1291.  
  1292. $.ajax({
  1293. type : 'POST',
  1294. headers : {'Authorization': 'Bearer ' + config.push},
  1295. url : 'https://api.pushbullet.com/v2/pushes',
  1296. data : push
  1297. });
  1298.  
  1299. }
  1300. }
  1301.  
  1302. function _color_tv(hit) {
  1303. var tvHourly = hit.tv.replace(/\$/g, '');
  1304.  
  1305. if (config.theme == "light") {
  1306. if (tvHourly >= 10.00) { return 'tvHigh'; }
  1307. else if (tvHourly >= 7.25) { return 'tvFair'; }
  1308. else { return 'tvLow'; }
  1309. }
  1310. else {
  1311. if (tvHourly >= 10.00) { return 'toHigh'; }
  1312. else if (tvHourly >= 7.25) { return 'toAverage'; }
  1313. else { return 'toLow'; }
  1314.  
  1315. }
  1316. }
  1317.  
  1318. function _color_to (hit) {
  1319. var to = hit.to.pay;
  1320.  
  1321. if (config.theme == "light") {
  1322. if (to > 4) { return 'tvHigh'; }
  1323. else if (to > 2.5) { return 'tvFair'; }
  1324. else if (to > 0) { return 'tvLow'; }
  1325. else { return 'tvNone'; }
  1326. }
  1327. else {
  1328. if (to > 4) { return 'toHigh'; }
  1329. else if (to > 3) { return 'toGood'; }
  1330. else if (to > 2) { return 'toAverage'; }
  1331. else if (to > 1) { return 'toLow'; }
  1332. else if (to > 0) { return 'toPoor'; }
  1333. else { return 'toNone'; }
  1334.  
  1335. }
  1336. }
  1337.  
  1338. function _convert_seconds (seconds) {
  1339. seconds = Number(seconds);
  1340. var h = Math.floor(seconds / 3600);
  1341. var m = Math.floor(seconds % 3600 / 60);
  1342. var s = Math.floor(seconds % 3600 % 60);
  1343. var time = '';
  1344. if (h > 0) { time += h + ' hour(s) '; }
  1345. if (m > 0) { time += m + ' minutes(s) '; }
  1346. if (s > 0) { time += s + ' seconds(s)'; }
  1347. return time;
  1348. }
  1349.  
  1350. function _block (term, name, gid) {
  1351. $('#bl_term') .val(term);
  1352. $('#bl_name') .val(name);
  1353. $('#bl_gid').val(gid);
  1354. $('#bl') .show();
  1355. }
  1356.  
  1357. function _panda(term, reqname, reqid, title, value, name, button) {
  1358. var hitData = {
  1359. hitTitle: title,
  1360. requesterName: reqname,
  1361. requesterId: reqid,
  1362. hitValue: value
  1363. }
  1364. var once = term == "panda" ? false : true;
  1365.  
  1366. PandaCrazy.online().then (
  1367. function(successResp) {
  1368. PandaCrazy.addJob( term, once, hitData );
  1369. button.addClass("clicked")
  1370. },
  1371. function(failedResp) {
  1372. alert( "Panda Crazy doesn't appear to be running. Please double check if it's being run on the same browser profile and try again");
  1373. }
  1374. );
  1375. console.log ( running );
  1376. }
  1377.  
  1378.  
  1379. function _add_block (obj) {
  1380. if (!blocklist[obj.term]) {
  1381. blocklist[obj.term] = obj;
  1382. _init_lists();
  1383. }
  1384. }
  1385.  
  1386. function _edit_block (term) {
  1387. var obj = blocklist[term];
  1388. $('#edit_bl_term') .val(obj.term) .text(obj.term);
  1389. $('#edit_bl_name') .val(obj.name);
  1390. $('#edit_bl_save') .val(obj.term);
  1391. $('#edit_bl_delete') .val(obj.term);
  1392. $('#edit_bl') .show();
  1393. }
  1394.  
  1395. function _update_block (block) {
  1396. var obj = blocklist[block];
  1397. obj.name = $('#edit_bl_name').val();
  1398. _init_lists();
  1399. }
  1400.  
  1401. function _delete_block (block) {
  1402. delete blocklist[block];
  1403. _init_lists();
  1404. }
  1405.  
  1406. function _add_include (obj) {
  1407. if (!includelist[obj.term]) {
  1408. includelist[obj.term] = obj;
  1409. _init_lists();
  1410. }
  1411. }
  1412.  
  1413. function _edit_include (term) {
  1414. var obj = includelist[term];
  1415.  
  1416. $('#edit_il_term') .val(obj.term) .text(obj.term);
  1417. $('#edit_il_name') .val(obj.name);
  1418. $('#edit_il_sound') .val(obj.sound);
  1419.  
  1420. $('#edit_il_noti_cb') .prop('checked', obj.noti_cb);
  1421. $('#edit_il_sound_cb') .prop('checked', obj.sound_cb);
  1422. $('#edit_il_push_cb') .prop('checked', obj.push_cb);
  1423.  
  1424. $('#edit_il_save') .val(obj.term);
  1425. $('#edit_il_delete') .val(obj.term);
  1426.  
  1427. $('#edit_il').show();
  1428. }
  1429.  
  1430. function _update_include (term) {
  1431. var obj = includelist[term];
  1432. obj.name = $('#edit_il_name') .val().trim();
  1433. obj.sound = $('#edit_il_sound') .val().trim();
  1434. obj.noti_cb = $('#edit_il_noti_cb') .prop('checked');
  1435. obj.sound_cb = $('#edit_il_sound_cb') .prop('checked');
  1436. obj.push_cb = $('#edit_il_push_cb') .prop('checked');
  1437. _init_lists();
  1438. }
  1439.  
  1440. function _delete_include (term) {
  1441. delete includelist[term];
  1442. _init_lists();
  1443. }
  1444.  
  1445. function _hide_hit_list( hide ) {
  1446. if (hide) {
  1447. $("#hits_button").text('Show New HITs');
  1448. $('#hits_table').hide();
  1449. $('#hits_hidden').show();
  1450. config.h_hidden = '1';
  1451. }
  1452. else {
  1453. $("#hits_button").text('Hide New HITs');
  1454. $('#hits_table').show();
  1455. $('#hits_hidden').hide();
  1456. config.h_hidden = '0';
  1457. }
  1458.  
  1459. _save( 'showhide' );
  1460. }
  1461.  
  1462. function _hide_log_list( hide ) {
  1463. if (hide) {
  1464. $("#logg_button").text('Show Logged HITs');
  1465. $('#log_table').hide();
  1466. $('#log_hidden').show();
  1467. config.l_hidden = '1';
  1468. }
  1469. else {
  1470. $("#logg_button").text('Hide Logged HITs');
  1471. $('#log_table').show();
  1472. $('#log_hidden').hide();
  1473. config.l_hidden = '0';
  1474. }
  1475.  
  1476. _save( 'showhide' );
  1477. }
  1478.  
  1479. function _init_lists () {
  1480. var bl_sort = [], il_sort = [], bl_html = '', il_html = '';
  1481.  
  1482. for (var bl_key in blocklist) {
  1483. bl_sort.push([bl_key, blocklist[bl_key].name]);
  1484. }
  1485.  
  1486. bl_sort.sort(function (a, b) {
  1487. if (a[1].toLowerCase() < b[1].toLowerCase()) return -1;
  1488. if (a[1].toLowerCase() > b[1].toLowerCase()) return 1;
  1489. return 0;
  1490. });
  1491.  
  1492. for (var i = 0; i < bl_sort.length; i ++) {
  1493. var bl_obj = blocklist[bl_sort[i][0]];
  1494. bl_html += '<button class="blockit" style="margin: 2px;" value="' + bl_obj.term + '" title="' + bl_obj.term + '">' + bl_obj.name + '</button>';
  1495. }
  1496.  
  1497. for (var il_key in includelist) {
  1498. il_sort.push([il_key, includelist[il_key].name]);
  1499. }
  1500.  
  1501. il_sort.sort(function (a, b) {
  1502. if (a[1].toLowerCase() < b[1].toLowerCase()) return -1;
  1503. if (a[1].toLowerCase() > b[1].toLowerCase()) return 1;
  1504. return 0;
  1505. });
  1506.  
  1507. for (var j = 0; j < il_sort.length; j ++) {
  1508. var il_obj = includelist[il_sort[j][0]];
  1509. il_html += '<button class="includeit" style="margin: 2px;" value="' + il_obj.term + '" title="' + il_obj.term + '">' + il_obj.name + '</button>';
  1510. }
  1511.  
  1512. $('#bl_items') .html(bl_html);
  1513. $('#il_items') .html(il_html);
  1514. _save('init');
  1515. }
  1516.  
  1517. function _import_block () {
  1518. var import_bl = prompt(
  1519. 'Block List Import\n\n' +
  1520. 'You can import from HIT Finder or HIT Scraper.\n\n' +
  1521. 'This will not delete your current block list, only add to it.\n\n' +
  1522. 'Please enter your block list here.',
  1523. ''
  1524. );
  1525.  
  1526. if (import_bl) {
  1527. var json = _json_validator(import_bl);
  1528.  
  1529. if (json) {
  1530. var _bl_obj = JSON.parse(import_bl);
  1531. for (var key in _bl_obj) {
  1532. if (_bl_obj[key].hasOwnProperty('term') && _bl_obj[key].hasOwnProperty('name') && !_bl_obj[key].hasOwnProperty('sound')) {
  1533. if (!blocklist[key]) {
  1534. blocklist[key] = {
  1535. term : _bl_obj[key].term,
  1536. name : _bl_obj[key].name
  1537. };
  1538. }
  1539. }
  1540. else {
  1541. alert('An error occured while importing.\n\n Please check if you have a valid import and try again.');
  1542. break;
  1543. }
  1544. }
  1545. _init_lists();
  1546. }
  1547. else if (import_bl.match(/^/)) {
  1548. var _bl_arr = import_bl.trim().split('^');
  1549. for (var i = 0; i < _bl_arr.length; i ++) {
  1550. if (!blocklist[_bl_arr[i]]) {
  1551. blocklist[_bl_arr[i]] = {
  1552. term : _bl_arr[i],
  1553. name : _bl_arr[i]
  1554. };
  1555. }
  1556. }
  1557. _init_lists();
  1558. }
  1559. }
  1560. else {
  1561. alert('An error occured while importing.\n\n Please check if you have a valid import and try again.');
  1562. }
  1563. }
  1564.  
  1565. function _export_block () {
  1566. GM_setClipboard(localStorage.getItem('_finder_bl'));
  1567. alert('Your block list has been copied to your clipboard.');
  1568. }
  1569.  
  1570. function _import_include () {
  1571. var import_il = prompt(
  1572. 'Include List Import\n\n' +
  1573. 'You can import from HIT Finder or HIT Scraper.\n\n' +
  1574. 'This will not delete your current include list, only add to it.\n\n' +
  1575. 'Please enter your include list here.',
  1576. ''
  1577. );
  1578.  
  1579. if (import_il) {
  1580. var json = _json_validator(import_il);
  1581.  
  1582. if (json) {
  1583. var _il_obj = JSON.parse(import_il);
  1584.  
  1585. for (var key in _il_obj) {
  1586. if (_il_obj[key].hasOwnProperty('term') && _il_obj[key].hasOwnProperty('name') && _il_obj[key].hasOwnProperty('sound')) {
  1587. if (!includelist[key]) {
  1588. includelist[key] = {
  1589. term : _il_obj[key].term,
  1590. name : _il_obj[key].name,
  1591. sound : _il_obj[key].sound,
  1592. noti_cb : _il_obj[key].noti_cb,
  1593. sound_cb : _il_obj[key].sound_cb,
  1594. push_cb : _il_obj[key].push_cb
  1595. };
  1596. }
  1597. }
  1598. else {
  1599. alert('An error occured while importing.\n\n Please check that you have a valid import and try again.');
  1600. break;
  1601. }
  1602. }
  1603. _init_lists();
  1604. }
  1605. else if (import_il.match(/^/)) {
  1606. var _il_arr = import_il.split('^');
  1607.  
  1608. for (var i = 0; i < _il_arr.length; i ++) {
  1609. if (!includelist[_il_arr[i]]) {
  1610. includelist[_il_arr[i]] = {
  1611. term : _il_arr[i],
  1612. name : _il_arr[i],
  1613. sound : '1',
  1614. noti_cb : true,
  1615. sound_cb : true,
  1616. push_cb : false
  1617. };
  1618. }
  1619. }
  1620. _init_lists();
  1621. }
  1622. }
  1623. else {
  1624. alert('An error occured while importing.\n\n Please check that you have a valid import and try again.');
  1625. }
  1626. }
  1627.  
  1628. function _export_include () {
  1629. GM_setClipboard(localStorage.getItem('_finder_il'));
  1630. alert('Your include list has been copied to your clipboard.');
  1631. }
  1632.  
  1633. function _export_vb (key) {
  1634. var hit = hitlog[key];
  1635.  
  1636. var pay = hit.to.pay, _pay = '#B30000';
  1637. if (pay > 3.99) { _pay = '#00B300'; }
  1638. else if (pay > 2.99) { _pay = '#B3B300'; }
  1639. else if (pay > 1.99) { _pay = '#B37400'; }
  1640.  
  1641. var fair = hit.to.fair, _fair = '#B30000';
  1642. if (fair > 3.99) { _fair = '#00B300'; }
  1643. else if (fair > 2.99) { _fair = '#B3B300'; }
  1644. else if (fair > 1.99) { _fair = '#B37400'; }
  1645.  
  1646. var comm = hit.to.comm, _comm = '#B30000';
  1647. if (comm > 3.99) { _comm = '#00B300'; }
  1648. else if (comm > 2.99) { _comm = '#B3B300'; }
  1649. else if (comm > 1.99) { _comm = '#B37400'; }
  1650.  
  1651. var fast = hit.to.fast, _fast = '#B30000';
  1652. if (fast > 3.99) { _fast = '#00B300'; }
  1653. else if (fast > 2.99) { _fast = '#B3B300'; }
  1654. else if (fast > 1.99) { _fast = '#B37400'; }
  1655.  
  1656. var tv = hit.tv.replace(/\$/g, ''), _tvhourly = '#B30000';
  1657. if ( tv != 'N/A' ) {
  1658. if ( tv >= 10 ) { _tvhourly = '#00B300'; }
  1659. else if ( tv >= 7.25 ) { _tvhourly = '#B3B300'; }
  1660. tv = '$' + tv + '/hr';
  1661. }
  1662.  
  1663. var exportcode = '[table][tr][td]'+
  1664. '[b]Title:[/b] [URL=' + pandaurl + hit.prevlink + ']' + hit.title + '[/URL] | [URL=' + pandaurl + hit.pandlink + ']PANDA[/URL]\n' +
  1665. '[b]Requester:[/b] [URL=' + pandaurl + hit.reqlink + ']' + hit.reqname + '[/URL] [' + hit.reqid + '] ([URL=' + pandaurl + hit.conlink + ']Contact[/URL]) ([URL=' + hit.tvlink +']Req TV[/URL]): [B][COLOR=' + _tvhourly + ']' + tv + '[/COLOR][/B]\n' +
  1666. '([URL='+hit.tolink+']TO[/URL]):'+
  1667. '[b] \[Pay: [COLOR=' + _pay + ']' + pay + '[/COLOR]\][/b]'+
  1668. '[b] \[Fair: [COLOR=' + _fair + ']' + fair + '[/COLOR]\][/b]' +
  1669. '[b] \[Comm: [COLOR=' + _comm +']' + comm + '[/COLOR]\][/b]' +
  1670. '[b] \[Fast: [COLOR=' + _fast + ']' + fast + '[/COLOR]\][/b]\n' +
  1671. '[b]Description:[/b] ' + hit.desc + '\n' +
  1672. '[b]Time:[/b] ' + hit.time + '\n' +
  1673. '[b]HITs Available:[/b] ' + hit.avail + '\n' +
  1674. '[b]Reward:[/b] [COLOR=green][b] ' + hit.reward + '[/b][/COLOR]\n' +
  1675. '[b]Qualifications:[/b] ' + hit.quals + '\n' +
  1676. '[/td][/tr][/table]';
  1677.  
  1678. GM_setClipboard(exportcode);
  1679. alert('Forum export has been copied to your clipboard.');
  1680. }
  1681.  
  1682. function _export_irc (key) {
  1683. var hit = hitlog[key];
  1684.  
  1685. $.get('https://ns4t.net/yourls-api.php?action=bulkshortener&title=MTurk&signature=39f6cf4959&urls[]=' + hit.prevlink + '&urls[]=' + hit.pandlink, function (data) {
  1686. var urls = data.split(';'),
  1687. preview = urls[0],
  1688. panda = urls[1];
  1689.  
  1690. var exportcode = hit.masters === 'Y' ? 'MASTERS ■ Req: ' + hit.reqname + ' ■ Title: ' + hit.title + ' ■ Reward: ' + hit.reward : 'Req: ' + hit.reqname + ' ■ Title: ' + hit.title + ' ■ Reward: ' + hit.reward;
  1691. exportcode += preview !== panda ? ' ■ Prev: ' + preview + ' ■ PandA: '+ panda : ' ■ Search: ' + preview;
  1692. exportcode += ' ■ TO: (Pay: ' + hit.to.pay + ') (Fair: ' + hit.to.fair + ') (Comm: ' + hit.to.comm + ') (Fast: ' + hit.to.fast + ')';
  1693.  
  1694. GM_setClipboard(exportcode);
  1695. alert('IRC export has been copied to your clipboard.');
  1696.  
  1697. }).fail(function () {
  1698. alert('Failed to shorten links.');
  1699. });
  1700. }
  1701.  
  1702. function _json_validator (data) {
  1703. try {
  1704. JSON.parse(data);
  1705. return true;
  1706. }
  1707. catch (e) {
  1708. return false;
  1709. }
  1710. }
  1711.  
  1712. function _save (type) {
  1713. if (type !== 'init' && type !== 'custom') {
  1714. config.delay = $('#delay') .val();
  1715. config.rew = $('#min_rew') .val();
  1716. config.avail = $('#min_avail') .val();
  1717. config.mto = $('#min_to') .val();
  1718. config.alert = $('#alert_delay') .val();
  1719. config.type = $('#type') .val();
  1720. config.size = $('#size') .val();
  1721. config.newaudio = $('#new_audio') .val();
  1722. config.theme = $('#adv_theme') .val();
  1723. config.to_theme = $('#to_theme') .val();
  1724.  
  1725. config.new = $('#new_sound') .prop('checked');
  1726. config.pb = $('#pb') .prop('checked');
  1727. config.to = $('#to') .prop('checked');
  1728. config.qual = $('#qual') .prop('checked');
  1729. config.nl = $('#nl_hide') .prop('checked');
  1730. config.bl = $('#bl_hide') .prop('checked');
  1731. config.m = $('#m_hide') .prop('checked');
  1732. console.log($('#push').val());
  1733.  
  1734. }
  1735. if (type === 'custom' && $('#adv_theme').val() === 'custom') {
  1736. config.custom = {
  1737. main : $('#theme_main') .val(),
  1738. primary : $('#theme_primary') .val(),
  1739. secondary : $('#theme_secondary') .val(),
  1740. text : $('#theme_text') .val(),
  1741. link : $('#theme_link') .val(),
  1742. visited : $('#theme_visited') .val(),
  1743. prop : false
  1744. };
  1745. themes.custom = config.custom;
  1746. }
  1747. config.push = $('#push').val();
  1748.  
  1749. localStorage.setItem('_finder', JSON.stringify(config));
  1750. localStorage.setItem('_finder_bl', JSON.stringify(blocklist));
  1751. localStorage.setItem('_finder_il', JSON.stringify(includelist));
  1752.  
  1753. if (config.nl) { $('.nl').toggleClass('nl nl_hidden'); }
  1754. else { $('.nl_hidden').toggleClass('nl nl_hidden'); }
  1755.  
  1756. if (config.bl) { $('.bl').toggleClass('bl bl_hidden'); }
  1757. else { $('.bl_hidden').toggleClass('bl bl_hidden'); }
  1758.  
  1759. if (config.m) { $('.m').toggleClass('m m_hidden'); }
  1760. else { $('.m_hidden').toggleClass('m m_hidden'); }
  1761. }
  1762.  
  1763. function _theme () {
  1764. var theme = themes[config.theme];
  1765.  
  1766. $('#theme_main') .val(theme.main) .prop('disabled', theme.prop);
  1767. $('#theme_primary') .val(theme.primary) .prop('disabled', theme.prop);
  1768. $('#theme_secondary') .val(theme.secondary) .prop('disabled', theme.prop);
  1769. $('#theme_text') .val(theme.text) .prop('disabled', theme.prop);
  1770. $('#theme_link') .val(theme.link) .prop('disabled', theme.prop);
  1771. $('#theme_visited') .val(theme.visited) .prop('disabled', theme.prop);
  1772. _write_theme();
  1773. }
  1774.  
  1775. function _write_theme () {
  1776. var css = _to_theme(), theme = themes[config.theme];
  1777.  
  1778. css +=
  1779. 'html {color: #' + theme.text + '; background-color: #' + theme.main + '; line-height: 1.5; font-family: "Roboto", sans-serif; font-size: 15px; font-weight: normal;}' +
  1780. 'body {margin: 0px;}' +
  1781. '#menubar { background-color: #' + theme.menu + '; margin: 0px; padding: 3px; height:30px; color: #' + theme.menutext + ' }' +
  1782. '#latest_hits { margin: 5px; }' +
  1783. '#logged_hits { margin: 5px; }' +
  1784. '#config { background-color: #' + theme.primary + '; border: 2px #' + theme.text + ' solid; padding: 2px;}' +
  1785.  
  1786. '#bl_items, #il_items {background-color: #'+theme.main+'; height: calc(100% - 64px); overflow-y: scroll;}' +
  1787. '#bl_div, #il_div {background-color: #'+theme.primary+'; border: 2px solid #'+theme.secondary+';}' +
  1788.  
  1789. '.add {background-color: #'+theme.primary+'; border: 2px solid #'+theme.secondary+';}' +
  1790.  
  1791. '.bl {border: 2px solid #FF0000;}' +
  1792. '.il {border: 2px solid #009900;}' +
  1793. '.hidden, .nl_hidden, .bl_hidden, .m_hidden {display: none;}' +
  1794. 'button:focus {outline: none !important;}';
  1795.  
  1796. if (config.theme == 'light' ) {
  1797. css +=
  1798. '.tvHigh {background-color: rgba(0,128,0,0.3); }' +
  1799. '.tvFair {background-color: rgba(255,165, 0, 0.3);}' +
  1800. '.tvLow {background-color: rgba(255,0,0,0.3); }' +
  1801. '.tvNone {background-color: rgba(128,128,128, 0.3); }'
  1802. }
  1803.  
  1804. $('#css').html(css);
  1805. }
  1806.  
  1807. function _to_theme () {
  1808. var to, theme = themes[config.theme], color = '';
  1809. console.log(config.to_theme);
  1810. if (config.theme === 'default') {
  1811. color = 'd9d9d9';
  1812. }
  1813. else {
  1814. color = '262626';
  1815. }
  1816.  
  1817. switch (config.to_theme) {
  1818. case '1':
  1819. to =
  1820. 'td {font-weight: bold;}' +
  1821. '.cont, .hit, .details {color: #000000;}' +
  1822. '.toHigh {background-color: #33cc59;}' +
  1823. '.toGood {background-color: #a6cc33;}' +
  1824. '.toAverage {background-color: #cccc33;}' +
  1825. '.toLow {background-color: #cca633;}' +
  1826. '.toPoor {background-color: #cc3333;}' +
  1827. '.toNone {background-color: #cccccc;}' +
  1828. '.rt, .pc {width: 20px; height: 20px; background-color: transparent; margin: 1px; border: 1px solid #000000; font-size: 80%; padding: 1px;}' +
  1829. '.vb, .irc {width: 25px; height: 20px; background-color: transparent; margin: 1px; border: 1px solid #000000; font-size: 80%; padding: 1px;}' +
  1830. '.clicked {background-color:grey;}';
  1831. ;
  1832. return to;
  1833. case '2':
  1834. to =
  1835. 'a {color: #'+theme.link+';}' +
  1836. 'a:visited {color: #'+theme.visited+';}' +
  1837. 'tbody td {color: #'+theme.text+';}' +
  1838. '.to a {color: #000000;}' +
  1839.  
  1840. '.cont, .details {color: #'+theme.text+';}' +
  1841. '.toHigh {background-color: #'+color+';}' +
  1842. '.toGood {background-color: #'+color+';}' +
  1843. '.toAverage {background-color: #'+color+';}' +
  1844. '.toLow {background-color: #'+color+';}' +
  1845. '.toPoor {background-color: #'+color+';}' +
  1846. '.toNone {background-color: #'+color+';}' +
  1847.  
  1848. '.toHigh .to {background-color: #33cc59;}' +
  1849. '.toGood .to {background-color: #a6cc33;}' +
  1850. '.toAverage .to {background-color: #cccc33;}' +
  1851. '.toLow .to {background-color: #cca633;}' +
  1852. '.toPoor .to {background-color: #cc3333;}' +
  1853. '.toNone .to {background-color: #cccccc;}' +
  1854. '.rt, .pc {width: 20px; height: 20px; color: #'+theme.text+'; background-color: transparent; margin: 1px; border: 1px solid #'+theme.text+'; font-size: 80%; padding: 1px;}' +
  1855. '.vb, .irc {width: 25px; height: 20px; color: #'+theme.text+'; background-color: transparent; margin: 1px; border: 1px solid #'+theme.text+'; font-size: 80%; padding: 1px;}' +
  1856. '.clicked {background-color:grey;}';
  1857. ;
  1858. return to;
  1859. case '3':
  1860. to =
  1861. 'a {color: #'+theme.link+';}' +
  1862. 'a:visited {color: #'+theme.visited+';}' +
  1863. 'tbody td {color: #'+theme.text+';}' +
  1864.  
  1865. '.cont, .details {color: #'+theme.text+';}' +
  1866. '.toHigh {background-color: #'+color+';}' +
  1867. '.toGood {background-color: #'+color+';}' +
  1868. '.toAverage {background-color: #'+color+';}' +
  1869. '.toLow {background-color: #'+color+';}' +
  1870. '.toPoor {background-color: #'+color+';}' +
  1871. '.toNone {background-color: #'+color+';}' +
  1872.  
  1873. '.toHigh .to a {color: #33cc59;}' +
  1874. '.toGood .to a {color: #a6cc33;}' +
  1875. '.toAverage .to a {color: #cccc33;}' +
  1876. '.toLow .to a {color: #cca633;}' +
  1877. '.toPoor .to a {color: #cc3333;}' +
  1878. '.toNone .to a {color: #cccccc;}' +
  1879. '.rt, .pc {width: 20px; height: 20px; color: #'+theme.text+'; background-color: transparent; margin: 1px; border: 1px solid #'+theme.text+'; font-size: 80%; padding: 1px;}' +
  1880. '.vb, .irc {width: 25px; height: 20px; color: #'+theme.text+'; background-color: transparent; margin: 1px; border: 1px solid #'+theme.text+'; font-size: 80%; padding: 1px;}' +
  1881. '.clicked {background-color:grey;}';
  1882. ;
  1883. return to;
  1884. }
  1885. }
  1886.  
  1887. $('#type option[value="' + config.type + '"]') .prop('selected', true);
  1888. $('#size option[value="' + config.size + '"]') .prop('selected', true);
  1889. $('#new_audio option[value="' + config.newaudio + '"]') .prop('selected', true);
  1890. $('#adv_theme option[value="' + config.theme + '"]') .prop('selected', true);
  1891. $('#to_theme option[value="' + config.to_theme + '"]') .prop('selected', true);
  1892.  
  1893. _theme();
  1894. _init_lists();
  1895. _loadTVData();
  1896. _hide_hit_list( config.h_hidden == '1' ? true : false );
  1897. _hide_log_list( config.l_hidden == '1' ? true : false );

QingJ © 2025

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