HIT Forker

Monitors mturk.com for HITs

目前為 2019-06-11 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name HIT Forker
  3. // @version 1.2.1
  4. // @description Monitors mturk.com for HITs
  5. // @author ThisPoorGuy
  6. // @icon https://i.imgur.com/RaPUMRP.png
  7. // @include https://worker.mturk.com/?finder_beta_test
  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. // @require https://cdnjs.cloudflare.com/ajax/libs/dompurify/1.0.8/purify.min.js
  15.  
  16. // @namespace https://gf.qytechs.cn/users/163167
  17. // ==/UserScript==
  18.  
  19. // Acknowledgements
  20. // The core of this script was forked/stolen/adapted from Kadauchi's Hit Finder Beta script. Coding assistance in spots
  21. // provided by Salem Beats and ChrisTurk. TurkerView was created by ChrisTurk. This script hooks into JR Panda Crazy
  22. // Slothbear provided the code for text to speech, thanks!
  23.  
  24. // Changelog
  25. // 1.2.1 - Fixed bug with TO API call to catch JSON error (Thanks THFYM for the tip!)
  26. // 1.2 - Added option to turn off TurkerView if you desire such things.
  27. // 1.1.1 = Fixed an issue with the TV API where it will stop if it encounters an error
  28. // 1.1 - Added new TurkerView API code
  29. // 1.0.6.1 - Further input sanatization improvements
  30. // 1.0.5 - Minor update to change the soundjay links to https to stop mixed content complaining.
  31. // 1.0.4 - Added an I button to the HIT log/HIT list so you can just click once to add something to the include list.
  32. // 1.0.3 - Further work on input sanitization
  33. // 1.0.2 - Fixed the issue where some asshat decided to inject code into a HIT name. THIS IS WHY WE CAN'T HAVE NICE THINGS.
  34. // 1.0.1 - Fixed IRC Export function. You're welcome one guy using IRC exports.
  35. // 1.0.0 - Added Text to speech for include list hits. There's a TTS checkbox in the show config section, this will override any sounds set up on your include list with a
  36. // text to speech notification. In order for the alert to trigger you need an include list entry with play sound enabled. Which sound you pick won't matter as this
  37. // will ignore that setting and use a vocal alert. Thanks to slothbear for the code.
  38. // 0.8.1.2 - Fixed an issue exporting HITS that have quotes in the title.
  39. // 0.8.1.1 - Added a limit to the number of characters you can stick into the fields on adding something to the block list to prevent accidental pasting of a block list import into the wrong spot.
  40. // 0.8.1 - Fixed a couple of export formatting bugs.
  41. // 0.8.0 - Added the ability to press a button to launch a qualification test if you don't qualify for something and a test is availible.
  42. // Working on adding requesting for auto-grant quals, but that's...trickier.
  43. // 0.7.6 - Fixed issue with the search qualified check box not working.
  44. // 0.7.5 - Added abilible hits to the Log display. Note this only shows the data from the time when the HIT was first seen, not any subsequent scans of it.
  45. // 0.7.4 - Removed column for masters, it wasn't used for anything and was broken anyway. Also removed hide masters because it worked off of that code, which wasn't working anyway
  46. // 0.7.3 - Returned a semi-colon to it's rightful position, even though it wasn't missed
  47. // 0.7.2 - Made it so that the Panda button sets pandas without once=true set. Whoops.
  48. // 0.7.0 - Big under the hood changes with how TV and TO review scores are gathered.
  49. // 0.6.5 - Further modifications to prevent availibility of external sites causing HF to stop randomly.
  50. // 0.6.4 - Send RequesterID over to PandaCrazy along with the other info.
  51. // 0.6.3 - Bringing PC functionality in house
  52. // 0.6.1 - Fixed panda button shading
  53. // 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.
  54. // 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...
  55. // 0.5.2 - Code cleanup.
  56. // 0.5.1 - Fixed the panda buttons on the Found hits table.
  57. // 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?
  58. // - Fixed a stupid typo in a variable name.
  59. // 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.
  60. // 0.4.2 - Link to TV Requester profile in export.
  61. // 0.4.1 - Show/Hide HITs and Logged Hits settings are now saved across sessions
  62. // 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
  63. // 0.3.5 - Added a button to hide the new HITS table. Moved the button to hide the logged hits for consistancy.
  64. // 0.3.2 - Modified icon for desktop notifications. Added Requester TV score to hit export
  65. // 0.3.1 - Fix for amazon screwing with things. Thanks ChrisTurk!
  66. // 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
  67. // 0.2.9 - Now acceptable to people with red/green color blindness!
  68. // 0.2.6 - Fixed a minor error which caused colors to not work properly.
  69. // 0.2.5 - Changed Coloration to respect TV reviews FIRST and then fall back on TO Values. Also changed colors.
  70. // 0.2.0 - Added TurkerView Hourly ratings to HIT results, fixed export links.
  71. // 0.1.5 - Some minor UI tweaks
  72. // 0.1.4 - Added some indication that you have already clicked a button to send HIT to PC. Only works in log currently.
  73. // 0.1.3 - Fixed issue with the Panda buttons in the HIT log not having the right GID
  74. // 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.
  75. // 0.1.1 - Cleaned up the header, removed unused audio files
  76. // 0.1.0 - Made modifications to launch links with worker website. Added buttons to send information to PandaCrazy directly instead of copying link
  77. // TODO:
  78. // Remove www code
  79. // Clean up interface
  80. // Delete the above todos because they're already done.
  81.  
  82. const ver = GM_info.scriptMetaStr.match(/version.*?(\d+.*)/)[1];
  83. var worker = true;
  84.  
  85. var _config = JSON.parse(localStorage.getItem('_finder')) || {};
  86. _config.tv_api_key = localStorage.getItem('turkerview_api_key') || '';
  87. var blocklist = JSON.parse(localStorage.getItem('_finder_bl')) || {};
  88. var includelist = JSON.parse(localStorage.getItem('_finder_il')) || {};
  89.  
  90. // Compatability check
  91. if (_config.version !== '1.1') { _config = {}; }
  92.  
  93. var config = {
  94. version : _config.version || '1.1',
  95. delay : _config.delay || '3',
  96. type : _config.type || 'LastUpdatedTime%3A1&pageSize=',
  97. size : _config.size || '25',
  98. rew : _config.rew || '0.00',
  99. avail : _config.avail || '0',
  100. mto : _config.mto || '0.00',
  101. alert : _config.alert || '0',
  102. qual : _config.hasOwnProperty('qual') ? _config.qual : true,
  103. new : _config.hasOwnProperty('new') ? _config.new : true,
  104. newaudio : _config.newaudio || 'beep',
  105. pb : _config.hasOwnProperty('pb') ? _config.pb : false,
  106. to : _config.hasOwnProperty('to') ? _config.to : false,
  107. tv : _config.hasOwnProperty('tv') ? _config.tv : true,
  108. nl : _config.hasOwnProperty('nl') ? _config.nl : false,
  109. bl : _config.hasOwnProperty('bl') ? _config.bl : false,
  110. m : _config.hasOwnProperty('m') ? _config.m : false,
  111. tts : _config.hasOwnProperty('tts') ? _config.tts : false,
  112. push : _config.push || 'access_token_here',
  113. tv_api_key : _config.tv_api_key || '',
  114. disable_tv : _config.disable_tv || false,
  115. theme : _config.theme || 'default',
  116. custom : _config.custom || {main: 'FFFFFF', primary: 'CCCCCC', secondary: '111111', text: '000000', link: '0000EE', visited: '551A8B', prop : false},
  117. to_theme : _config.to_theme || '1',
  118. h_hidden : _config.h_hidden || '0',
  119. l_hidden : _config.l_hidden || '0'
  120. };
  121. console.log(config);
  122. console.log(config.tv_api_key);
  123. var themes = {
  124. 'default' : {main: 'FFFFFF', primary: 'CCCCCC', secondary: '111111', menu: '373b44', menutext: 'FFFFFF', text: '000000', link: '0000EE', visited: '551A8B', prop : true},
  125. 'light' : {main: 'FFFFFF', primary: 'CCCCCC', secondary: '111111', menu: '373b44', menutext: 'FFFFFF', text: '000000', link: '0000EE', visited: '551A8B', prop : true},
  126. 'dark' : {main: '404040', primary: '666666', secondary: 'FFFFFF', menu: '202020', menutext: 'FFFFFF', text: 'FFFFFF', link: 'FFFFFF', visited: 'B3B3B3', prop : true},
  127. 'darker' : {main: '000000', primary: '262626', secondary: 'FFFFFF', menu: '373b44', menutext: 'FFFFFF', text: 'FFFFFF', link: 'FFFFFF', visited: 'B3B3B3', prop : true},
  128. 'custom' : config.custom
  129. };
  130.  
  131. var turkerview = { };
  132. var turkerview_update = 0;
  133. var requesters = [ ];
  134. var tvTimeoutCache = [ ];
  135.  
  136. var searches = 0,
  137. logged = 0,
  138. hitlog = {},
  139. noti_delay = [],
  140. push_delay = [];
  141.  
  142. const ViewHeaders = new Headers([
  143. ['X-VIEW-KEY', config.tv_api_key],
  144. ['X-APP-KEY', 'HIT Forker'],
  145. ['X-APP-VER', ver] //SemVer
  146. ]);
  147.  
  148. // General Configuration variables
  149. var url, upd, num, rew, minrew, searchqual, pandaurl;
  150.  
  151. url = 'https://worker.mturk.com/?';
  152. pandaurl = 'https://worker.mturk.com';
  153. upd = '&sort=updated_desc&page_size=';
  154. num = '&sort=num_hits_desc&page_size=';
  155. rew = '&sort=reward_desc&page_size=';
  156. minrew = '&filters%5Bmin_reward%5D=';
  157. searchqual = '&filters%5Bqualified=';
  158.  
  159. var PandaCrazy = (function createPandaCrazy() {
  160. let _self = this;
  161.  
  162. let _lastSentPingTime;
  163. let _lastReceivedPongTime;
  164.  
  165. let _onlineSinceLastPing;
  166.  
  167. let _pcListener;
  168.  
  169. const MAX_WAIT_FOR_PANDA_CRAZY_RESPONSE_MS = 1000;
  170.  
  171. function ping() {
  172. _lastSentPingTime = Date.now();
  173. localStorage.setItem("JR_message_ping_pandacrazy", `{"theTarget": "${Math.random()}"}`);
  174. }
  175.  
  176. function hasIndicatedOnlineSinceLastPing() {
  177. if(_lastSentPingTime !== undefined && _lastReceivedPongTime !== undefined) {
  178. return _lastReceivedPongTime >= _lastSentPingTime;
  179. }
  180. else {
  181. return undefined;
  182. }
  183. }
  184.  
  185. function online() {
  186.  
  187. function respondToStorage(resolve, reject, e) {
  188. if(e.key.includes("JR_message_pong") && Boolean(e.newValue)) {
  189.  
  190. _lastReceivedPongTime = Date.now();
  191.  
  192. let pongData = JSON.parse(e.newValue);
  193.  
  194. let lag = Number(pongData.time) - Number(_lastReceivedPongTime);
  195.  
  196. if(hasIndicatedOnlineSinceLastPing()) {
  197. resolve("online");
  198. }
  199. }
  200. }
  201.  
  202. let isOnlinePromise = new Promise((resolve, reject) => {
  203.  
  204. setTimeout(() => {reject("timeout");}, MAX_WAIT_FOR_PANDA_CRAZY_RESPONSE_MS);
  205.  
  206. if(_pcListener) {window.removeEventListener("storage", _pcListener);}
  207.  
  208. _pcListener = respondToStorage.bind(window, resolve, reject);
  209.  
  210. window.addEventListener("storage", _pcListener);
  211.  
  212. /*
  213. window.addEventListener("storage", e => {
  214.  
  215. // console.log("Storage Event", e);
  216.  
  217. if(e.key.includes("JR_message_pong") && Boolean(e.newValue)) {
  218.  
  219. _lastReceivedPongTime = Date.now();
  220.  
  221. let pongData = JSON.parse(e.newValue);
  222.  
  223. let lag = Number(pongData.time) - Number(_lastReceivedPongTime);
  224.  
  225. if(hasIndicatedOnlineSinceLastPing()) {
  226. resolve("online");
  227. }
  228. }
  229. });
  230. */
  231. });
  232.  
  233. ping();
  234.  
  235. return isOnlinePromise;
  236. }
  237.  
  238. function addJob(gid, once, metadata) {
  239. let commandString = once ? "addOnceJob" : "addJob";
  240.  
  241. localStorage.setItem("JR_message_pandacrazy", JSON.stringify({
  242. time: Date.now(),
  243. command: commandString,
  244. data: {
  245. groupId: gid,
  246. title: (metadata ? metadata.hitTitle || metadata.title : undefined),
  247. requesterName: (metadata ? metadata.requesterName : undefined),
  248. requesterId: (metadata ? metadata.requesterID || metadata.requesterId || metadata.rid : undefined),
  249. pay: (metadata ? metadata.hitValue || metadata.pay : undefined),
  250. duration: (metadata ? metadata.duration : undefined),
  251. hitsAvailable: (metadata ? metadata.hitsAvailable : undefined)
  252. }
  253. }));
  254. }
  255.  
  256. function startJob(gid) {
  257. localStorage.setItem("JR_message_pandacrazy", JSON.stringify({
  258. time: Date.now(),
  259. command: "startcollect",
  260. data: {
  261. groupId: gid
  262. }
  263. }));
  264. }
  265.  
  266. return {
  267. addJob,
  268. startJob,
  269. ping,
  270. online
  271. };
  272. })();
  273.  
  274. const SPEECH_VOICE = 3; //0 - 21ish
  275. const SPEECH_RATE = 0.9; //1 - 10 (default is 1)
  276. const SPEECH_VOLUME = 1; //0 - 1 (default is 1)
  277. const SPEECH_LANG = 'en-US'; //(default is 'en')
  278.  
  279.  
  280.  
  281. //this is what does it all!
  282. unsafeWindow.slothbearsTTS = function(obj) {
  283. let phrase = "Hit Found!" + obj.name;
  284. var speech = new Speech();
  285. if (speech.supported()) {
  286. speech.speak(phrase);
  287. }
  288. };
  289.  
  290.  
  291.  
  292. var Speech = function() {
  293. };
  294.  
  295. Speech.voices = null;
  296.  
  297. (function() {
  298. if ('speechSynthesis' in window) {
  299. // First call to getVoices may be null...later an event indicates when it is loaded
  300. Speech.voices = window.speechSynthesis.getVoices();
  301.  
  302. // Save voices when loaded after first call
  303. window.speechSynthesis.onvoiceschanged = function() {
  304. Speech.voices = window.speechSynthesis.getVoices();
  305. };
  306. }
  307. })();
  308.  
  309. Speech.prototype.supported = function() {
  310. return Speech.voices !== null;
  311. };
  312.  
  313. Speech.prototype.speak = function(text) {
  314. if (Speech.voices !== null) {
  315. var speech = new SpeechSynthesisUtterance(text);
  316.  
  317. speech.rate = SPEECH_RATE;
  318. speech.voice = speechSynthesis.getVoices()[SPEECH_VOICE];
  319. speech.lang = SPEECH_LANG;
  320. speech.volume = SPEECH_VOLUME;
  321. window.speechSynthesis.speak(speech);
  322. }
  323. };
  324.  
  325. $('head').html(
  326. '<title>HIT Forker</title>' +
  327. '<link rel="icon" type="image/jpg" href="http://nopurpose.org/stuff/avatars/Lj21396.gif">' +
  328. '<base target="_blank">' +
  329.  
  330. '<audio id="audio_1"><source src="https://www.soundjay.com/button/sounds/button-1.mp3" type="audio/mpeg"></audio>' +
  331. '<audio id="audio_2"><source src="https://www.soundjay.com/button/sounds/button-3.mp3" type="audio/mpeg"></audio>' +
  332. '<audio id="audio_3"><source src="https://www.soundjay.com/button/sounds/button-4.mp3" type="audio/mpeg"></audio>' +
  333. '<audio id="audio_4"><source src="https://www.soundjay.com/button/sounds/button-5.mp3" type="audio/mpeg"></audio>' +
  334. '<audio id="audio_beep"><source src="https://www.soundjay.com/button/sounds/beep-21.mp3" type="audio/mpeg"></audio>' +
  335. '<audio id="audio_beepbeep"><source src="https://www.soundjay.com/button/sounds/beep-24.mp3" type="audio/mpeg"></audio>' +
  336. '<audio id="audio_click"><source src="https://www.soundjay.com/button/sounds/button-20.mp3" type="audio/mpeg"></audio>' +
  337.  
  338. '<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">' +
  339. '<style id="css" type="text/css">'
  340. );
  341.  
  342. $('body').on('click', '.closeTvAlert', function(){
  343. $(this).parent().parent().hide();
  344. });
  345.  
  346. $('body').html(
  347. // Main
  348. '<div style="margin-bottom: 5px; text-align:right;" id="menubar">' +
  349. '<div style="position: absolute; top: 32px width: 100px; font-size: 14pt; font-weight: bold;" id="menu_title">HIT Forker</div>'+
  350. '<div style="line-height: 30px; margin-right:5px;">'+
  351. '<button id="scan_button" style="margin-right: 5px;">Start</button>' +
  352. '<button id="bloc_button" style="margin-right: 5px;">Block List</button>' +
  353. '<button id="incl_button" style="margin-right: 5px;">Include List</button>' +
  354. '<button id="sett_button" style="margin-right: 5px;">Advanced Settings</button>' +
  355. '<button id="conf_button" style="margin-right: 5px;">Show Config</button>' +
  356.  
  357. '</div></div>' +
  358.  
  359. // Config
  360. '<div id="config" style="position: absolute; top: 37px; right: 5px; margin-bottom: 5px;" class="hidden">' +
  361.  
  362. '<div style="margin-bottom: 5px;">' +
  363. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;" title="Delay in seconds between searches.">Search Delay: ' +
  364. '<input id="delay" style="width: 50px;" type="number" step="1" min="1" value="' + config.delay + '">' +
  365. '</label>' +
  366.  
  367. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;" title="Filter HITs by minimum reward.">Min Reward: ' +
  368. '<input id="min_rew" style="width: 50px;" type="number" step="0.01" min="0" value="' + config.rew + '">' +
  369. '</label>' +
  370.  
  371. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;" title="Filter HITs by minimum available.">Min Avail: ' +
  372. '<input id="min_avail" style="width: 50px;" type="number" step="1" min="0" value="' + config.avail + '">' +
  373. '</label>' +
  374.  
  375. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;" title="Filter HITs by minimum TO pay.">Min TO: ' +
  376. '<input id="min_to" style="width: 50px;" type="number" step="0.1" min="0" max="5" value="' + config.mto + '">' +
  377. '</label>' +
  378.  
  379. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;" title="Search for this many HITs.">Size: ' +
  380. '<input id="size" style="width: 50px;" type="number" step="1" min="1" max="100" value="' + config.size + '">' +
  381. '</label>' +
  382.  
  383. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;" title="Sort HITs by (Latest / Most Available / Highest Reward)">Sort by: ' +
  384. '<select id="type" value="' + config.type + '">' +
  385. '<option value="' + upd + '">Latest</option>' +
  386. '<option value="' + num + '">Most Available</option>' +
  387. '<option value="' + rew + '">Reward (Most)</option>' +
  388. '</select>' +
  389. '</label>' +
  390.  
  391. '<label style="margin-right: 0px; display: inline-block; border-bottom: 1px solid;" title="Only show HITs that you are for.">Qualified' +
  392. '<input id="qual" type="checkbox" ' + (config.qual ? 'checked' : '') + '>' +
  393. '</label>' +
  394. '</div>' +
  395.  
  396. '<div style="margin-bottom: 5px;">' +
  397. '<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: ' +
  398. '<input id="alert_delay" style="width: 50px;" type="number" step="1" min="0" value="' + config.alert + '">' +
  399. '</label>' +
  400.  
  401. '<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 ' +
  402. '<input id="new_sound" type="checkbox" ' + (config.new ? 'checked' : '') + '>' +
  403. '<select id="new_audio" value="' + config.newaudio + '">' +
  404. //'<option value="default">Default</option>' +
  405. '<option value="beep">Beep</option>' +
  406. '<option value="beepbeep">Beep Beep</option>' +
  407. //'<option value="ding">Ding</option>' +
  408. //'<option value="squee">Squee</option>' +
  409. '<option value="click">Click</option>' +
  410. '</select>' +
  411. '</label>' +
  412.  
  413. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;" title="Allow include list to send a TTS notification when matched">TTS ' +
  414. '<input id="tts" type="checkbox" ' + (config.tts ? 'checked' : '') + '>' +
  415. '</label>' +
  416.  
  417. '<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 ' +
  418. '<input id="pb" type="checkbox" ' + (config.pb ? 'checked' : '') + '>' +
  419. '</label>' +
  420.  
  421. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;" title="Use turkopticon.">Enable TO ' +
  422. '<input id="to" type="checkbox" ' + (config.to ? 'checked' : '') + '>' +
  423. '</label>' +
  424.  
  425. '<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 ' +
  426. '<input id="nl_hide" type="checkbox" ' + (config.nl ? 'checked' : '') + '>' +
  427. '</label>' +
  428.  
  429. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;" title="Hide HITs that match your block list.">Hide Block List ' +
  430. '<input id="bl_hide" type="checkbox" ' + (config.bl ? 'checked' : '') + '>' +
  431. '</label>' +
  432.  
  433. '</div>' +
  434.  
  435. '</div>' +
  436.  
  437. '<div id="TVAlert" style="background-color: #dff0d8; border-color: #d0e9c6;' + (((config.tv_api_key == '' || config.tv_api_key.length != 40) && !config.disable_tv) ? `` : ` display: none; `) +' color: #3c763d; padding: 15px; margin-bottom: 1rem; border: 1px solid transparent; border-radius: 2px; margin: auto; width: 60%; padding-top: 10px; padding-bottom: 10px;">' +
  438. '<h4 style="font-size: 0.857rem; margin-bottom: 0.5rem; margin-top: 0.5rem;">TurkerView API Changes (<span class="closeTvAlert" style="cursor: pointer;">Dismiss</span>)</h4>' +
  439.  
  440. `<small>
  441. <p>Sorry for the intrusion, but we're expanding our services & infrastructure and making huge improvements to the way we deliver information & data to Turkers in 2019!</p>
  442. <p>HIT Forker has been updated to function with TurkerView's new View API [<a href="https://forum.turkerview.com/threads/hit-forker-update.2025/" target="_blank">details here</a>]
  443. <p>TVJS 10 is out! You can read change details <a href="https://forum.turkerview.com/threads/turkerviewjs-10.2010/" target="_blank">here</a> - including improvements to approval (AA) time tracking! You can find more information about the full API changes <a href="https://forum.turkerview.com/threads/view-api-details.2012/" target="_blank" style="text-decoration: underline;">on our announcement here</a>.</p>
  444. <p>Make sure to register & get your new access keys to our upgraded API by <a href="https://turkerview.com/account/api/" target="_blank" style="text-decoration: underline;">visiting your account dashboard</a>. We'll stop displaying this as soon as you do, but the script wont be able to retrieve TV data after February 1st without an API Key.</p>
  445. </small><form action="saveForkerApiForm" onsubmit="return false;">
  446. <input type="text" class="form-control" style="max-width: 50%; margin-top: 5px; margin-bottom: 5px;">
  447. <button type="submit" class="btn btn-primary">Save API Key</button>
  448. </form>
  449. <script>
  450. $('form[action*=saveForkerApiForm]').submit(function(e){
  451. e.preventDefault();
  452. let api_key = $(this).find('input[type=text]').val().trim();
  453. console.log(api_key);
  454. if (api_key.length == 40){
  455. localStorage.setItem('turkerview_api_key', api_key);
  456. alert('Awesome, we saved your API key for future use! HIT Forker will reload now.');
  457. window.location.reload();
  458. } else {
  459. alert("We cannot save the provided key as it isn't valid.");
  460. }
  461. });
  462. </script>` +
  463.  
  464. '</div>'+
  465.  
  466. '<div id="TVErrorMessage" style="display: none; background-color: #f2dede; border-color: #ebcccc; color: #a94442; padding: 15px; margin-bottom: 1rem; border: 1px solid transparent; border-radius: 2px; margin: auto; width: 60%; padding-top: 10px; padding-bottom: 10px;">' +
  467. '<h4 style="font-size: 0.857rem; margin-bottom: 0.5rem; margin-top: 0.5rem;">TurkerView API Error (<span class="closeTvAlert" style="cursor: pointer;">Dismiss</span>)</h4>' +
  468. '<p style="margin-bottom: 0.5rem; margin-top: 0.5rem;">Error Message.</p>' +
  469. '</div>'+
  470. // HITs
  471. '<div id="latest_hits">' +
  472. '<div style="border-bottom: 3px solid; margin-bottom: 5px;">' +
  473. '<span style="font-size: 20px; font-weight: bold;">HITs</span>' +
  474. '<span id="hits_data" style="font-size: 11px;"></span>' +
  475. '<span id="hits_controls" style="float: right"><button id="hits_button" style="margin-right: 5px;">Hide New HITs</button></span>' +
  476. '</div>' +
  477. '<div id="hits_hidden" style="text-align: center; display: none;">--- HITS HIDDEN ---</div>' +
  478. '<div id="hits_table">' +
  479. '<div>' +
  480. '<div style="overflow: hidden; white-space: nowrap;">' +
  481. '<div style="float: left; width: calc(100% - 330px);">' +
  482. '<span style="width: 34%; float: left; display:inline-block; overflow: hidden;">Requester</span>' +
  483. '<span style="width: 64%; float: right; display:inline-block; overflow: hidden;">Project</span>' +
  484. '</div>' +
  485.  
  486. '<div style="float: right;">' +
  487. '<span style="width: 60px; display:inline-block; text-align: center;">Tasks</span>' +
  488. '<span style="width: 60px; display:inline-block; text-align: center;">Accept</span>' +
  489. '<span style="width: 60px; display:inline-block; text-align: center;">TV</span>' +
  490. '<span style="width: 60px; display:inline-block; text-align: center;">TO</span>' +
  491. '<span style="width: 60px; display:inline-block; text-align: center;">PANDA</span>' +
  492. '</div>' +
  493. '</div>' +
  494. '</div>' +
  495. '<div id="new_hits_"></div>' +
  496. '</div>' +
  497. '</div>' +
  498.  
  499. '<br>' +
  500.  
  501. //Logged HITs
  502. '<div id="logged_hits">' +
  503. '<div style="border-bottom: 3px solid; margin-bottom: 5px;">' +
  504. '<span style="font-size: 20px; font-weight: bold;">Logged HITs</span>' +
  505. '<span id="logged_hits_data" style="font-size: 11px;"></span>' +
  506. '<span id="log_controls" style="float: right"><button id="logg_button" style="margin-right: 0px;">Hide Logged HITs</button></span>' +
  507. '</div>' +
  508. '<div id="log_hidden" style="text-align: center; display: none;">--- LOGGED HITS HIDDEN ---</div>' +
  509. '<div id="log_table">' +
  510. '<div>' +
  511. '<div style="overflow: hidden; white-space: nowrap;">' +
  512.  
  513. '<div style="float: left;">' +
  514. '<span style="width: 80px; display:inline-block;">Time</span>' +
  515. '</div>' +
  516.  
  517. '<div style="float: left; width: calc(100% - 3500px);">' +
  518. '<span style="width: 25%; float: left; display:inline-block; overflow: hidden;">Requester</span>' +
  519. '<span style="width: 75%; float: right; display:inline-block; overflow: hidden;">Project</span>' +
  520.  
  521. '</div>' +
  522.  
  523. '<div style="float: right;">' +
  524. '<span style="width: 60px; display:inline-block; text-align: center;">Avail</span>' +
  525. '<span style="width: 60px; display:inline-block; text-align: center;">Accept</span>' +
  526. '<span style="width: 60px; display:inline-block; text-align: center;">TV</span>' +
  527. '<span style="width: 60px; display:inline-block; text-align: center;">TO</span>' +
  528. '<span style="width: 60px; display:inline-block; text-align: center;">PANDA</span>' +
  529. '</div>' +
  530. '</div>' +
  531. '</div>' +
  532. '<div id="log_hits_"></div>' +
  533. '</div>' +
  534. '</div>' +
  535.  
  536. // Block List
  537. '<div id="bl_div" style="z-index: 99; position: fixed; width: 80%; height: 80%; left: 10%; top: 300px; margin-top: -250px; display: none;">' +
  538. '<div style="position: relative; width: 80%; left: 10%; border-bottom: 3px solid; padding: 2px; text-align: center;">Block List</div>' +
  539. '<div id="bl_items"></div>' +
  540. '<div style="text-align: center;">' +
  541. '<button id="bl_add" style="margin-right: 5px;">Add</button>' +
  542. '<button id="bl_close" style="margin-right: 5px;">Close</button>' +
  543. '<button id="bl_import" style="margin-right: 5px;">Import</button>' +
  544. '<button id="bl_export" style="margin-right: 0px;">Export</button>' +
  545. '</div>' +
  546. '</div>' +
  547.  
  548. // Add Block List Popup
  549. '<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;">' +
  550. '<div style="position: relative; width: 80%; left: 10%; border-bottom: 3px solid; padding: 2px; text-align: center;">Add To Block List</div>' +
  551.  
  552. '<div>' +
  553. '<p><label>Term: </label><input id="bl_term" value="" maxlength="300"></p>' +
  554. '<p><label>Name: </label><input id="bl_name" value="" maxlength="300"></p>' +
  555. '<input id="bl_gid" value="0" type="hidden">' +
  556. '</div>' +
  557.  
  558. '<div>' +
  559. '<button id="bl_add_save" style="margin-right: 5px;">Save</button>' +
  560. '<button id="bl_add_cancel" style="margin-right: 0px;">Cancel</button>' +
  561. '</div>' +
  562. '</div>' +
  563.  
  564. // Edit Block List Popup
  565. '<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;">' +
  566. '<div style="position: relative; width: 80%; left: 10%; border-bottom: 3px solid; padding: 2px; text-align: center;">Edit Block List Item</div>' +
  567.  
  568. '<div>' +
  569. '<p><label>Term: </label><input id="edit_bl_term" value=""disabled></p>' +
  570. '<p><label>Name: </label><input id="edit_bl_name" value=""></p>' +
  571. '</div>' +
  572.  
  573. '<div>' +
  574. '<button id="edit_bl_save" style="margin-right: 5px;">Save</button>' +
  575. '<button id="edit_bl_delete" style="margin-right: 5px;">Delete</button>' +
  576. '<button id="edit_bl_cancel" style="margin-right: 0px;">Cancel</button>' +
  577. '</div>' +
  578. '</div>' +
  579.  
  580. // Include List
  581. '<div id="il_div" style="z-index: 99; position: fixed; width: 80%; height: 80%; left: 10%; top: 300px; margin-top: -250px; display: none;">' +
  582. '<div style="position: relative; width: 80%; left: 10%; border-bottom: 3px solid; padding: 2px; text-align: center;">Include List</div>' +
  583. '<div id="il_items"></div>' +
  584. '<div style="text-align: center;">' +
  585. '<button id="il_add" style="margin-right: 5px;">Add</button>' +
  586. '<button id="il_close" style="margin-right: 5px;">Close</button>' +
  587. '<button id="il_import" style="margin-right: 5px;">Import</button>' +
  588. '<button id="il_export" style="margin-right: 0px;">Export</button>' +
  589. '</div>' +
  590. '</div>' +
  591.  
  592. // Add Include List Popup
  593. '<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;">' +
  594. '<div style="position: relative; width: 80%; left: 10%; border-bottom: 3px solid; padding: 2px; text-align: center;">Add To Include List</div>' +
  595.  
  596. '<div>' +
  597. '<p><label>Term: </label><input id="il_term" value=""></p>' +
  598. '<p><label>Name: </label><input id="il_name" value=""></p>' +
  599. '</div>' +
  600.  
  601. '<div style="position: relative; width: 80%; left: 10%; border-bottom: 3px solid; padding: 2px; text-align: center;">Alerts</div>' +
  602.  
  603. '<p>' +
  604. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;">Sound: ' +
  605. '<select id="il_sound">' +
  606. '<option value="1">Sound 1</option>' +
  607. '<option value="2">Sound 2</option>' +
  608. '<option value="3">Sound 3</option>' +
  609. '<option value="4">Sound 4</option>' +
  610. '</select>' +
  611. '</label>' +
  612.  
  613. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;">Desktop Notifications' +
  614. '<input id="il_noti_cb" type="checkbox">' +
  615. '</label>' +
  616.  
  617. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;">Play Sound' +
  618. '<input id="il_sound_cb" type="checkbox">' +
  619. '</label>' +
  620.  
  621. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;">Send Pushbullet' +
  622. '<input id="il_push_cb" type="checkbox">' +
  623. '</label>' +
  624. '</p>' +
  625.  
  626. '<div>' +
  627. '<button id="il_add_save" style="margin-right: 5px;">Save</button>' +
  628. '<button id="il_add_cancel" style="margin-right: 0px;">Cancel</button>' +
  629. '</div>' +
  630. '</div>' +
  631.  
  632. // Edit Include List Popup
  633. '<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;">' +
  634. '<div style="position: relative; width: 80%; left: 10%; border-bottom: 3px solid; padding: 2px; text-align: center;">Edit Include List Item</div>' +
  635.  
  636. '<div>' +
  637. '<p><label>Term: </label><input id="edit_il_term" value="" disabled></p>' +
  638. '<p><label>Name: </label><input id="edit_il_name" value=""></p>' +
  639. '</div>' +
  640.  
  641. '<div style="position: relative; width: 80%; left: 10%; border-bottom: 3px solid; padding: 2px; text-align: center;"">Alerts</div>' +
  642.  
  643. '<p>' +
  644. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;">Sound: ' +
  645. '<select id="edit_il_sound">' +
  646. '<option value="1">Sound 1</option>' +
  647. '<option value="2">Sound 2</option>' +
  648. '<option value="3">Sound 3</option>' +
  649. '<option value="4">Sound 4</option>' +
  650. '</select>' +
  651. '</label>' +
  652.  
  653. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;">Desktop Notifications' +
  654. '<input id="edit_il_noti_cb" type="checkbox">' +
  655. '</label>' +
  656.  
  657. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;">Play Sound' +
  658. '<input id="edit_il_sound_cb" type="checkbox">' +
  659. '</label>' +
  660.  
  661. '<label style="margin-right: 0px; display: inline-block; border-bottom: 1px solid;">Send Pushbullet' +
  662. '<input id="edit_il_push_cb" type="checkbox">' +
  663. '</label>' +
  664. '</p>' +
  665.  
  666. '<div>' +
  667. '<button id="edit_il_save" style="margin-right: 5px;">Save</button>' +
  668. '<button id="edit_il_delete" style="margin-right: 5px;">Delete</button>' +
  669. '<button id="edit_il_cancel" style="margin-right: 0px;">Cancel</button>' +
  670. '</div>' +
  671. '</div>' +
  672.  
  673. // Advanced Settings
  674. '<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;">' +
  675. '<div style="position: relative; width: 80%; left: 10%; border-bottom: 3px solid; padding: 2px; text-align: center;">Advanced Settings</div>' +
  676.  
  677. '<div>' +
  678. '<p><label>Pushbullet Token: </label><input id="push" value="' + config.push + '"></p>' +
  679. '</div>' +
  680. '<div style="position: relative; width: 80%; left: 10%; border-bottom: 3px solid; padding: 2px; text-align: center;">TurkerView</div>' +
  681. '<div><p><label>TurkerView API Key: </label><input id="tv_api_key" value="' + ((config.tv_api_key == null || config.tv_api_key.length != 40) ? '' : config.tv_api_key) + '"></p></div>' +
  682. '<div><p><label><input type="checkbox" name="disable_turkerview"' + (config.disable_tv ? 'checked' : '') + '> Disable TurkerView</label></p></div>' +
  683. '<div><p>TurkerView is completely free (no obligation) for a month, we hope you\'ll <a href="" target="_blank">join us & try it</a>, but if not feel free to disable to stop notifications.</p></div>' +
  684.  
  685. '<div style="position: relative; width: 80%; left: 10%; border-bottom: 3px solid; padding: 2px; text-align: center;">Theme</div>' +
  686.  
  687. '<p>' +
  688. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;">Theme: ' +
  689. '<select id="adv_theme" value="' + config.theme + '">' +
  690. '<option value="default">Default (Light)</option>' +
  691. '<option value="light">Pastel</option>' +
  692. '<option value="dark">Dark</option>' +
  693. '<option value="darker">Darker</option>' +
  694. '<option value="custom">Custom</option>' +
  695. '</select>' +
  696. '</label>' +
  697.  
  698. '<label style="margin-right: 0px; display: inline-block; border-bottom: 1px solid;">TO Theme: ' +
  699. '<select id="to_theme" value="' + config.to_theme + '">' +
  700. '<option value="1">Default</option>' +
  701. '<option value="2">Column Only</option>' +
  702. '<option value="3">Text Only</option>' +
  703. '</select>' +
  704. '</label>' +
  705. '</p>' +
  706.  
  707. '<p>' +
  708. '<label style="width: 150px; margin-right: 5px; display: inline-block; border-bottom: 1px solid; text-align: left;">Main: #' +
  709. '<input id="theme_main" style="width: 55px; float: right;" maxlength="6">' +
  710. '</label>' +
  711.  
  712. '<label style="width: 150px; margin-right: 5px; display: inline-block; border-bottom: 1px solid; text-align: left;">Primary: #' +
  713. '<input id="theme_primary" style="width: 55px; float: right;" maxlength="6">' +
  714. '</label>' +
  715.  
  716. '<label style="width: 150px; margin-right: 0px; display: inline-block; border-bottom: 1px solid; text-align: left;">Secondary: #' +
  717. '<input id="theme_secondary" style="width: 55px; float: right;" maxlength="6">' +
  718. '</label>' +
  719. '</p>' +
  720.  
  721. '<p>' +
  722. '<label style="width: 150px; margin-right: 5px; display: inline-block; border-bottom: 1px solid; text-align: left;">Text: #' +
  723. '<input id="theme_text" style="width: 55px; float: right;" maxlength="6">' +
  724. '</label>' +
  725.  
  726. '<label style="width: 150px; margin-right: 5px; display: inline-block; border-bottom: 1px solid; text-align: left;">Link: #' +
  727. '<input id="theme_link" style="width: 55px; float: right;" maxlength="6">' +
  728. '</label>' +
  729.  
  730. '<label style="width: 150px; margin-right: 0px; display: inline-block; border-bottom: 1px solid; text-align: left;">Visited: #' +
  731. '<input id="theme_visited" style="width: 55px; float: right;" maxlength="6">' +
  732. '</label>' +
  733. '</p>' +
  734.  
  735. '<div>' +
  736. '<button id="sett_save" style="margin-right: 5px;">Save</button>' +
  737. '<button id="sett_close" style="margin-right: 0px;">Close</button>' +
  738. '</div>' +
  739. '</div>'
  740. );
  741.  
  742. // Click functions
  743. $('#scan_button').click(function () {
  744. if ($(this).text() === 'Start') {
  745. $(this).text('Stop');
  746. _scan();
  747. }
  748. else {
  749. $(this).text('Start');
  750. }
  751. });
  752.  
  753. $('#sett_button').click(function () {
  754. $('#sett').toggle();
  755. });
  756.  
  757. $('#conf_button').click(function () {
  758. if ($(this).text() === 'Hide Config') {
  759. $(this).text('Show Config');
  760. }
  761. else {
  762. $(this).text('Hide Config');
  763. }
  764. $('#config').toggleClass('hidden');
  765. });
  766.  
  767. $('#logg_button').click(function () {
  768. _hide_log_list( $(this).text() === 'Hide Logged HITs' ? true : false );
  769. });
  770.  
  771. $('#hits_button').click(function () {
  772. _hide_hit_list( $(this).text() === 'Hide New HITs' ? true : false );
  773. });
  774.  
  775. $('#bloc_button').click(function () {
  776. $('#bl_div').toggle();
  777. });
  778.  
  779. $('#bl_add').click(function () {
  780. $('#bl').show();
  781. });
  782.  
  783. $('#bl_close').click(function () {
  784. $('#bl_div').hide();
  785. });
  786.  
  787. $('#bl_import').click(function () {
  788. _import_block();
  789. });
  790.  
  791. $('#bl_export').click(function () {
  792. _export_block();
  793. });
  794.  
  795. $('#bl_add_save').click(function () {
  796. var obj = {
  797. term : $('#bl_term').val(),
  798. name : $('#bl_name').val() === '' ? $('#bl_term').val() : $('#bl_name').val(),
  799. gid : $('#bl_gid').val() === '' ? 'X' : $('#bl_gid').val()
  800. };
  801.  
  802. _add_block(obj);
  803.  
  804. if ( obj.gid != 'X' ) {
  805. $('.loggid_' + obj.gid ).remove();
  806. }
  807. else {
  808. $('.logreqid_' + obj.term ).remove();
  809. }
  810.  
  811. $('#bl_term, #bl_name').val('');
  812. $('#bl').hide();
  813. });
  814.  
  815. $('#bl_add_cancel').click(function () {
  816. $('#bl_term, #bl_name').val('');
  817. $('#bl').hide();
  818. });
  819.  
  820. $('#edit_bl_save').click(function () {
  821. _update_block($(this).val());
  822. $('#edit_bl_term, #edit_bl_name').val('');
  823. $('#edit_bl').hide();
  824. });
  825.  
  826. $('#edit_bl_delete').click(function () {
  827. _delete_block($(this).val());
  828. $('#edit_bl_term, #edit_bl_name').val('');
  829. $('#edit_bl').hide();
  830. });
  831.  
  832. $('#edit_bl_cancel').click(function () {
  833. $('#edit_bl_term, #edit_bl_name').val('');
  834. $('#edit_bl').hide();
  835. });
  836.  
  837. $('#incl_button').click(function () {
  838. $('#il_div').toggle();
  839. });
  840.  
  841. $('#il_add').click(function () {
  842. $('#il').show();
  843. });
  844.  
  845. $('#il_close').click(function () {
  846. $('#il_div').hide();
  847. });
  848.  
  849. $('#il_import').click(function () {
  850. _import_include();
  851. });
  852.  
  853. $('#il_export').click(function () {
  854. _export_include();
  855. });
  856.  
  857. $('#il_add_save').click(function () {
  858. var obj = {
  859. term : $('#il_term').val().trim(),
  860. name : $('#il_name').val().trim() === '' ? $('#il_term').val().trim() : $('#il_name').val().trim(),
  861. sound : $('#il_sound').val(),
  862. noti_cb : $('#il_noti_cb').prop('checked'),
  863. sound_cb : $('#il_sound_cb').prop('checked'),
  864. push_cb : $('#il_push_cb').prop('checked')
  865. };
  866.  
  867. _add_include(obj);
  868.  
  869. $('#il_term, #il_name').val('');
  870. $('#il').hide();
  871. });
  872.  
  873. $('#il_add_cancel').click(function () {
  874. $('#il_term, #il_name').val('');
  875. $('#il').hide();
  876. });
  877.  
  878. $('#edit_il_save').click(function () {
  879. _update_include($(this).val());
  880. $('#edit_il_term, #edit_il_name, #edit_il_sound').val('');
  881. $('#edit_il_noti_cb, #edit_il_sound_cb, #edit_il_push_cb').prop('checked', false);
  882. $('#edit_il').hide();
  883. });
  884.  
  885. $('#edit_il_delete').click(function () {
  886. _delete_include($(this).val());
  887. $('#edit_il_term, #edit_il_name, #edit_il_sound').val('');
  888. $('#edit_il_noti_cb, #edit_il_sound_cb, #edit_il_push_cb').prop('checked', false);
  889. $('#edit_il').hide();
  890. });
  891.  
  892. $('#edit_il_cancel').click(function () {
  893. $('#edit_il_term, #edit_il_name, #edit_il_sound').val('');
  894. $('#edit_il_noti_cb, #edit_il_sound_cb, #edit_il_push_cb').prop('checked', false);
  895. $('#edit_il').hide();
  896. });
  897.  
  898. $('.on, .off').click(function () {
  899. $(this).toggleClass('on off');
  900. _save();
  901. });
  902.  
  903. $('#sett_save').click(function () {
  904.  
  905. let original_key = config.tv_api_key;
  906. let new_key = $('#tv_api_key').val();
  907. let disable_tv = $('input[name=disable_turkerview]').is(':checked');
  908. config.disable_tv = disable_tv;
  909. _save('custom');
  910. _theme();
  911. if (original_key != new_key) {
  912. $('#sett').prepend(`<p class="saved-settings-alert">Settings Saved! We'll reload Forker shortly.</p>`);
  913. setTimeout(function() {
  914. window.location.reload();
  915. }, 1000)
  916. } else $('#sett').prepend(`<p class="saved-settings-alert">Settings Saved!</p>`);
  917. });
  918.  
  919. $('#sett_close').click(function () {
  920. $('#sett').find('.saved-settings-alert').remove();
  921. $('#sett').hide();
  922. });
  923.  
  924. $('#time').click(function () {
  925. $('.new').removeClass('new');
  926. });
  927.  
  928. // Delegated click functions
  929. $('body').on('click', '.blockit', function () {
  930. _edit_block($(this).val());
  931. });
  932.  
  933. $('body').on('click', '.includeit', function () {
  934. _edit_include($(this).val());
  935. });
  936.  
  937. $('body').on('click', '.rt', function () {
  938. _block($(this).data('term'), $(this).data('name'), $(this).attr('id'));
  939. });
  940.  
  941. $('body').on('click', '.it', function () {
  942. _includerid($(this).data('term'), $(this).data('name'), $(this).attr('id'));
  943. });
  944.  
  945. $('body').on('click', '.pc', function () {
  946. _panda($(this).data('term'), $(this).data('reqname'), $(this).data('reqid'), $(this).data('title'), $(this).data('value'), $(this).data('name'), $(this))
  947. });
  948.  
  949. $('body').on('click', '.vb', function () {
  950. _export_vb($(this).val());
  951. });
  952.  
  953. $('body').on('click', '.irc', function () {
  954. _export_irc($(this).val());
  955. });
  956.  
  957. $('body').on('click', '.details', function () {
  958. $(this).toggleClass('fa-plus-circle fa-minus-circle');
  959. $('.info[value="' + $(this).val() + '"]').toggle();
  960. });
  961.  
  962. // Delegated mouseover functions
  963. $('body').on('mouseover', '.new', function () {
  964. $(this).removeClass('new');
  965. });
  966.  
  967. // On change events
  968. $('#new_audio').change(function () {
  969. _save();
  970. _sound('new');
  971. });
  972.  
  973. $('#il_sound').change(function () {
  974. _sound('il');
  975. });
  976.  
  977. $('#edit_il_sound').change(function () {
  978. _sound('il_edit');
  979. });
  980.  
  981. $('#type, #size, #adv_theme, #to_theme, #c_theme, :checkbox').change(function () {
  982. _save();
  983. });
  984.  
  985. $('#adv_theme, #to_theme, #c_theme').change(function () {
  986. _theme();
  987. });
  988.  
  989. // On input events
  990. $('#delay, #min_rew, #min_avail, #min_to, #alert_delay').on('input', function () {
  991. _save();
  992. });
  993.  
  994. function sanitize(strings, ...values) {
  995. console.log( strings );
  996. const dirty = strings.reduce((prev, next, i) => `${prev}${next}${values[i]} || ''}`, '');
  997. return DomPurify.sanitize(dirty);
  998. }
  999.  
  1000. function extend(obj, src) {
  1001. for (var key in src) {
  1002. if (src.hasOwnProperty(key)) obj[key] = src[key];
  1003. }
  1004. return obj;
  1005. }
  1006.  
  1007. function _scan () {
  1008. var searchqualvar
  1009. searchqualvar = (config.qual ? 'true' : 'false');
  1010.  
  1011.  
  1012. if ($('#scan_button').text() === 'Stop') {
  1013. var _url = url + $('#type').val() + $('#size').val() + minrew + $('#min_rew').val() + searchqual + searchqualvar;
  1014. //console.log( _url );
  1015. var _scanurl = _url + '&format=json';
  1016.  
  1017. var date = new Date(), h = date.getHours(), m = date.getMinutes(), s = date.getSeconds(), ampm = h >= 12 ? 'pm' : 'am';
  1018. h = h % 12; h = h ? h : 12; m = m < 10 ? '0' + m : m; s = s < 10 ? '0' + s : s;
  1019. var timeis = [h, m, s, ampm];
  1020. console.log( _scanurl );
  1021. $.get(_scanurl, function (data) {
  1022. _scrape_new(data, timeis);
  1023. }).fail(function () {
  1024. setTimeout(function () { _scan(); }, 2500);
  1025. });
  1026. }
  1027. }
  1028.  
  1029. function _scrape_new (data, timeis) {
  1030. var keys = [], log_keys = [], to = [], logged_in = true;
  1031. var new_requesters = [];
  1032. var hits = data.results;
  1033. //Set config for allowed tags
  1034. var config = {
  1035. ALLOWED_TAGS: ['p', '#text']
  1036. };
  1037.  
  1038. for (var i = 0; i < hits.length; i ++) {
  1039. var hit = hits[i],
  1040. req_name = DOMPurify.sanitize(hit.requester_name,config).replace(/"/g, "&quot;" ),
  1041. req_id = DOMPurify.sanitize(hit.requester_id,config),
  1042. req_link = DOMPurify.sanitize(hit.requester_url.replace(/\.json/, ''),config),
  1043. //req_link = 'https://www.mturk.com/mturk/searchbar?selectedSearchType=hitgroups&requesterId=' + hit.requester_id,
  1044. con_link = DOMPurify.sanitize('https://www.mturk.com/mturk/contact?requesterId=' + hit.requester_id, config),
  1045. group_id = DOMPurify.sanitize(hit.hit_set_id,config),
  1046. prev_link = DOMPurify.sanitize(hit.project_tasks_url.replace(/\.json/, ''),config),
  1047. //prev_link = 'https://www.mturk.com/mturk/preview?groupId=' + hit.hit_set_id,
  1048. pand_link = DOMPurify.sanitize(hit.accept_project_task_url.replace(/\.json/, ''),config),
  1049. //pand_link = 'https://www.mturk.com/mturk/previewandaccept?groupId=' + hit.hit_set_id,
  1050. title = DOMPurify.sanitize(hit.title,config),
  1051. safetitle = title.replace(/"/g, "&quot;" ),
  1052. desc = DOMPurify.sanitize(hit.description.replace(/"/g, "&quot;" ),config),
  1053. time = _convert_seconds(hit.assignment_duration_in_seconds),
  1054. reward = DOMPurify.sanitize('$' + hit.monetary_reward.amount_in_dollars.toFixed(2),config),
  1055. avail = DOMPurify.sanitize(hit.assignable_hits_count,config);
  1056.  
  1057. var key = req_id + title + reward + group_id;
  1058. keys.push(key);
  1059.  
  1060. var qualif = 'None';
  1061. var quals = hit.project_requirements;
  1062.  
  1063.  
  1064. if (quals.length) {
  1065.  
  1066. qualif = '';
  1067. for (var j = 0; j < quals.length; j ++) {
  1068. var q_comp = quals[j].comparator + ' ';
  1069. var q_name = quals[j].qualification_type.name + ' ';
  1070.  
  1071. var q_valu = quals[j].qualification_values;
  1072. var q_values = '';
  1073. for (var k = 0; k < quals.length; k ++) {
  1074. if (quals[j].qualification_values[k]) {
  1075. q_values += quals[j].qualification_values[k];
  1076. q_values += k === quals.length ? ', ' : '';
  1077. }
  1078. }
  1079. if ( typeof quals[j].qualification_request_url !== 'undefined' ) {
  1080. q_values += '~!~' + quals[j].qualification_request_url;
  1081. }
  1082. qualif += (q_name + q_comp + q_values).trim() + '; ';
  1083. }
  1084. qualif = qualif.trim();
  1085. }
  1086.  
  1087. qualif = DOMPurify.sanitize(qualif,config);
  1088.  
  1089. if (!hitlog[key]) {
  1090. hitlog[key] = {
  1091. reqname : req_name,
  1092. reqid : req_id,
  1093. reqlink : req_link,
  1094. conlink : con_link,
  1095. groupid : group_id,
  1096. prevlink : prev_link,
  1097. pandlink : pand_link,
  1098. title : title,
  1099. safetitle: safetitle,
  1100. desc : desc,
  1101. time : time,
  1102. reward : reward,
  1103. avail : avail,
  1104. quals : qualif,
  1105. key : key,
  1106. tolink : 'https://turkopticon.ucsd.edu/' + req_id,
  1107. to : { comm : 'N/A', fair : 'N/A', fast : 'N/A', pay : 'N/A' },
  1108. tvlink : 'https://turkerview.com/requesters/' + req_id,
  1109. tv : 'N/A'
  1110. };
  1111.  
  1112. if ( $.inArray( req_id, requesters ) == -1 ) {
  1113. new_requesters.push( req_id );
  1114. }
  1115.  
  1116. to.push([key, req_id]);
  1117. log_keys.push(key);
  1118. }
  1119. else {
  1120. hitlog[key].avail = avail;
  1121. }
  1122. }
  1123.  
  1124. var tvPromise = _getTVReviews( new_requesters );
  1125. var toPromise = _to(keys, log_keys, logged_in, to, timeis);
  1126.  
  1127. $.when( tvPromise, toPromise).done( function( v1, v2 ) {
  1128. _build(keys, log_keys, timeis);
  1129. }
  1130. );
  1131. }
  1132.  
  1133. let stopTV = false;
  1134. let tv_fail_rate = 0;
  1135. function _getTVReviews( reqlist ) {
  1136. var def = $.Deferred();
  1137. if ( reqlist.length > 0 && !config.disable_tv && !stopTV){
  1138. fetch(`https://view.turkerview.com/v1/requesters/?requester_ids=${reqlist.join()}`, {
  1139. method: 'GET',
  1140. cache: 'no-cache',
  1141. headers: ViewHeaders
  1142. }).then(response => {
  1143. if (!response.ok) throw response;
  1144.  
  1145. return response.json();
  1146. }).then(json => {
  1147.  
  1148. newreviews = json.requesters;
  1149. $.merge( requesters, reqlist );
  1150. turkerview = extend( turkerview, newreviews);
  1151. def.resolve(json);
  1152.  
  1153. }).catch(ex => {
  1154. tv_fail_rate++;
  1155. if (ex.statusText == 'invalidUserAuthKey') {
  1156. stopTV = true;
  1157. $('#TVErrorMessage').find('p').html(`<span>Your TurkerView API Key is invalid. If you haven't added it yet check the "Advanced Settings" options tab!</span><p style="margin-bottom: 0.5rem; margin-top: 0.5rem;">You can claim your free API key (or support the site with a subscription!) from your <a href="https://turkerview.com/account/api/" target="_blank">TurkerView account API dashboard.</a></p>`);
  1158. $('#TVErrorMessage').show();
  1159. }
  1160. else if (ex.statusText == 'dailyLimitExceeded' || ex.statusText == 'freeTrialExpired') {
  1161. stopTV = true;
  1162. $('#TVErrorMessage').find('p').html(`<span>Your TurkerView API Key has hit the free quota limit, please upgrade from your <a href="https://turkerview.com/account/api/" target="_blank">TurkerView account API dashboard</a>.</span>`);
  1163. $('#TVErrorMessage').show();
  1164. }
  1165.  
  1166. def.resolve( 'Empty');
  1167. });
  1168. }
  1169. else {
  1170. def.resolve( 'Empty');
  1171. }
  1172.  
  1173. return def.promise();
  1174. }
  1175.  
  1176. function _getTVHourly( reqid ) {
  1177. var tvHourly;
  1178. if( reqid in turkerview ) {
  1179. tvHourly = '$' + turkerview[reqid]['wages']['average']['wage'] + "/hr";
  1180. }
  1181. else {
  1182. tvHourly = '-';
  1183. }
  1184.  
  1185. return tvHourly;
  1186. }
  1187.  
  1188. function _to (keys, log_keys, logged_in, to, timeis) {
  1189. var def = $.Deferred();
  1190. var timeout = true;
  1191.  
  1192. var ids = [];
  1193.  
  1194. if (logged_in && to.length && config.to) {
  1195. for (var i = 0; i < to.length; i++) {
  1196. ids.push(to[i][1]);
  1197. }
  1198.  
  1199. $.ajax( {
  1200. url: 'https://turkopticon.ucsd.edu/api/multi-attrs.php?ids=' + ids,
  1201. success: function (data) {
  1202. try {
  1203. var to_data = JSON.parse(data);
  1204. }
  1205. catch(err) {
  1206. console.log ( "Fork off TO you're drunk" );
  1207. // malformed javascript, treat it lke TO timed out.
  1208. def.resolve( 'Done');
  1209. }
  1210.  
  1211. for (i = 0; i < to.length; i++) {
  1212. if (!to_data[to[i][1]].length && typeof to_data[to[i][1]].attrs != 'undefined') {
  1213. hitlog[to[i][0]].to = to_data[to[i][1]].attrs;
  1214. }
  1215. }
  1216.  
  1217. timeout = false;
  1218. },
  1219. timeout: 400
  1220. }).always(function () {
  1221. def.resolve( 'Done' );
  1222. });
  1223. }
  1224. else {
  1225. def.resolve( 'TO Off' );
  1226. }
  1227. return def.promise();
  1228.  
  1229. }
  1230.  
  1231. function _build (keys, log_keys, timeis) {
  1232. var hit_html = '', log_html = '';
  1233.  
  1234. for (var i = 0; i < keys.length; i++) {
  1235. var hit = hitlog[keys[i]], blocked = _check_block(hit), included = _check_include(hit), remove = false, classes, tvHourly, tvScore = false;
  1236.  
  1237. hit.tv = _getTVHourly( hit.reqid );
  1238.  
  1239. if ( hit.tv.substring(0,3) == 'N/A' || hit.tv.substring(0,3) == '<sp' ) {
  1240. tvScore = false;
  1241. }
  1242. else {
  1243. tvScore = true;
  1244. }
  1245.  
  1246. rowcolor = tvScore == true ? _color_tv(hit) : 'toNone';
  1247.  
  1248. classes = rowcolor;
  1249.  
  1250. if (Number(config.avail) > Number(hit.avail) || Number(config.mto) > Number(hit.to.pay)) {
  1251. classes += ' hidden';
  1252. remove = true;
  1253. }
  1254.  
  1255. if (blocked) {
  1256. classes += config.bl ? ' bl_hidden' : ' bl';
  1257. remove = true;
  1258. }
  1259.  
  1260. if (included) {
  1261. classes += ' il';
  1262. _included(included, hit);
  1263. }
  1264. else {
  1265. classes += config.nl ? ' nl_hidden' : ' nl';
  1266. }
  1267.  
  1268. hit_html +=
  1269. '<div class="cont" style="margin-bottom: 2px;">' +
  1270. '<div class="' + classes + ' " style="overflow: hidden; white-space: nowrap; margin-bottom: 2px;">' +
  1271.  
  1272. '<div style="float: left; width: calc(100% - 330px);">' +
  1273.  
  1274. '<span style="width: 25%; float: left; display:inline-block; overflow: hidden;">' +
  1275. '<button data-term="' + hit.reqid + '" data-name="' + hit.reqname + '" class="rt">R</button>' +
  1276. '<button id="'+ hit.groupid + '" data-term="' + hit.safetitle + '" data-name="' + hit.safetitle + '" class="rt">T</button>' +
  1277. '<button data-term="' + hit.reqid + '" data-name="' + hit.reqname + '" class="it">I</button>' +
  1278. '<a href="' + hit.reqlink + '">' + hit.reqname + '</a>' +
  1279. '</span>' +
  1280.  
  1281. '<span style="width: 75%; float: right; display:inline-block; overflow: hidden;">' +
  1282. '<button value="' + hit.key + '" class="vb">vB</button>' +
  1283. '<button value="' + hit.key + '" class="irc">IRC</button>' +
  1284. '<a href="' + hit.prevlink + '">' + hit.safetitle + '</a>' +
  1285. '</span>' +
  1286.  
  1287. '</div>' +
  1288.  
  1289. '<div style="float: right;">' +
  1290.  
  1291. '<span style="width: 60px; display:inline-block; text-align: center;">' +
  1292. hit.avail +
  1293. '</span>' +
  1294.  
  1295. '<span style="width: 60px; display:inline-block; text-align: center;">' +
  1296. '<a href="' + hit.pandlink + '">' + hit.reward + '</a>' +
  1297. '</span>' +
  1298.  
  1299. '<span class="to" style="width: 60px; display:inline-block; text-align: center;">' +
  1300. '<a href="' + hit.tvlink + '">' + hit.tv + '</a>' +
  1301. '</span>' +
  1302.  
  1303. '<span class="to" style="width: 60px; display:inline-block; text-align: center;">' +
  1304. '<a href="' + hit.tolink + '">' + hit.to.pay + '</a>' +
  1305. '</span>' +
  1306.  
  1307. '<span style="width: 60px; display:inline-block; text-align: center;">' +
  1308. '<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>' +
  1309. '<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>' +
  1310. '</span>' +
  1311.  
  1312. '</div>' +
  1313. '</div>' +
  1314. '</div>'
  1315. ;
  1316.  
  1317. if (remove) {
  1318. var index = log_keys.indexOf(keys[i]);
  1319.  
  1320. if (index > -1) {
  1321. log_keys.splice(index, 1);
  1322. }
  1323. }
  1324. }
  1325.  
  1326. if (log_keys.length) {
  1327. for (var j = 0; j < log_keys.length; j ++) {
  1328. var hit_log = hitlog[log_keys[j]], included_log = _check_include(hit_log), rowcolor, classes_log, tvHourly;
  1329.  
  1330. rowcolor = hit_log.tv != 'N/A' ? _color_tv(hit_log) : 'toNone';
  1331.  
  1332. classes_log = rowcolor;
  1333.  
  1334. if (included_log) {
  1335. classes_log += ' il';
  1336. }
  1337. else {
  1338. classes_log += config.nl ? ' nl_hidden' : ' nl';
  1339. }
  1340.  
  1341. var quals = hit_log.quals.split(';');
  1342. var qualif = '';
  1343.  
  1344. for (var k = 0; k < quals.length; k ++) {
  1345. if (quals[k] !== '') {
  1346. if( quals[k].indexOf('~!~') != -1 ) {
  1347. var temp = quals[k].split('~!~');
  1348. quals[k] = temp[0];
  1349. if (temp[1].indexOf('request') == -1 ) {
  1350. //Qual test
  1351. quals[k] += '<form action="' +temp[1] +'" method="get" style=" display:inline!important;"><button>Take Test</button></form>';
  1352. }
  1353. else {
  1354. //Request Qual
  1355. //quals[k] += '<form action="' +temp[1] +'" method="post"><button>Request</button></form>';
  1356. }
  1357. }
  1358. qualif += '<li style="padding: 2px;">' + quals[k] + '</li>';
  1359. }
  1360. }
  1361.  
  1362.  
  1363.  
  1364. log_html +=
  1365. '<div class="cont loggid_' + hit_log.groupid +' logreqid_' + hit_log.reqid + '" style="margin-bottom: 2px;">' +
  1366. '<div class="' + classes_log + '" style="overflow: hidden; white-space: nowrap;">' +
  1367.  
  1368. '<div style="float: left;">' +
  1369. '<span style="width: 80px; display:inline-block;">' +
  1370. '<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>' +
  1371. timeis[0] + ':' + timeis[1] + timeis[3] + '</span>' +
  1372. '</div>' +
  1373.  
  1374. '<div style="float: left; width: calc(100% - 410px);">' +
  1375.  
  1376. '<span style="width: 25%; float: left; display:inline-block; overflow: hidden;">' +
  1377. '<button data-term="' + hit_log.reqid + '" data-name="' + hit_log.reqname + '" class="rt">R</button>' +
  1378. '<button id="'+ hit_log.groupid + '" data-term="' + hit_log.safetitle + '" data-name="' + hit_log.safetitle + '" class="rt">T</button>' +
  1379. '<button data-term="' + hit_log.reqid + '" data-name="' + hit_log.reqname + '" class="it">I</button>' +
  1380. '<a href="' + hit_log.reqlink + '">' + hit_log.reqname + '</a>' +
  1381. '</span>' +
  1382.  
  1383. '<span style="width: 75%; float: right; display:inline-block; overflow: hidden;">' +
  1384. '<button value="' + hit_log.key + '" class="vb">vB</button>' +
  1385. '<button value="' + hit_log.key + '" class="irc">IRC</button>' +
  1386. '<a href="' + hit_log.prevlink + '">' + hit_log.safetitle + '</a>' +
  1387. '</span>' +
  1388.  
  1389. '</div>' +
  1390.  
  1391. '<div style="float: right;">' +
  1392.  
  1393. '<span style="width: 60px; display:inline-block; text-align: center;">' +
  1394. hit_log.avail +
  1395. '</span>' +
  1396.  
  1397. '<span style="width: 60px; display: inline-block; text-align: center;">' +
  1398. '<a href="' + hit_log.pandlink + '">' + hit_log.reward + '</a>' +
  1399. '</span>' +
  1400.  
  1401. '<span class="to" style="width: 60px; display:inline-block; text-align: center;">' +
  1402. '<a href="' + hit_log.tvlink + '">' + hit_log.tv + '</a>' +
  1403. '</span>' +
  1404.  
  1405.  
  1406. '<span class="to" style="width: 60px; display:inline-block; text-align: center;">' +
  1407. '<a href="' + hit_log.tolink + '">' + hit_log.to.pay + '</a>' +
  1408. '</span>' +
  1409.  
  1410. '<span style="width: 60px; display:inline-block; text-align: center;">' +
  1411. '<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>' +
  1412. '<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>' +
  1413. '</span>' +
  1414.  
  1415. '</div>' +
  1416. '</div>'+
  1417.  
  1418. '<div class="info ' + rowcolor + '" value="' + hit_log.key + '" style="overflow: hidden; display: none; font-size: 11px;">' +
  1419.  
  1420. '<div style="border-bottom: 1px solid #000000;"></div>' +
  1421.  
  1422. '<span style="width: 33%; float: left; display:inline-block; padding: 5px;">' +
  1423. '<span style="text-decoration: underline;">Description</span>' +
  1424. '<div style="padding: 2px;">' + hit_log.desc +'</div>' +
  1425. '<span style="text-decoration: underline;">Time</span>' +
  1426. '<div style="padding: 2px;">' + hit_log.time +'</div>' +
  1427. '</span>' +
  1428.  
  1429. '<span style="width: 33%; float: left; display:inline-block; padding: 5px;">' +
  1430. '<span style="text-decoration: underline;">Qualifications</span>' +
  1431. qualif +
  1432. '</span>' +
  1433.  
  1434. '<span style="width: calc(34% - 30px); float: right; display:inline-block; padding: 5px;">' +
  1435. '<span style="text-decoration: underline;">Turkopticon</span>' +
  1436. '<br>' +
  1437. '<span style="width: 70px; display:inline-block; padding: 2px;">Pay : ' + hit_log.to.pay +'</span>' +
  1438. '<span style="width: 70px; display:inline-block; padding: 2px;">Fair : ' + hit_log.to.fair +'</span>' +
  1439. '<br>' +
  1440. '<span style="width: 70px; display:inline-block; padding: 2px;">Comm : ' + hit_log.to.comm +'</span>' +
  1441. '<span style="width: 70px; display:inline-block; padding: 2px;">Fast : ' + hit_log.to.fast +'</span>' +
  1442. '</span>' +
  1443.  
  1444. '</div>' +
  1445. '</div>';
  1446.  
  1447. logged ++;
  1448. }
  1449. if (config.new) {
  1450. _sound('new');
  1451. }
  1452. }
  1453. $('#new_hits_').html(hit_html);
  1454. $('#log_hits_').prepend(log_html);
  1455.  
  1456. searches ++;
  1457. var hits_data = '<span> ' + timeis[0] + ':' + timeis[1] + ':' + timeis[2] + timeis[3] + ' Scanned HITs: ' + keys.length + '</span><span style="float: right;">' + tv_fail_rate + '/' + searches + '</span>';
  1458. var logged_hits_data = '<span style="float: right;">' + logged + '</span>';
  1459.  
  1460. $('#hits_data').html(hits_data);
  1461. $('#logged_hits_data').html(logged_hits_data);
  1462.  
  1463. if ($('#scan_button').text() === 'Stop') {
  1464. setTimeout(function () {
  1465. _scan();
  1466. }, $('#delay').val() * 1000);
  1467. }
  1468. }
  1469.  
  1470. function _sound (sound) {
  1471. if (sound === 'new') { $('#audio_' + config.newaudio) [0].play(); }
  1472. if (sound === 'include') { $('#audio_' + config.newaudio) [0].play(); }
  1473. if (sound === 'il') { $('#audio_' + $('#il_sound').val()) [0].play(); }
  1474. if (sound === 'il_edit') { $('#audio_' + $('#edit_il_sound').val()) [0].play(); }
  1475. }
  1476.  
  1477. function _check_block (hit) {
  1478. for (var key in blocklist) {
  1479. var obj = blocklist[key];
  1480. 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()) {
  1481. return obj;
  1482. }
  1483. }
  1484. }
  1485.  
  1486. function _check_include (hit) {
  1487. for (var key in includelist) {
  1488. var obj = includelist[key];
  1489. 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()) {
  1490. return obj;
  1491. }
  1492. }
  1493. }
  1494.  
  1495. function _included (obj, hit) {
  1496. var check = noti_delay.indexOf(hit.key) !== -1;
  1497. var pushcheck = push_delay.indexOf(hit.key) !== -1;
  1498.  
  1499. if (!check) {
  1500. noti_delay.unshift(hit.key);
  1501. setTimeout(function () { noti_delay.pop(); }, config.alert * 1000);
  1502. }
  1503. if (obj.noti_cb && !check) {
  1504. Notification.requestPermission();
  1505. var n = new Notification(hit.reqname + ' | ' + hit.reward, {
  1506. icon : 'http://nopurpose.org/stuff/avatars/Lj21396.gif',
  1507. body : hit.title,
  1508. });
  1509. setTimeout(n.close.bind(n), 5000);
  1510.  
  1511. n.onclick = function(e) {
  1512. e.preventDefault();
  1513. window.open(hit.prevlink, '_blank');
  1514. };
  1515.  
  1516. }
  1517. if (obj.sound_cb && !check) {
  1518. if ( !config.tts ) {
  1519. $('#audio_' + obj.sound)[0].play();
  1520. }
  1521. else {
  1522. //Console.log("BOOM, TTS");
  1523. slothbearsTTS(obj);
  1524. }
  1525. }
  1526. if (obj.push_cb && !pushcheck && config.pb) {
  1527. push_delay.unshift(hit.key);
  1528. setTimeout(function () { push_delay.pop(); }, 900000);
  1529.  
  1530. var push = {};
  1531.  
  1532. push['type'] = 'note';
  1533. push['title'] = 'HIT Finder';
  1534. push['body'] = '[' + hit.reqname + ']\n[' + hit.safetitle + ']\n[' + hit.reward + ']\n[' + hit.prevlink + ']';
  1535.  
  1536. $.ajax({
  1537. type : 'POST',
  1538. headers : {'Authorization': 'Bearer ' + config.push},
  1539. url : 'https://api.pushbullet.com/v2/pushes',
  1540. data : push
  1541. });
  1542.  
  1543. }
  1544. }
  1545.  
  1546. function _color_tv(hit) {
  1547. var tvHourly = hit.tv.replace(/\$/g, '').replace(/\/hr/g, '');
  1548.  
  1549. if (tvHourly == '-') return 'toNone';
  1550.  
  1551. if (config.theme == "light") {
  1552. if (tvHourly >= 10.00) { return 'tvHigh'; }
  1553. else if (tvHourly >= 7.25) { return 'tvFair'; }
  1554. else { return 'tvLow'; }
  1555. }
  1556. else {
  1557. if (tvHourly >= 10.00) { return 'toHigh'; }
  1558. else if (tvHourly >= 7.25) { return 'toAverage'; }
  1559. else { return 'toLow'; }
  1560.  
  1561. }
  1562. }
  1563.  
  1564. function _color_to (hit) {
  1565. var to = hit.to.pay;
  1566.  
  1567. if (config.theme == "light") {
  1568. if (to > 4) { return 'tvHigh'; }
  1569. else if (to > 2.5) { return 'tvFair'; }
  1570. else if (to > 0) { return 'tvLow'; }
  1571. else { return 'tvNone'; }
  1572. }
  1573. else {
  1574. if (to > 4) { return 'toHigh'; }
  1575. else if (to > 3) { return 'toGood'; }
  1576. else if (to > 2.25) { return 'toAverage'; }
  1577. else if (to > 1.25) { return 'toLow'; }
  1578. else if (to > 0) { return 'toPoor'; }
  1579. else { return 'toNone'; }
  1580.  
  1581. }
  1582. }
  1583.  
  1584. function _convert_seconds (seconds) {
  1585. seconds = Number(seconds);
  1586. var h = Math.floor(seconds / 3600);
  1587. var m = Math.floor(seconds % 3600 / 60);
  1588. var s = Math.floor(seconds % 3600 % 60);
  1589. var time = '';
  1590. if (h > 0) { time += h + ' hour(s) '; }
  1591. if (m > 0) { time += m + ' minutes(s) '; }
  1592. if (s > 0) { time += s + ' seconds(s)'; }
  1593. return time;
  1594. }
  1595.  
  1596. function _block (term, name, gid) {
  1597. $('#bl_term') .val(term);
  1598. $('#bl_name') .val(name);
  1599. $('#bl_gid').val(gid);
  1600. $('#bl') .show();
  1601. }
  1602.  
  1603. function _includerid( term, name, gid ) {
  1604. $('#il_term') .val(term);
  1605. $('#il_name') .val(name);
  1606. $('#il') .show();
  1607. }
  1608.  
  1609. function _panda(term, reqname, reqid, title, value, name, button) {
  1610. var hitData = {
  1611. hitTitle: title,
  1612. requesterName: reqname,
  1613. requesterId: reqid,
  1614. hitValue: value
  1615. }
  1616.  
  1617. var once = name == "panda" ? false : true;
  1618.  
  1619. PandaCrazy.online().then (
  1620. function(successResp) {
  1621. PandaCrazy.addJob( term, once, hitData );
  1622. button.addClass("clicked")
  1623. },
  1624. function(failedResp) {
  1625. 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");
  1626. }
  1627. );
  1628. //console.log ( running );
  1629. }
  1630.  
  1631.  
  1632. function _add_block (obj) {
  1633. if (!blocklist[obj.term]) {
  1634. blocklist[obj.term] = obj;
  1635. _init_lists();
  1636. }
  1637. }
  1638.  
  1639. function _edit_block (term) {
  1640. var obj = blocklist[term];
  1641. $('#edit_bl_term') .val(obj.term) .text(obj.term);
  1642. $('#edit_bl_name') .val(obj.name);
  1643. $('#edit_bl_save') .val(obj.term);
  1644. $('#edit_bl_delete') .val(obj.term);
  1645. $('#edit_bl') .show();
  1646. }
  1647.  
  1648. function _update_block (block) {
  1649. var obj = blocklist[block];
  1650. obj.name = $('#edit_bl_name').val();
  1651. _init_lists();
  1652. }
  1653.  
  1654. function _delete_block (block) {
  1655. delete blocklist[block];
  1656. _init_lists();
  1657. }
  1658.  
  1659. function _add_include (obj) {
  1660. if (!includelist[obj.term]) {
  1661. includelist[obj.term] = obj;
  1662. _init_lists();
  1663. }
  1664. }
  1665.  
  1666. function _edit_include (term) {
  1667. var obj = includelist[term];
  1668.  
  1669. $('#edit_il_term') .val(obj.term) .text(obj.term);
  1670. $('#edit_il_name') .val(obj.name);
  1671. $('#edit_il_sound') .val(obj.sound);
  1672.  
  1673. $('#edit_il_noti_cb') .prop('checked', obj.noti_cb);
  1674. $('#edit_il_sound_cb') .prop('checked', obj.sound_cb);
  1675. $('#edit_il_push_cb') .prop('checked', obj.push_cb);
  1676.  
  1677. $('#edit_il_save') .val(obj.term);
  1678. $('#edit_il_delete') .val(obj.term);
  1679.  
  1680. $('#edit_il').show();
  1681. }
  1682.  
  1683. function _update_include (term) {
  1684. var obj = includelist[term];
  1685. obj.name = $('#edit_il_name') .val().trim();
  1686. obj.sound = $('#edit_il_sound') .val().trim();
  1687. obj.noti_cb = $('#edit_il_noti_cb') .prop('checked');
  1688. obj.sound_cb = $('#edit_il_sound_cb') .prop('checked');
  1689. obj.push_cb = $('#edit_il_push_cb') .prop('checked');
  1690. _init_lists();
  1691. }
  1692.  
  1693. function _delete_include (term) {
  1694. delete includelist[term];
  1695. _init_lists();
  1696. }
  1697.  
  1698. function _hide_hit_list( hide ) {
  1699. if (hide) {
  1700. $("#hits_button").text('Show New HITs');
  1701. $('#hits_table').hide();
  1702. $('#hits_hidden').show();
  1703. config.h_hidden = '1';
  1704. }
  1705. else {
  1706. $("#hits_button").text('Hide New HITs');
  1707. $('#hits_table').show();
  1708. $('#hits_hidden').hide();
  1709. config.h_hidden = '0';
  1710. }
  1711.  
  1712. _save( 'showhide' );
  1713. }
  1714.  
  1715. function _hide_log_list( hide ) {
  1716. if (hide) {
  1717. $("#logg_button").text('Show Logged HITs');
  1718. $('#log_table').hide();
  1719. $('#log_hidden').show();
  1720. config.l_hidden = '1';
  1721. }
  1722. else {
  1723. $("#logg_button").text('Hide Logged HITs');
  1724. $('#log_table').show();
  1725. $('#log_hidden').hide();
  1726. config.l_hidden = '0';
  1727. }
  1728.  
  1729. _save( 'showhide' );
  1730. }
  1731.  
  1732. function _init_lists () {
  1733. var bl_sort = [], il_sort = [], bl_html = '', il_html = '';
  1734.  
  1735. for (var bl_key in blocklist) {
  1736. bl_sort.push([bl_key, blocklist[bl_key].name]);
  1737. }
  1738.  
  1739. bl_sort.sort(function (a, b) {
  1740. if (a[1].toLowerCase() < b[1].toLowerCase()) return -1;
  1741. if (a[1].toLowerCase() > b[1].toLowerCase()) return 1;
  1742. return 0;
  1743. });
  1744.  
  1745. for (var i = 0; i < bl_sort.length; i ++) {
  1746. var bl_obj = blocklist[bl_sort[i][0]];
  1747. bl_html += '<button class="blockit" style="margin: 2px;" value="' + bl_obj.term + '" title="' + bl_obj.term + '">' + bl_obj.name + '</button>';
  1748. }
  1749.  
  1750. for (var il_key in includelist) {
  1751. il_sort.push([il_key, includelist[il_key].name]);
  1752. }
  1753.  
  1754. il_sort.sort(function (a, b) {
  1755. if (a[1].toLowerCase() < b[1].toLowerCase()) return -1;
  1756. if (a[1].toLowerCase() > b[1].toLowerCase()) return 1;
  1757. return 0;
  1758. });
  1759.  
  1760. for (var j = 0; j < il_sort.length; j ++) {
  1761. var il_obj = includelist[il_sort[j][0]];
  1762. il_html += '<button class="includeit" style="margin: 2px;" value="' + il_obj.term + '" title="' + il_obj.term + '">' + il_obj.name + '</button>';
  1763. }
  1764.  
  1765. $('#bl_items') .html(bl_html);
  1766. $('#il_items') .html(il_html);
  1767. _save('init');
  1768. }
  1769.  
  1770. function _import_block () {
  1771. var import_bl = prompt(
  1772. 'Block List Import\n\n' +
  1773. 'You can import from HIT Finder or HIT Scraper.\n\n' +
  1774. 'This will not delete your current block list, only add to it.\n\n' +
  1775. 'Please enter your block list here.',
  1776. ''
  1777. );
  1778.  
  1779. if (import_bl) {
  1780. var json = _json_validator(import_bl);
  1781.  
  1782. if (json) {
  1783. var _bl_obj = JSON.parse(import_bl);
  1784. for (var key in _bl_obj) {
  1785. if (_bl_obj[key].hasOwnProperty('term') && _bl_obj[key].hasOwnProperty('name') && !_bl_obj[key].hasOwnProperty('sound')) {
  1786. if (!blocklist[key]) {
  1787. blocklist[key] = {
  1788. term : _bl_obj[key].term,
  1789. name : _bl_obj[key].name
  1790. };
  1791. }
  1792. }
  1793. else {
  1794. alert('An error occured while importing.\n\n Please check if you have a valid import and try again.');
  1795. break;
  1796. }
  1797. }
  1798. _init_lists();
  1799. }
  1800. else if (import_bl.match(/^/)) {
  1801. var _bl_arr = import_bl.trim().split('^');
  1802. for (var i = 0; i < _bl_arr.length; i ++) {
  1803. if (!blocklist[_bl_arr[i]]) {
  1804. blocklist[_bl_arr[i]] = {
  1805. term : _bl_arr[i],
  1806. name : _bl_arr[i]
  1807. };
  1808. }
  1809. }
  1810. _init_lists();
  1811. }
  1812. }
  1813. else {
  1814. alert('An error occured while importing.\n\n Please check if you have a valid import and try again.');
  1815. }
  1816. }
  1817.  
  1818. function _export_block () {
  1819. GM_setClipboard(localStorage.getItem('_finder_bl'));
  1820. alert('Your block list has been copied to your clipboard.');
  1821. }
  1822.  
  1823. function _import_include () {
  1824. var import_il = prompt(
  1825. 'Include List Import\n\n' +
  1826. 'You can import from HIT Finder or HIT Scraper.\n\n' +
  1827. 'This will not delete your current include list, only add to it.\n\n' +
  1828. 'Please enter your include list here.',
  1829. ''
  1830. );
  1831.  
  1832. if (import_il) {
  1833. var json = _json_validator(import_il);
  1834.  
  1835. if (json) {
  1836. var _il_obj = JSON.parse(import_il);
  1837.  
  1838. for (var key in _il_obj) {
  1839. if (_il_obj[key].hasOwnProperty('term') && _il_obj[key].hasOwnProperty('name') && _il_obj[key].hasOwnProperty('sound')) {
  1840. if (!includelist[key]) {
  1841. includelist[key] = {
  1842. term : _il_obj[key].term,
  1843. name : _il_obj[key].name,
  1844. sound : _il_obj[key].sound,
  1845. noti_cb : _il_obj[key].noti_cb,
  1846. sound_cb : _il_obj[key].sound_cb,
  1847. push_cb : _il_obj[key].push_cb
  1848. };
  1849. }
  1850. }
  1851. else {
  1852. alert('An error occured while importing.\n\n Please check that you have a valid import and try again.');
  1853. break;
  1854. }
  1855. }
  1856. _init_lists();
  1857. }
  1858. else if (import_il.match(/^/)) {
  1859. var _il_arr = import_il.split('^');
  1860.  
  1861. for (var i = 0; i < _il_arr.length; i ++) {
  1862. if (!includelist[_il_arr[i]]) {
  1863. includelist[_il_arr[i]] = {
  1864. term : _il_arr[i],
  1865. name : _il_arr[i],
  1866. sound : '1',
  1867. noti_cb : true,
  1868. sound_cb : true,
  1869. push_cb : false
  1870. };
  1871. }
  1872. }
  1873. _init_lists();
  1874. }
  1875. }
  1876. else {
  1877. alert('An error occured while importing.\n\n Please check that you have a valid import and try again.');
  1878. }
  1879. }
  1880.  
  1881. function _export_include () {
  1882. GM_setClipboard(localStorage.getItem('_finder_il'));
  1883. alert('Your include list has been copied to your clipboard.');
  1884. }
  1885.  
  1886. function _export_vb (key) {
  1887. var hit = hitlog[key];
  1888.  
  1889. var pay = hit.to.pay, _pay = '#B30000';
  1890. if (pay > 3.99) { _pay = '#00B300'; }
  1891. else if (pay > 2.99) { _pay = '#B3B300'; }
  1892. else if (pay > 1.99) { _pay = '#B37400'; }
  1893.  
  1894. var fair = hit.to.fair, _fair = '#B30000';
  1895. if (fair > 3.99) { _fair = '#00B300'; }
  1896. else if (fair > 2.99) { _fair = '#B3B300'; }
  1897. else if (fair > 1.99) { _fair = '#B37400'; }
  1898.  
  1899. var comm = hit.to.comm, _comm = '#B30000';
  1900. if (comm > 3.99) { _comm = '#00B300'; }
  1901. else if (comm > 2.99) { _comm = '#B3B300'; }
  1902. else if (comm > 1.99) { _comm = '#B37400'; }
  1903.  
  1904. var fast = hit.to.fast, _fast = '#B30000';
  1905. if (fast > 3.99) { _fast = '#00B300'; }
  1906. else if (fast > 2.99) { _fast = '#B3B300'; }
  1907. else if (fast > 1.99) { _fast = '#B37400'; }
  1908.  
  1909. var tv = hit.tv.replace(/\$/g, ''), _tvhourly = '#B30000';
  1910. if ( tv != 'N/A' ) {
  1911. if ( tv >= 10 ) { _tvhourly = '#00B300'; }
  1912. else if ( tv >= 7.25 ) { _tvhourly = '#B3B300'; }
  1913. tv = '$' + tv + '/hr';
  1914. }
  1915.  
  1916. var quals = hit.quals.split(';');
  1917. var qualif = '';
  1918.  
  1919. for (var k = 0; k < quals.length; k ++) {
  1920. if (quals[k] !== '') {
  1921. if( quals[k].indexOf('~!~') != -1 ) {
  1922. var temp = quals[k].split('~!~');
  1923. quals[k] = temp[0];
  1924. if (temp[1].indexOf('request') == -1 ) {
  1925. //Qual test
  1926. quals[k] += '[URL=' +temp[1] +']Take Test[/URL]';
  1927. }
  1928. else {
  1929. //Request Qual
  1930. //quals[k] += '<form action="' +temp[1] +'" method="post"><button>Request</button></form>';
  1931. }
  1932. }
  1933. qualif += quals[k] + ';';
  1934. }
  1935. }
  1936.  
  1937. var exportcode = '[table][tr][td]'+
  1938. '[b]Title:[/b] [URL=' + pandaurl + hit.prevlink + ']' + hit.safetitle + '[/URL] | [URL=' + pandaurl + hit.pandlink + ']PANDA[/URL]\n' +
  1939. '[b]Requester:[/b] [URL=' + pandaurl + hit.reqlink + ']' + hit.reqname + '[/URL] [' + hit.reqid + '] ([URL=' + hit.tvlink +']Req TV[/URL]): [B][COLOR=' + _tvhourly + ']' + tv + '[/COLOR][/B]\n' +
  1940. '([URL='+hit.tolink+']TO[/URL]):'+
  1941. '[b] \[Pay: [COLOR=' + _pay + ']' + pay + '[/COLOR]\][/b]'+
  1942. '[b] \[Fair: [COLOR=' + _fair + ']' + fair + '[/COLOR]\][/b]' +
  1943. '[b] \[Comm: [COLOR=' + _comm +']' + comm + '[/COLOR]\][/b]' +
  1944. '[b] \[Fast: [COLOR=' + _fast + ']' + fast + '[/COLOR]\][/b]\n' +
  1945. '[b]Description:[/b] ' + hit.desc + '\n' +
  1946. '[b]Time:[/b] ' + hit.time + '\n' +
  1947. '[b]HITs Available:[/b] ' + hit.avail + '\n' +
  1948. '[b]Reward:[/b] [COLOR=green][b] ' + hit.reward + '[/b][/COLOR]\n' +
  1949. '[b]Qualifications:[/b] ' + qualif + '\n' +
  1950. '[/td][/tr][/table]';
  1951.  
  1952. GM_setClipboard(exportcode);
  1953. alert('Forum export has been copied to your clipboard.');
  1954. }
  1955.  
  1956. function _export_irc (key) {
  1957. var hit = hitlog[key];
  1958.  
  1959. $.get('https://ns4t.net/yourls-api.php?action=bulkshortener&title=MTurk&signature=39f6cf4959&urls[]=https://worker.mturk.com' + hit.prevlink + '&urls[]=https://worker.mturk.com' + hit.pandlink, function (data) {
  1960. var urls = data.split(';'),
  1961. preview = urls[0],
  1962. panda = urls[1];
  1963.  
  1964. var exportcode = 'Req: ' + hit.reqname + ' ■ Title: ' + hit.safetitle + ' ■ Reward: ' + hit.reward;
  1965. exportcode += preview !== panda ? ' ■ Prev: ' + preview + ' ■ PandA: '+ panda : ' ■ Search: ' + preview;
  1966. exportcode += ' ■ TO: (Pay: ' + hit.to.pay + ') (Fair: ' + hit.to.fair + ') (Comm: ' + hit.to.comm + ') (Fast: ' + hit.to.fast + ')';
  1967.  
  1968. GM_setClipboard(exportcode);
  1969. alert('IRC export has been copied to your clipboard.');
  1970.  
  1971. }).fail(function () {
  1972. alert('Failed to shorten links.');
  1973. });
  1974. }
  1975.  
  1976. function _json_validator (data) {
  1977. try {
  1978. JSON.parse(data);
  1979. return true;
  1980. }
  1981. catch (e) {
  1982. return false;
  1983. }
  1984. }
  1985.  
  1986. function _save (type) {
  1987. if (type !== 'init' && type !== 'custom') {
  1988. config.delay = $('#delay') .val();
  1989. config.rew = $('#min_rew') .val();
  1990. config.avail = $('#min_avail') .val();
  1991. config.mto = $('#min_to') .val();
  1992. config.alert = $('#alert_delay') .val();
  1993. config.type = $('#type') .val();
  1994. config.size = $('#size') .val();
  1995. config.newaudio = $('#new_audio') .val();
  1996. config.theme = $('#adv_theme') .val();
  1997. config.to_theme = $('#to_theme') .val();
  1998.  
  1999. config.new = $('#new_sound') .prop('checked');
  2000. config.pb = $('#pb') .prop('checked');
  2001. config.tts = $('#tts') .prop('checked');
  2002. config.to = $('#to') .prop('checked');
  2003. config.qual = $('#qual') .prop('checked');
  2004. config.nl = $('#nl_hide') .prop('checked');
  2005. config.bl = $('#bl_hide') .prop('checked');
  2006. config.m = $('#m_hide') .prop('checked');
  2007. console.log($('#push').val());
  2008.  
  2009. }
  2010. if (type === 'custom' && $('#adv_theme').val() === 'custom') {
  2011. config.custom = {
  2012. main : $('#theme_main') .val(),
  2013. primary : $('#theme_primary') .val(),
  2014. secondary : $('#theme_secondary') .val(),
  2015. text : $('#theme_text') .val(),
  2016. link : $('#theme_link') .val(),
  2017. visited : $('#theme_visited') .val(),
  2018. prop : false
  2019. };
  2020. themes.custom = config.custom;
  2021. }
  2022. config.push = $('#push').val();
  2023. config.tv_api_key = $('#tv_api_key').val();
  2024.  
  2025. localStorage.setItem('_finder', JSON.stringify(config));
  2026. localStorage.setItem('_finder_bl', JSON.stringify(blocklist));
  2027. localStorage.setItem('_finder_il', JSON.stringify(includelist));
  2028.  
  2029. if (config.nl) { $('.nl').toggleClass('nl nl_hidden'); }
  2030. else { $('.nl_hidden').toggleClass('nl nl_hidden'); }
  2031.  
  2032. if (config.bl) { $('.bl').toggleClass('bl bl_hidden'); }
  2033. else { $('.bl_hidden').toggleClass('bl bl_hidden'); }
  2034.  
  2035. if (config.m) { $('.m').toggleClass('m m_hidden'); }
  2036. else { $('.m_hidden').toggleClass('m m_hidden'); }
  2037. }
  2038.  
  2039. function _theme () {
  2040. var theme = themes[config.theme];
  2041.  
  2042. $('#theme_main') .val(theme.main) .prop('disabled', theme.prop);
  2043. $('#theme_primary') .val(theme.primary) .prop('disabled', theme.prop);
  2044. $('#theme_secondary') .val(theme.secondary) .prop('disabled', theme.prop);
  2045. $('#theme_text') .val(theme.text) .prop('disabled', theme.prop);
  2046. $('#theme_link') .val(theme.link) .prop('disabled', theme.prop);
  2047. $('#theme_visited') .val(theme.visited) .prop('disabled', theme.prop);
  2048. _write_theme();
  2049. }
  2050.  
  2051. function _write_theme () {
  2052. var css = _to_theme(), theme = themes[config.theme];
  2053.  
  2054. css +=
  2055. 'html {color: #' + theme.text + '; background-color: #' + theme.main + '; line-height: 1.5; font-family: "Roboto", sans-serif; font-size: 15px; font-weight: normal;}' +
  2056. 'body {margin: 0px;}' +
  2057. '#menubar { background-color: #' + theme.menu + '; margin: 0px; padding: 3px; height:30px; color: #' + theme.menutext + ' }' +
  2058. '#latest_hits { margin: 5px; }' +
  2059. '#logged_hits { margin: 5px; }' +
  2060. '#config { background-color: #' + theme.primary + '; border: 2px #' + theme.text + ' solid; padding: 2px;}' +
  2061.  
  2062. '#bl_items, #il_items {background-color: #'+theme.main+'; height: calc(100% - 64px); overflow-y: scroll;}' +
  2063. '#bl_div, #il_div {background-color: #'+theme.primary+'; border: 2px solid #'+theme.secondary+';}' +
  2064.  
  2065. '.add {background-color: #'+theme.primary+'; border: 2px solid #'+theme.secondary+';}' +
  2066.  
  2067. '.bl {border: 2px solid #FF0000;}' +
  2068. '.il {border: 2px solid #009900;}' +
  2069. '.hidden, .nl_hidden, .bl_hidden, .m_hidden {display: none;}' +
  2070. 'button:focus {outline: none !important;}';
  2071.  
  2072. if (config.theme == 'light' ) {
  2073. css +=
  2074. '.tvHigh {background-color: rgba(0,128,0,0.3); }' +
  2075. '.tvFair {background-color: rgba(255,165, 0, 0.3);}' +
  2076. '.tvLow {background-color: rgba(255,0,0,0.3); }' +
  2077. '.tvNone {background-color: rgba(128,128,128, 0.3); }'
  2078. }
  2079.  
  2080. $('#css').html(css);
  2081. }
  2082.  
  2083. function _to_theme () {
  2084. var to, theme = themes[config.theme], color = '';
  2085. console.log(config.to_theme);
  2086. if (config.theme === 'default') {
  2087. color = 'd9d9d9';
  2088. }
  2089. else {
  2090. color = '262626';
  2091. }
  2092.  
  2093. switch (config.to_theme) {
  2094. case '1':
  2095. to =
  2096. 'td {font-weight: bold;}' +
  2097. '.cont, .hit, .details {color: #000000;}' +
  2098. '.toHigh {background-color: #33cc59;}' +
  2099. '.toGood {background-color: #a6cc33;}' +
  2100. '.toAverage {background-color: #cccc33;}' +
  2101. '.toLow {background-color: #cca633;}' +
  2102. '.toPoor {background-color: #cc3333;}' +
  2103. '.toNone {background-color: #cccccc;}' +
  2104. '.rt, .it, .pc {width: 20px; height: 20px; background-color: transparent; margin: 1px; border: 1px solid #000000; font-size: 80%; padding: 1px;}' +
  2105. '.vb, .irc {width: 25px; height: 20px; background-color: transparent; margin: 1px; border: 1px solid #000000; font-size: 80%; padding: 1px;}' +
  2106. '.clicked {background-color:grey;}';
  2107. ;
  2108. return to;
  2109. case '2':
  2110. to =
  2111. 'a {color: #'+theme.link+';}' +
  2112. 'a:visited {color: #'+theme.visited+';}' +
  2113. 'tbody td {color: #'+theme.text+';}' +
  2114. '.to a {color: #000000;}' +
  2115.  
  2116. '.cont, .details {color: #'+theme.text+';}' +
  2117. '.toHigh {background-color: #'+color+';}' +
  2118. '.toGood {background-color: #'+color+';}' +
  2119. '.toAverage {background-color: #'+color+';}' +
  2120. '.toLow {background-color: #'+color+';}' +
  2121. '.toPoor {background-color: #'+color+';}' +
  2122. '.toNone {background-color: #'+color+';}' +
  2123.  
  2124. '.toHigh .to {background-color: #33cc59;}' +
  2125. '.toGood .to {background-color: #a6cc33;}' +
  2126. '.toAverage .to {background-color: #cccc33;}' +
  2127. '.toLow .to {background-color: #cca633;}' +
  2128. '.toPoor .to {background-color: #cc3333;}' +
  2129. '.toNone .to {background-color: #cccccc;}' +
  2130. '.rt, .pc {width: 20px; height: 20px; color: #'+theme.text+'; background-color: transparent; margin: 1px; border: 1px solid #'+theme.text+'; font-size: 80%; padding: 1px;}' +
  2131. '.vb, .irc {width: 25px; height: 20px; color: #'+theme.text+'; background-color: transparent; margin: 1px; border: 1px solid #'+theme.text+'; font-size: 80%; padding: 1px;}' +
  2132. '.clicked {background-color:grey;}';
  2133. ;
  2134. return to;
  2135. case '3':
  2136. to =
  2137. 'a {color: #'+theme.link+';}' +
  2138. 'a:visited {color: #'+theme.visited+';}' +
  2139. 'tbody td {color: #'+theme.text+';}' +
  2140.  
  2141. '.cont, .details {color: #'+theme.text+';}' +
  2142. '.toHigh {background-color: #'+color+';}' +
  2143. '.toGood {background-color: #'+color+';}' +
  2144. '.toAverage {background-color: #'+color+';}' +
  2145. '.toLow {background-color: #'+color+';}' +
  2146. '.toPoor {background-color: #'+color+';}' +
  2147. '.toNone {background-color: #'+color+';}' +
  2148.  
  2149. '.toHigh .to a {color: #33cc59;}' +
  2150. '.toGood .to a {color: #a6cc33;}' +
  2151. '.toAverage .to a {color: #cccc33;}' +
  2152. '.toLow .to a {color: #cca633;}' +
  2153. '.toPoor .to a {color: #cc3333;}' +
  2154. '.toNone .to a {color: #cccccc;}' +
  2155. '.rt, .pc {width: 20px; height: 20px; color: #'+theme.text+'; background-color: transparent; margin: 1px; border: 1px solid #'+theme.text+'; font-size: 80%; padding: 1px;}' +
  2156. '.vb, .irc {width: 25px; height: 20px; color: #'+theme.text+'; background-color: transparent; margin: 1px; border: 1px solid #'+theme.text+'; font-size: 80%; padding: 1px;}' +
  2157. '.clicked {background-color:grey;}';
  2158. ;
  2159. return to;
  2160. }
  2161. }
  2162.  
  2163. $('#type option[value="' + config.type + '"]') .prop('selected', true);
  2164. $('#size option[value="' + config.size + '"]') .prop('selected', true);
  2165. $('#new_audio option[value="' + config.newaudio + '"]') .prop('selected', true);
  2166. $('#adv_theme option[value="' + config.theme + '"]') .prop('selected', true);
  2167. $('#to_theme option[value="' + config.to_theme + '"]') .prop('selected', true);
  2168.  
  2169. _theme();
  2170. _init_lists();
  2171. _hide_hit_list( config.h_hidden == '1' ? true : false );
  2172. _hide_log_list( config.l_hidden == '1' ? true : false );

QingJ © 2025

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