HIT Forker

Monitors mturk.com for HITs

目前為 2019-09-12 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name HIT Forker
  3. // @version 1.2.2
  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. '<base target="_blank">' +
  328.  
  329. '<audio id="audio_1"><source src="https://www.soundjay.com/button/sounds/button-1.mp3" type="audio/mpeg"></audio>' +
  330. '<audio id="audio_2"><source src="https://www.soundjay.com/button/sounds/button-3.mp3" type="audio/mpeg"></audio>' +
  331. '<audio id="audio_3"><source src="https://www.soundjay.com/button/sounds/button-4.mp3" type="audio/mpeg"></audio>' +
  332. '<audio id="audio_4"><source src="https://www.soundjay.com/button/sounds/button-5.mp3" type="audio/mpeg"></audio>' +
  333. '<audio id="audio_beep"><source src="https://www.soundjay.com/button/sounds/beep-21.mp3" type="audio/mpeg"></audio>' +
  334. '<audio id="audio_beepbeep"><source src="https://www.soundjay.com/button/sounds/beep-24.mp3" type="audio/mpeg"></audio>' +
  335. '<audio id="audio_click"><source src="https://www.soundjay.com/button/sounds/button-20.mp3" type="audio/mpeg"></audio>' +
  336.  
  337. '<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">' +
  338. '<style id="css" type="text/css">'
  339. );
  340.  
  341. $('body').on('click', '.closeTvAlert', function(){
  342. $(this).parent().parent().hide();
  343. });
  344.  
  345. $('body').html(
  346. // Main
  347. '<div style="margin-bottom: 5px; text-align:right;" id="menubar">' +
  348. '<div style="position: absolute; top: 32px width: 100px; font-size: 14pt; font-weight: bold;" id="menu_title">HIT Forker</div>'+
  349. '<div style="line-height: 30px; margin-right:5px;">'+
  350. '<button id="scan_button" style="margin-right: 5px;">Start</button>' +
  351. '<button id="bloc_button" style="margin-right: 5px;">Block List</button>' +
  352. '<button id="incl_button" style="margin-right: 5px;">Include List</button>' +
  353. '<button id="sett_button" style="margin-right: 5px;">Advanced Settings</button>' +
  354. '<button id="conf_button" style="margin-right: 5px;">Show Config</button>' +
  355.  
  356. '</div></div>' +
  357.  
  358. // Config
  359. '<div id="config" style="position: absolute; top: 37px; right: 5px; margin-bottom: 5px;" class="hidden">' +
  360.  
  361. '<div style="margin-bottom: 5px;">' +
  362. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;" title="Delay in seconds between searches.">Search Delay: ' +
  363. '<input id="delay" style="width: 50px;" type="number" step="1" min="1" value="' + config.delay + '">' +
  364. '</label>' +
  365.  
  366. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;" title="Filter HITs by minimum reward.">Min Reward: ' +
  367. '<input id="min_rew" style="width: 50px;" type="number" step="0.01" min="0" value="' + config.rew + '">' +
  368. '</label>' +
  369.  
  370. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;" title="Filter HITs by minimum available.">Min Avail: ' +
  371. '<input id="min_avail" style="width: 50px;" type="number" step="1" min="0" value="' + config.avail + '">' +
  372. '</label>' +
  373.  
  374. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;" title="Filter HITs by minimum TO pay.">Min TO: ' +
  375. '<input id="min_to" style="width: 50px;" type="number" step="0.1" min="0" max="5" value="' + config.mto + '">' +
  376. '</label>' +
  377.  
  378. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;" title="Search for this many HITs.">Size: ' +
  379. '<input id="size" style="width: 50px;" type="number" step="1" min="1" max="100" value="' + config.size + '">' +
  380. '</label>' +
  381.  
  382. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;" title="Sort HITs by (Latest / Most Available / Highest Reward)">Sort by: ' +
  383. '<select id="type" value="' + config.type + '">' +
  384. '<option value="' + upd + '">Latest</option>' +
  385. '<option value="' + num + '">Most Available</option>' +
  386. '<option value="' + rew + '">Reward (Most)</option>' +
  387. '</select>' +
  388. '</label>' +
  389.  
  390. '<label style="margin-right: 0px; display: inline-block; border-bottom: 1px solid;" title="Only show HITs that you are for.">Qualified' +
  391. '<input id="qual" type="checkbox" ' + (config.qual ? 'checked' : '') + '>' +
  392. '</label>' +
  393. '</div>' +
  394.  
  395. '<div style="margin-bottom: 5px;">' +
  396. '<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: ' +
  397. '<input id="alert_delay" style="width: 50px;" type="number" step="1" min="0" value="' + config.alert + '">' +
  398. '</label>' +
  399.  
  400. '<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 ' +
  401. '<input id="new_sound" type="checkbox" ' + (config.new ? 'checked' : '') + '>' +
  402. '<select id="new_audio" value="' + config.newaudio + '">' +
  403. //'<option value="default">Default</option>' +
  404. '<option value="beep">Beep</option>' +
  405. '<option value="beepbeep">Beep Beep</option>' +
  406. //'<option value="ding">Ding</option>' +
  407. //'<option value="squee">Squee</option>' +
  408. '<option value="click">Click</option>' +
  409. '</select>' +
  410. '</label>' +
  411.  
  412. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;" title="Allow include list to send a TTS notification when matched">TTS ' +
  413. '<input id="tts" type="checkbox" ' + (config.tts ? 'checked' : '') + '>' +
  414. '</label>' +
  415.  
  416. '<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 ' +
  417. '<input id="pb" type="checkbox" ' + (config.pb ? 'checked' : '') + '>' +
  418. '</label>' +
  419.  
  420. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;" title="Use turkopticon.">Enable TO ' +
  421. '<input id="to" type="checkbox" ' + (config.to ? 'checked' : '') + '>' +
  422. '</label>' +
  423.  
  424. '<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 ' +
  425. '<input id="nl_hide" type="checkbox" ' + (config.nl ? 'checked' : '') + '>' +
  426. '</label>' +
  427.  
  428. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;" title="Hide HITs that match your block list.">Hide Block List ' +
  429. '<input id="bl_hide" type="checkbox" ' + (config.bl ? 'checked' : '') + '>' +
  430. '</label>' +
  431.  
  432. '</div>' +
  433.  
  434. '</div>' +
  435.  
  436. '<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;">' +
  437. '<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>' +
  438.  
  439. `<small>
  440. <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>
  441. <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>]
  442. <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>
  443. <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>
  444. </small><form action="saveForkerApiForm" onsubmit="return false;">
  445. <input type="text" class="form-control" style="max-width: 50%; margin-top: 5px; margin-bottom: 5px;">
  446. <button type="submit" class="btn btn-primary">Save API Key</button>
  447. </form>
  448. <script>
  449. $('form[action*=saveForkerApiForm]').submit(function(e){
  450. e.preventDefault();
  451. let api_key = $(this).find('input[type=text]').val().trim();
  452. console.log(api_key);
  453. if (api_key.length == 40){
  454. localStorage.setItem('turkerview_api_key', api_key);
  455. alert('Awesome, we saved your API key for future use! HIT Forker will reload now.');
  456. window.location.reload();
  457. } else {
  458. alert("We cannot save the provided key as it isn't valid.");
  459. }
  460. });
  461. </script>` +
  462.  
  463. '</div>'+
  464.  
  465. '<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;">' +
  466. '<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>' +
  467. '<p style="margin-bottom: 0.5rem; margin-top: 0.5rem;">Error Message.</p>' +
  468. '</div>'+
  469. // HITs
  470. '<div id="latest_hits">' +
  471. '<div style="border-bottom: 3px solid; margin-bottom: 5px;">' +
  472. '<span style="font-size: 20px; font-weight: bold;">HITs</span>' +
  473. '<span id="hits_data" style="font-size: 11px;"></span>' +
  474. '<span id="hits_controls" style="float: right"><button id="hits_button" style="margin-right: 5px;">Hide New HITs</button></span>' +
  475. '</div>' +
  476. '<div id="hits_hidden" style="text-align: center; display: none;">--- HITS HIDDEN ---</div>' +
  477. '<div id="hits_table">' +
  478. '<div>' +
  479. '<div style="overflow: hidden; white-space: nowrap;">' +
  480. '<div style="float: left; width: calc(100% - 330px);">' +
  481. '<span style="width: 34%; float: left; display:inline-block; overflow: hidden;">Requester</span>' +
  482. '<span style="width: 64%; float: right; display:inline-block; overflow: hidden;">Project</span>' +
  483. '</div>' +
  484.  
  485. '<div style="float: right;">' +
  486. '<span style="width: 60px; display:inline-block; text-align: center;">Tasks</span>' +
  487. '<span style="width: 60px; display:inline-block; text-align: center;">Accept</span>' +
  488. '<span style="width: 60px; display:inline-block; text-align: center;">TV</span>' +
  489. '<span style="width: 60px; display:inline-block; text-align: center;">TO</span>' +
  490. '<span style="width: 60px; display:inline-block; text-align: center;">PANDA</span>' +
  491. '</div>' +
  492. '</div>' +
  493. '</div>' +
  494. '<div id="new_hits_"></div>' +
  495. '</div>' +
  496. '</div>' +
  497.  
  498. '<br>' +
  499.  
  500. //Logged HITs
  501. '<div id="logged_hits">' +
  502. '<div style="border-bottom: 3px solid; margin-bottom: 5px;">' +
  503. '<span style="font-size: 20px; font-weight: bold;">Logged HITs</span>' +
  504. '<span id="logged_hits_data" style="font-size: 11px;"></span>' +
  505. '<span id="log_controls" style="float: right"><button id="logg_button" style="margin-right: 0px;">Hide Logged HITs</button></span>' +
  506. '</div>' +
  507. '<div id="log_hidden" style="text-align: center; display: none;">--- LOGGED HITS HIDDEN ---</div>' +
  508. '<div id="log_table">' +
  509. '<div>' +
  510. '<div style="overflow: hidden; white-space: nowrap;">' +
  511.  
  512. '<div style="float: left;">' +
  513. '<span style="width: 80px; display:inline-block;">Time</span>' +
  514. '</div>' +
  515.  
  516. '<div style="float: left; width: calc(100% - 3500px);">' +
  517. '<span style="width: 25%; float: left; display:inline-block; overflow: hidden;">Requester</span>' +
  518. '<span style="width: 75%; float: right; display:inline-block; overflow: hidden;">Project</span>' +
  519.  
  520. '</div>' +
  521.  
  522. '<div style="float: right;">' +
  523. '<span style="width: 60px; display:inline-block; text-align: center;">Avail</span>' +
  524. '<span style="width: 60px; display:inline-block; text-align: center;">Accept</span>' +
  525. '<span style="width: 60px; display:inline-block; text-align: center;">TV</span>' +
  526. '<span style="width: 60px; display:inline-block; text-align: center;">TO</span>' +
  527. '<span style="width: 60px; display:inline-block; text-align: center;">PANDA</span>' +
  528. '</div>' +
  529. '</div>' +
  530. '</div>' +
  531. '<div id="log_hits_"></div>' +
  532. '</div>' +
  533. '</div>' +
  534.  
  535. // Block List
  536. '<div id="bl_div" style="z-index: 99; position: fixed; width: 80%; height: 80%; left: 10%; top: 300px; margin-top: -250px; display: none;">' +
  537. '<div style="position: relative; width: 80%; left: 10%; border-bottom: 3px solid; padding: 2px; text-align: center;">Block List</div>' +
  538. '<div id="bl_items"></div>' +
  539. '<div style="text-align: center;">' +
  540. '<button id="bl_add" style="margin-right: 5px;">Add</button>' +
  541. '<button id="bl_close" style="margin-right: 5px;">Close</button>' +
  542. '<button id="bl_import" style="margin-right: 5px;">Import</button>' +
  543. '<button id="bl_export" style="margin-right: 0px;">Export</button>' +
  544. '</div>' +
  545. '</div>' +
  546.  
  547. // Add Block List Popup
  548. '<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;">' +
  549. '<div style="position: relative; width: 80%; left: 10%; border-bottom: 3px solid; padding: 2px; text-align: center;">Add To Block List</div>' +
  550.  
  551. '<div>' +
  552. '<p><label>Term: </label><input id="bl_term" value="" maxlength="300"></p>' +
  553. '<p><label>Name: </label><input id="bl_name" value="" maxlength="300"></p>' +
  554. '<input id="bl_gid" value="0" type="hidden">' +
  555. '</div>' +
  556.  
  557. '<div>' +
  558. '<button id="bl_add_save" style="margin-right: 5px;">Save</button>' +
  559. '<button id="bl_add_cancel" style="margin-right: 0px;">Cancel</button>' +
  560. '</div>' +
  561. '</div>' +
  562.  
  563. // Edit Block List Popup
  564. '<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;">' +
  565. '<div style="position: relative; width: 80%; left: 10%; border-bottom: 3px solid; padding: 2px; text-align: center;">Edit Block List Item</div>' +
  566.  
  567. '<div>' +
  568. '<p><label>Term: </label><input id="edit_bl_term" value=""disabled></p>' +
  569. '<p><label>Name: </label><input id="edit_bl_name" value=""></p>' +
  570. '</div>' +
  571.  
  572. '<div>' +
  573. '<button id="edit_bl_save" style="margin-right: 5px;">Save</button>' +
  574. '<button id="edit_bl_delete" style="margin-right: 5px;">Delete</button>' +
  575. '<button id="edit_bl_cancel" style="margin-right: 0px;">Cancel</button>' +
  576. '</div>' +
  577. '</div>' +
  578.  
  579. // Include List
  580. '<div id="il_div" style="z-index: 99; position: fixed; width: 80%; height: 80%; left: 10%; top: 300px; margin-top: -250px; display: none;">' +
  581. '<div style="position: relative; width: 80%; left: 10%; border-bottom: 3px solid; padding: 2px; text-align: center;">Include List</div>' +
  582. '<div id="il_items"></div>' +
  583. '<div style="text-align: center;">' +
  584. '<button id="il_add" style="margin-right: 5px;">Add</button>' +
  585. '<button id="il_close" style="margin-right: 5px;">Close</button>' +
  586. '<button id="il_import" style="margin-right: 5px;">Import</button>' +
  587. '<button id="il_export" style="margin-right: 0px;">Export</button>' +
  588. '</div>' +
  589. '</div>' +
  590.  
  591. // Add Include List Popup
  592. '<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;">' +
  593. '<div style="position: relative; width: 80%; left: 10%; border-bottom: 3px solid; padding: 2px; text-align: center;">Add To Include List</div>' +
  594.  
  595. '<div>' +
  596. '<p><label>Term: </label><input id="il_term" value=""></p>' +
  597. '<p><label>Name: </label><input id="il_name" value=""></p>' +
  598. '</div>' +
  599.  
  600. '<div style="position: relative; width: 80%; left: 10%; border-bottom: 3px solid; padding: 2px; text-align: center;">Alerts</div>' +
  601.  
  602. '<p>' +
  603. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;">Sound: ' +
  604. '<select id="il_sound">' +
  605. '<option value="1">Sound 1</option>' +
  606. '<option value="2">Sound 2</option>' +
  607. '<option value="3">Sound 3</option>' +
  608. '<option value="4">Sound 4</option>' +
  609. '</select>' +
  610. '</label>' +
  611.  
  612. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;">Desktop Notifications' +
  613. '<input id="il_noti_cb" type="checkbox">' +
  614. '</label>' +
  615.  
  616. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;">Play Sound' +
  617. '<input id="il_sound_cb" type="checkbox">' +
  618. '</label>' +
  619.  
  620. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;">Send Pushbullet' +
  621. '<input id="il_push_cb" type="checkbox">' +
  622. '</label>' +
  623. '</p>' +
  624.  
  625. '<div>' +
  626. '<button id="il_add_save" style="margin-right: 5px;">Save</button>' +
  627. '<button id="il_add_cancel" style="margin-right: 0px;">Cancel</button>' +
  628. '</div>' +
  629. '</div>' +
  630.  
  631. // Edit Include List Popup
  632. '<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;">' +
  633. '<div style="position: relative; width: 80%; left: 10%; border-bottom: 3px solid; padding: 2px; text-align: center;">Edit Include List Item</div>' +
  634.  
  635. '<div>' +
  636. '<p><label>Term: </label><input id="edit_il_term" value="" disabled></p>' +
  637. '<p><label>Name: </label><input id="edit_il_name" value=""></p>' +
  638. '</div>' +
  639.  
  640. '<div style="position: relative; width: 80%; left: 10%; border-bottom: 3px solid; padding: 2px; text-align: center;"">Alerts</div>' +
  641.  
  642. '<p>' +
  643. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;">Sound: ' +
  644. '<select id="edit_il_sound">' +
  645. '<option value="1">Sound 1</option>' +
  646. '<option value="2">Sound 2</option>' +
  647. '<option value="3">Sound 3</option>' +
  648. '<option value="4">Sound 4</option>' +
  649. '</select>' +
  650. '</label>' +
  651.  
  652. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;">Desktop Notifications' +
  653. '<input id="edit_il_noti_cb" type="checkbox">' +
  654. '</label>' +
  655.  
  656. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;">Play Sound' +
  657. '<input id="edit_il_sound_cb" type="checkbox">' +
  658. '</label>' +
  659.  
  660. '<label style="margin-right: 0px; display: inline-block; border-bottom: 1px solid;">Send Pushbullet' +
  661. '<input id="edit_il_push_cb" type="checkbox">' +
  662. '</label>' +
  663. '</p>' +
  664.  
  665. '<div>' +
  666. '<button id="edit_il_save" style="margin-right: 5px;">Save</button>' +
  667. '<button id="edit_il_delete" style="margin-right: 5px;">Delete</button>' +
  668. '<button id="edit_il_cancel" style="margin-right: 0px;">Cancel</button>' +
  669. '</div>' +
  670. '</div>' +
  671.  
  672. // Advanced Settings
  673. '<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;">' +
  674. '<div style="position: relative; width: 80%; left: 10%; border-bottom: 3px solid; padding: 2px; text-align: center;">Advanced Settings</div>' +
  675.  
  676. '<div>' +
  677. '<p><label>Pushbullet Token: </label><input id="push" value="' + config.push + '"></p>' +
  678. '</div>' +
  679. '<div style="position: relative; width: 80%; left: 10%; border-bottom: 3px solid; padding: 2px; text-align: center;">TurkerView</div>' +
  680. '<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>' +
  681. '<div><p><label><input type="checkbox" name="disable_turkerview"' + (config.disable_tv ? 'checked' : '') + '> Disable TurkerView</label></p></div>' +
  682. '<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>' +
  683.  
  684. '<div style="position: relative; width: 80%; left: 10%; border-bottom: 3px solid; padding: 2px; text-align: center;">Theme</div>' +
  685.  
  686. '<p>' +
  687. '<label style="margin-right: 5px; display: inline-block; border-bottom: 1px solid;">Theme: ' +
  688. '<select id="adv_theme" value="' + config.theme + '">' +
  689. '<option value="default">Default (Light)</option>' +
  690. '<option value="light">Pastel</option>' +
  691. '<option value="dark">Dark</option>' +
  692. '<option value="darker">Darker</option>' +
  693. '<option value="custom">Custom</option>' +
  694. '</select>' +
  695. '</label>' +
  696.  
  697. '<label style="margin-right: 0px; display: inline-block; border-bottom: 1px solid;">TO Theme: ' +
  698. '<select id="to_theme" value="' + config.to_theme + '">' +
  699. '<option value="1">Default</option>' +
  700. '<option value="2">Column Only</option>' +
  701. '<option value="3">Text Only</option>' +
  702. '</select>' +
  703. '</label>' +
  704. '</p>' +
  705.  
  706. '<p>' +
  707. '<label style="width: 150px; margin-right: 5px; display: inline-block; border-bottom: 1px solid; text-align: left;">Main: #' +
  708. '<input id="theme_main" style="width: 55px; float: right;" maxlength="6">' +
  709. '</label>' +
  710.  
  711. '<label style="width: 150px; margin-right: 5px; display: inline-block; border-bottom: 1px solid; text-align: left;">Primary: #' +
  712. '<input id="theme_primary" style="width: 55px; float: right;" maxlength="6">' +
  713. '</label>' +
  714.  
  715. '<label style="width: 150px; margin-right: 0px; display: inline-block; border-bottom: 1px solid; text-align: left;">Secondary: #' +
  716. '<input id="theme_secondary" style="width: 55px; float: right;" maxlength="6">' +
  717. '</label>' +
  718. '</p>' +
  719.  
  720. '<p>' +
  721. '<label style="width: 150px; margin-right: 5px; display: inline-block; border-bottom: 1px solid; text-align: left;">Text: #' +
  722. '<input id="theme_text" style="width: 55px; float: right;" maxlength="6">' +
  723. '</label>' +
  724.  
  725. '<label style="width: 150px; margin-right: 5px; display: inline-block; border-bottom: 1px solid; text-align: left;">Link: #' +
  726. '<input id="theme_link" style="width: 55px; float: right;" maxlength="6">' +
  727. '</label>' +
  728.  
  729. '<label style="width: 150px; margin-right: 0px; display: inline-block; border-bottom: 1px solid; text-align: left;">Visited: #' +
  730. '<input id="theme_visited" style="width: 55px; float: right;" maxlength="6">' +
  731. '</label>' +
  732. '</p>' +
  733.  
  734. '<div>' +
  735. '<button id="sett_save" style="margin-right: 5px;">Save</button>' +
  736. '<button id="sett_close" style="margin-right: 0px;">Close</button>' +
  737. '</div>' +
  738. '</div>'
  739. );
  740.  
  741. // Click functions
  742. $('#scan_button').click(function () {
  743. if ($(this).text() === 'Start') {
  744. $(this).text('Stop');
  745. _scan();
  746. }
  747. else {
  748. $(this).text('Start');
  749. }
  750. });
  751.  
  752. $('#sett_button').click(function () {
  753. $('#sett').toggle();
  754. });
  755.  
  756. $('#conf_button').click(function () {
  757. if ($(this).text() === 'Hide Config') {
  758. $(this).text('Show Config');
  759. }
  760. else {
  761. $(this).text('Hide Config');
  762. }
  763. $('#config').toggleClass('hidden');
  764. });
  765.  
  766. $('#logg_button').click(function () {
  767. _hide_log_list( $(this).text() === 'Hide Logged HITs' ? true : false );
  768. });
  769.  
  770. $('#hits_button').click(function () {
  771. _hide_hit_list( $(this).text() === 'Hide New HITs' ? true : false );
  772. });
  773.  
  774. $('#bloc_button').click(function () {
  775. $('#bl_div').toggle();
  776. });
  777.  
  778. $('#bl_add').click(function () {
  779. $('#bl').show();
  780. });
  781.  
  782. $('#bl_close').click(function () {
  783. $('#bl_div').hide();
  784. });
  785.  
  786. $('#bl_import').click(function () {
  787. _import_block();
  788. });
  789.  
  790. $('#bl_export').click(function () {
  791. _export_block();
  792. });
  793.  
  794. $('#bl_add_save').click(function () {
  795. var obj = {
  796. term : $('#bl_term').val(),
  797. name : $('#bl_name').val() === '' ? $('#bl_term').val() : $('#bl_name').val(),
  798. gid : $('#bl_gid').val() === '' ? 'X' : $('#bl_gid').val()
  799. };
  800.  
  801. _add_block(obj);
  802.  
  803. if ( obj.gid != 'X' ) {
  804. $('.loggid_' + obj.gid ).remove();
  805. }
  806. else {
  807. $('.logreqid_' + obj.term ).remove();
  808. }
  809.  
  810. $('#bl_term, #bl_name').val('');
  811. $('#bl').hide();
  812. });
  813.  
  814. $('#bl_add_cancel').click(function () {
  815. $('#bl_term, #bl_name').val('');
  816. $('#bl').hide();
  817. });
  818.  
  819. $('#edit_bl_save').click(function () {
  820. _update_block($(this).val());
  821. $('#edit_bl_term, #edit_bl_name').val('');
  822. $('#edit_bl').hide();
  823. });
  824.  
  825. $('#edit_bl_delete').click(function () {
  826. _delete_block($(this).val());
  827. $('#edit_bl_term, #edit_bl_name').val('');
  828. $('#edit_bl').hide();
  829. });
  830.  
  831. $('#edit_bl_cancel').click(function () {
  832. $('#edit_bl_term, #edit_bl_name').val('');
  833. $('#edit_bl').hide();
  834. });
  835.  
  836. $('#incl_button').click(function () {
  837. $('#il_div').toggle();
  838. });
  839.  
  840. $('#il_add').click(function () {
  841. $('#il').show();
  842. });
  843.  
  844. $('#il_close').click(function () {
  845. $('#il_div').hide();
  846. });
  847.  
  848. $('#il_import').click(function () {
  849. _import_include();
  850. });
  851.  
  852. $('#il_export').click(function () {
  853. _export_include();
  854. });
  855.  
  856. $('#il_add_save').click(function () {
  857. var obj = {
  858. term : $('#il_term').val().trim(),
  859. name : $('#il_name').val().trim() === '' ? $('#il_term').val().trim() : $('#il_name').val().trim(),
  860. sound : $('#il_sound').val(),
  861. noti_cb : $('#il_noti_cb').prop('checked'),
  862. sound_cb : $('#il_sound_cb').prop('checked'),
  863. push_cb : $('#il_push_cb').prop('checked')
  864. };
  865.  
  866. _add_include(obj);
  867.  
  868. $('#il_term, #il_name').val('');
  869. $('#il').hide();
  870. });
  871.  
  872. $('#il_add_cancel').click(function () {
  873. $('#il_term, #il_name').val('');
  874. $('#il').hide();
  875. });
  876.  
  877. $('#edit_il_save').click(function () {
  878. _update_include($(this).val());
  879. $('#edit_il_term, #edit_il_name, #edit_il_sound').val('');
  880. $('#edit_il_noti_cb, #edit_il_sound_cb, #edit_il_push_cb').prop('checked', false);
  881. $('#edit_il').hide();
  882. });
  883.  
  884. $('#edit_il_delete').click(function () {
  885. _delete_include($(this).val());
  886. $('#edit_il_term, #edit_il_name, #edit_il_sound').val('');
  887. $('#edit_il_noti_cb, #edit_il_sound_cb, #edit_il_push_cb').prop('checked', false);
  888. $('#edit_il').hide();
  889. });
  890.  
  891. $('#edit_il_cancel').click(function () {
  892. $('#edit_il_term, #edit_il_name, #edit_il_sound').val('');
  893. $('#edit_il_noti_cb, #edit_il_sound_cb, #edit_il_push_cb').prop('checked', false);
  894. $('#edit_il').hide();
  895. });
  896.  
  897. $('.on, .off').click(function () {
  898. $(this).toggleClass('on off');
  899. _save();
  900. });
  901.  
  902. $('#sett_save').click(function () {
  903.  
  904. let original_key = config.tv_api_key;
  905. let new_key = $('#tv_api_key').val();
  906. let disable_tv = $('input[name=disable_turkerview]').is(':checked');
  907. config.disable_tv = disable_tv;
  908. _save('custom');
  909. _theme();
  910. if (original_key != new_key) {
  911. $('#sett').prepend(`<p class="saved-settings-alert">Settings Saved! We'll reload Forker shortly.</p>`);
  912. setTimeout(function() {
  913. window.location.reload();
  914. }, 1000)
  915. } else $('#sett').prepend(`<p class="saved-settings-alert">Settings Saved!</p>`);
  916. });
  917.  
  918. $('#sett_close').click(function () {
  919. $('#sett').find('.saved-settings-alert').remove();
  920. $('#sett').hide();
  921. });
  922.  
  923. $('#time').click(function () {
  924. $('.new').removeClass('new');
  925. });
  926.  
  927. // Delegated click functions
  928. $('body').on('click', '.blockit', function () {
  929. _edit_block($(this).val());
  930. });
  931.  
  932. $('body').on('click', '.includeit', function () {
  933. _edit_include($(this).val());
  934. });
  935.  
  936. $('body').on('click', '.rt', function () {
  937. _block($(this).data('term'), $(this).data('name'), $(this).attr('id'));
  938. });
  939.  
  940. $('body').on('click', '.it', function () {
  941. _includerid($(this).data('term'), $(this).data('name'), $(this).attr('id'));
  942. });
  943.  
  944. $('body').on('click', '.pc', function () {
  945. _panda($(this).data('term'), $(this).data('reqname'), $(this).data('reqid'), $(this).data('title'), $(this).data('value'), $(this).data('name'), $(this))
  946. });
  947.  
  948. $('body').on('click', '.vb', function () {
  949. _export_vb($(this).val());
  950. });
  951.  
  952. $('body').on('click', '.irc', function () {
  953. _export_irc($(this).val());
  954. });
  955.  
  956. $('body').on('click', '.details', function () {
  957. $(this).toggleClass('fa-plus-circle fa-minus-circle');
  958. $('.info[value="' + $(this).val() + '"]').toggle();
  959. });
  960.  
  961. // Delegated mouseover functions
  962. $('body').on('mouseover', '.new', function () {
  963. $(this).removeClass('new');
  964. });
  965.  
  966. // On change events
  967. $('#new_audio').change(function () {
  968. _save();
  969. _sound('new');
  970. });
  971.  
  972. $('#il_sound').change(function () {
  973. _sound('il');
  974. });
  975.  
  976. $('#edit_il_sound').change(function () {
  977. _sound('il_edit');
  978. });
  979.  
  980. $('#type, #size, #adv_theme, #to_theme, #c_theme, :checkbox').change(function () {
  981. _save();
  982. });
  983.  
  984. $('#adv_theme, #to_theme, #c_theme').change(function () {
  985. _theme();
  986. });
  987.  
  988. // On input events
  989. $('#delay, #min_rew, #min_avail, #min_to, #alert_delay').on('input', function () {
  990. _save();
  991. });
  992.  
  993. function sanitize(strings, ...values) {
  994. console.log( strings );
  995. const dirty = strings.reduce((prev, next, i) => `${prev}${next}${values[i]} || ''}`, '');
  996. return DomPurify.sanitize(dirty);
  997. }
  998.  
  999. function extend(obj, src) {
  1000. for (var key in src) {
  1001. if (src.hasOwnProperty(key)) obj[key] = src[key];
  1002. }
  1003. return obj;
  1004. }
  1005.  
  1006. function _scan () {
  1007. var searchqualvar
  1008. searchqualvar = (config.qual ? 'true' : 'false');
  1009.  
  1010.  
  1011. if ($('#scan_button').text() === 'Stop') {
  1012. var _url = url + $('#type').val() + $('#size').val() + minrew + $('#min_rew').val() + searchqual + searchqualvar;
  1013. //console.log( _url );
  1014. var _scanurl = _url + '&format=json';
  1015.  
  1016. var date = new Date(), h = date.getHours(), m = date.getMinutes(), s = date.getSeconds(), ampm = h >= 12 ? 'pm' : 'am';
  1017. h = h % 12; h = h ? h : 12; m = m < 10 ? '0' + m : m; s = s < 10 ? '0' + s : s;
  1018. var timeis = [h, m, s, ampm];
  1019. console.log( _scanurl );
  1020. $.get(_scanurl, function (data) {
  1021. _scrape_new(data, timeis);
  1022. }).fail(function () {
  1023. setTimeout(function () { _scan(); }, 2500);
  1024. });
  1025. }
  1026. }
  1027.  
  1028. function _scrape_new (data, timeis) {
  1029. var keys = [], log_keys = [], to = [], logged_in = true;
  1030. var new_requesters = [];
  1031. var hits = data.results;
  1032. //Set config for allowed tags
  1033. var config = {
  1034. ALLOWED_TAGS: ['p', '#text']
  1035. };
  1036.  
  1037. for (var i = 0; i < hits.length; i ++) {
  1038. var hit = hits[i],
  1039. req_name = DOMPurify.sanitize(hit.requester_name,config).replace(/"/g, "&quot;" ),
  1040. req_id = DOMPurify.sanitize(hit.requester_id,config),
  1041. req_link = DOMPurify.sanitize(hit.requester_url.replace(/\.json/, ''),config),
  1042. //req_link = 'https://www.mturk.com/mturk/searchbar?selectedSearchType=hitgroups&requesterId=' + hit.requester_id,
  1043. con_link = DOMPurify.sanitize('https://www.mturk.com/mturk/contact?requesterId=' + hit.requester_id, config),
  1044. group_id = DOMPurify.sanitize(hit.hit_set_id,config),
  1045. prev_link = DOMPurify.sanitize(hit.project_tasks_url.replace(/\.json/, ''),config),
  1046. //prev_link = 'https://www.mturk.com/mturk/preview?groupId=' + hit.hit_set_id,
  1047. pand_link = DOMPurify.sanitize(hit.accept_project_task_url.replace(/\.json/, ''),config),
  1048. //pand_link = 'https://www.mturk.com/mturk/previewandaccept?groupId=' + hit.hit_set_id,
  1049. title = DOMPurify.sanitize(hit.title,config),
  1050. safetitle = title.replace(/"/g, "&quot;" ),
  1051. desc = DOMPurify.sanitize(hit.description.replace(/"/g, "&quot;" ),config),
  1052. time = _convert_seconds(hit.assignment_duration_in_seconds),
  1053. reward = DOMPurify.sanitize('$' + hit.monetary_reward.amount_in_dollars.toFixed(2),config),
  1054. avail = DOMPurify.sanitize(hit.assignable_hits_count,config);
  1055.  
  1056. var key = req_id + title + reward + group_id;
  1057. keys.push(key);
  1058.  
  1059. var qualif = 'None';
  1060. var quals = hit.project_requirements;
  1061.  
  1062.  
  1063. if (quals.length) {
  1064.  
  1065. qualif = '';
  1066. for (var j = 0; j < quals.length; j ++) {
  1067. var q_comp = quals[j].comparator + ' ';
  1068. var q_name = quals[j].qualification_type.name + ' ';
  1069.  
  1070. var q_valu = quals[j].qualification_values;
  1071. var q_values = '';
  1072. for (var k = 0; k < quals.length; k ++) {
  1073. if (quals[j].qualification_values[k]) {
  1074. q_values += quals[j].qualification_values[k];
  1075. q_values += k === quals.length ? ', ' : '';
  1076. }
  1077. }
  1078. if ( typeof quals[j].qualification_request_url !== 'undefined' ) {
  1079. q_values += '~!~' + quals[j].qualification_request_url;
  1080. }
  1081. qualif += (q_name + q_comp + q_values).trim() + '; ';
  1082. }
  1083. qualif = qualif.trim();
  1084. }
  1085.  
  1086. qualif = DOMPurify.sanitize(qualif,config);
  1087.  
  1088. if (!hitlog[key]) {
  1089. hitlog[key] = {
  1090. reqname : req_name,
  1091. reqid : req_id,
  1092. reqlink : req_link,
  1093. conlink : con_link,
  1094. groupid : group_id,
  1095. prevlink : prev_link,
  1096. pandlink : pand_link,
  1097. title : title,
  1098. safetitle: safetitle,
  1099. desc : desc,
  1100. time : time,
  1101. reward : reward,
  1102. avail : avail,
  1103. quals : qualif,
  1104. key : key,
  1105. tolink : 'https://turkopticon.ucsd.edu/' + req_id,
  1106. to : { comm : 'N/A', fair : 'N/A', fast : 'N/A', pay : 'N/A' },
  1107. tvlink : 'https://turkerview.com/requesters/' + req_id,
  1108. tv : 'N/A'
  1109. };
  1110.  
  1111. if ( $.inArray( req_id, requesters ) == -1 ) {
  1112. new_requesters.push( req_id );
  1113. }
  1114.  
  1115. to.push([key, req_id]);
  1116. log_keys.push(key);
  1117. }
  1118. else {
  1119. hitlog[key].avail = avail;
  1120. }
  1121. }
  1122.  
  1123. var tvPromise = _getTVReviews( new_requesters );
  1124. var toPromise = _to(keys, log_keys, logged_in, to, timeis);
  1125.  
  1126. $.when( tvPromise, toPromise).done( function( v1, v2 ) {
  1127. _build(keys, log_keys, timeis);
  1128. }
  1129. );
  1130. }
  1131.  
  1132. let stopTV = false;
  1133. let tv_fail_rate = 0;
  1134. function _getTVReviews( reqlist ) {
  1135. var def = $.Deferred();
  1136. if ( reqlist.length > 0 && !config.disable_tv && !stopTV){
  1137. fetch(`https://view.turkerview.com/v1/requesters/?requester_ids=${reqlist.join()}`, {
  1138. method: 'GET',
  1139. cache: 'no-cache',
  1140. headers: ViewHeaders
  1141. }).then(response => {
  1142. if (!response.ok) throw response;
  1143.  
  1144. return response.json();
  1145. }).then(json => {
  1146.  
  1147. newreviews = json.requesters;
  1148. $.merge( requesters, reqlist );
  1149. turkerview = extend( turkerview, newreviews);
  1150. def.resolve(json);
  1151.  
  1152. }).catch(ex => {
  1153. tv_fail_rate++;
  1154. if (ex.statusText == 'invalidUserAuthKey') {
  1155. stopTV = true;
  1156. $('#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>`);
  1157. $('#TVErrorMessage').show();
  1158. }
  1159. else if (ex.statusText == 'dailyLimitExceeded' || ex.statusText == 'freeTrialExpired') {
  1160. stopTV = true;
  1161. $('#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>`);
  1162. $('#TVErrorMessage').show();
  1163. }
  1164.  
  1165. def.resolve( 'Empty');
  1166. });
  1167. }
  1168. else {
  1169. def.resolve( 'Empty');
  1170. }
  1171.  
  1172. return def.promise();
  1173. }
  1174.  
  1175. function _getTVHourly( reqid ) {
  1176. var tvHourly;
  1177. if( reqid in turkerview ) {
  1178. tvHourly = '$' + turkerview[reqid]['wages']['average']['wage'] + "/hr";
  1179. }
  1180. else {
  1181. tvHourly = '-';
  1182. }
  1183.  
  1184. return tvHourly;
  1185. }
  1186.  
  1187. function _to (keys, log_keys, logged_in, to, timeis) {
  1188. var def = $.Deferred();
  1189. var timeout = true;
  1190.  
  1191. var ids = [];
  1192.  
  1193. if (logged_in && to.length && config.to) {
  1194. for (var i = 0; i < to.length; i++) {
  1195. ids.push(to[i][1]);
  1196. }
  1197.  
  1198. $.ajax( {
  1199. url: 'https://turkopticon.ucsd.edu/api/multi-attrs.php?ids=' + ids,
  1200. success: function (data) {
  1201. try {
  1202. var to_data = JSON.parse(data);
  1203. }
  1204. catch(err) {
  1205. console.log ( "Fork off TO you're drunk" );
  1206. // malformed javascript, treat it lke TO timed out.
  1207. def.resolve( 'Done');
  1208. }
  1209.  
  1210. for (i = 0; i < to.length; i++) {
  1211. if (!to_data[to[i][1]].length && typeof to_data[to[i][1]].attrs != 'undefined') {
  1212. hitlog[to[i][0]].to = to_data[to[i][1]].attrs;
  1213. }
  1214. }
  1215.  
  1216. timeout = false;
  1217. },
  1218. timeout: 400
  1219. }).always(function () {
  1220. def.resolve( 'Done' );
  1221. });
  1222. }
  1223. else {
  1224. def.resolve( 'TO Off' );
  1225. }
  1226. return def.promise();
  1227.  
  1228. }
  1229.  
  1230. function _build (keys, log_keys, timeis) {
  1231. var hit_html = '', log_html = '';
  1232.  
  1233. for (var i = 0; i < keys.length; i++) {
  1234. var hit = hitlog[keys[i]], blocked = _check_block(hit), included = _check_include(hit), remove = false, classes, tvHourly, tvScore = false;
  1235.  
  1236. hit.tv = _getTVHourly( hit.reqid );
  1237.  
  1238. if ( hit.tv.substring(0,3) == 'N/A' || hit.tv.substring(0,3) == '<sp' ) {
  1239. tvScore = false;
  1240. }
  1241. else {
  1242. tvScore = true;
  1243. }
  1244.  
  1245. rowcolor = tvScore == true ? _color_tv(hit) : 'toNone';
  1246.  
  1247. classes = rowcolor;
  1248.  
  1249. if (Number(config.avail) > Number(hit.avail) || Number(config.mto) > Number(hit.to.pay)) {
  1250. classes += ' hidden';
  1251. remove = true;
  1252. }
  1253.  
  1254. if (blocked) {
  1255. classes += config.bl ? ' bl_hidden' : ' bl';
  1256. remove = true;
  1257. }
  1258.  
  1259. if (included) {
  1260. classes += ' il';
  1261. _included(included, hit);
  1262. }
  1263. else {
  1264. classes += config.nl ? ' nl_hidden' : ' nl';
  1265. }
  1266.  
  1267. hit_html +=
  1268. '<div class="cont" style="margin-bottom: 2px;">' +
  1269. '<div class="' + classes + ' " style="overflow: hidden; white-space: nowrap; margin-bottom: 2px;">' +
  1270.  
  1271. '<div style="float: left; width: calc(100% - 330px);">' +
  1272.  
  1273. '<span style="width: 25%; float: left; display:inline-block; overflow: hidden;">' +
  1274. '<button data-term="' + hit.reqid + '" data-name="' + hit.reqname + '" class="rt">R</button>' +
  1275. '<button id="'+ hit.groupid + '" data-term="' + hit.safetitle + '" data-name="' + hit.safetitle + '" class="rt">T</button>' +
  1276. '<button data-term="' + hit.reqid + '" data-name="' + hit.reqname + '" class="it">I</button>' +
  1277. '<a href="' + hit.reqlink + '">' + hit.reqname + '</a>' +
  1278. '</span>' +
  1279.  
  1280. '<span style="width: 75%; float: right; display:inline-block; overflow: hidden;">' +
  1281. '<button value="' + hit.key + '" class="vb">vB</button>' +
  1282. '<button value="' + hit.key + '" class="irc">IRC</button>' +
  1283. '<a href="' + hit.prevlink + '">' + hit.safetitle + '</a>' +
  1284. '</span>' +
  1285.  
  1286. '</div>' +
  1287.  
  1288. '<div style="float: right;">' +
  1289.  
  1290. '<span style="width: 60px; display:inline-block; text-align: center;">' +
  1291. hit.avail +
  1292. '</span>' +
  1293.  
  1294. '<span style="width: 60px; display:inline-block; text-align: center;">' +
  1295. '<a href="' + hit.pandlink + '">' + hit.reward + '</a>' +
  1296. '</span>' +
  1297.  
  1298. '<span class="to" style="width: 60px; display:inline-block; text-align: center;">' +
  1299. '<a href="' + hit.tvlink + '">' + hit.tv + '</a>' +
  1300. '</span>' +
  1301.  
  1302. '<span class="to" style="width: 60px; display:inline-block; text-align: center;">' +
  1303. '<a href="' + hit.tolink + '">' + hit.to.pay + '</a>' +
  1304. '</span>' +
  1305.  
  1306. '<span style="width: 60px; display:inline-block; text-align: center;">' +
  1307. '<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>' +
  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="once" class="pc">O</button>' +
  1309. '</span>' +
  1310.  
  1311. '</div>' +
  1312. '</div>' +
  1313. '</div>'
  1314. ;
  1315.  
  1316. if (remove) {
  1317. var index = log_keys.indexOf(keys[i]);
  1318.  
  1319. if (index > -1) {
  1320. log_keys.splice(index, 1);
  1321. }
  1322. }
  1323. }
  1324.  
  1325. if (log_keys.length) {
  1326. for (var j = 0; j < log_keys.length; j ++) {
  1327. var hit_log = hitlog[log_keys[j]], included_log = _check_include(hit_log), rowcolor, classes_log, tvHourly;
  1328.  
  1329. rowcolor = hit_log.tv != 'N/A' ? _color_tv(hit_log) : 'toNone';
  1330.  
  1331. classes_log = rowcolor;
  1332.  
  1333. if (included_log) {
  1334. classes_log += ' il';
  1335. }
  1336. else {
  1337. classes_log += config.nl ? ' nl_hidden' : ' nl';
  1338. }
  1339.  
  1340. var quals = hit_log.quals.split(';');
  1341. var qualif = '';
  1342.  
  1343. for (var k = 0; k < quals.length; k ++) {
  1344. if (quals[k] !== '') {
  1345. if( quals[k].indexOf('~!~') != -1 ) {
  1346. var temp = quals[k].split('~!~');
  1347. quals[k] = temp[0];
  1348. if (temp[1].indexOf('request') == -1 ) {
  1349. //Qual test
  1350. quals[k] += '<form action="' +temp[1] +'" method="get" style=" display:inline!important;"><button>Take Test</button></form>';
  1351. }
  1352. else {
  1353. //Request Qual
  1354. //quals[k] += '<form action="' +temp[1] +'" method="post"><button>Request</button></form>';
  1355. }
  1356. }
  1357. qualif += '<li style="padding: 2px;">' + quals[k] + '</li>';
  1358. }
  1359. }
  1360.  
  1361.  
  1362.  
  1363. log_html +=
  1364. '<div class="cont loggid_' + hit_log.groupid +' logreqid_' + hit_log.reqid + '" style="margin-bottom: 2px;">' +
  1365. '<div class="' + classes_log + '" style="overflow: hidden; white-space: nowrap;">' +
  1366.  
  1367. '<div style="float: left;">' +
  1368. '<span style="width: 80px; display:inline-block;">' +
  1369. '<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>' +
  1370. timeis[0] + ':' + timeis[1] + timeis[3] + '</span>' +
  1371. '</div>' +
  1372.  
  1373. '<div style="float: left; width: calc(100% - 410px);">' +
  1374.  
  1375. '<span style="width: 25%; float: left; display:inline-block; overflow: hidden;">' +
  1376. '<button data-term="' + hit_log.reqid + '" data-name="' + hit_log.reqname + '" class="rt">R</button>' +
  1377. '<button id="'+ hit_log.groupid + '" data-term="' + hit_log.safetitle + '" data-name="' + hit_log.safetitle + '" class="rt">T</button>' +
  1378. '<button data-term="' + hit_log.reqid + '" data-name="' + hit_log.reqname + '" class="it">I</button>' +
  1379. '<a href="' + hit_log.reqlink + '">' + hit_log.reqname + '</a>' +
  1380. '</span>' +
  1381.  
  1382. '<span style="width: 75%; float: right; display:inline-block; overflow: hidden;">' +
  1383. '<button value="' + hit_log.key + '" class="vb">vB</button>' +
  1384. '<button value="' + hit_log.key + '" class="irc">IRC</button>' +
  1385. '<a href="' + hit_log.prevlink + '">' + hit_log.safetitle + '</a>' +
  1386. '</span>' +
  1387.  
  1388. '</div>' +
  1389.  
  1390. '<div style="float: right;">' +
  1391.  
  1392. '<span style="width: 60px; display:inline-block; text-align: center;">' +
  1393. hit_log.avail +
  1394. '</span>' +
  1395.  
  1396. '<span style="width: 60px; display: inline-block; text-align: center;">' +
  1397. '<a href="' + hit_log.pandlink + '">' + hit_log.reward + '</a>' +
  1398. '</span>' +
  1399.  
  1400. '<span class="to" style="width: 60px; display:inline-block; text-align: center;">' +
  1401. '<a href="' + hit_log.tvlink + '">' + hit_log.tv + '</a>' +
  1402. '</span>' +
  1403.  
  1404.  
  1405. '<span class="to" style="width: 60px; display:inline-block; text-align: center;">' +
  1406. '<a href="' + hit_log.tolink + '">' + hit_log.to.pay + '</a>' +
  1407. '</span>' +
  1408.  
  1409. '<span style="width: 60px; display:inline-block; text-align: center;">' +
  1410. '<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>' +
  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="once" class="pc">O</button>' +
  1412. '</span>' +
  1413.  
  1414. '</div>' +
  1415. '</div>'+
  1416.  
  1417. '<div class="info ' + rowcolor + '" value="' + hit_log.key + '" style="overflow: hidden; display: none; font-size: 11px;">' +
  1418.  
  1419. '<div style="border-bottom: 1px solid #000000;"></div>' +
  1420.  
  1421. '<span style="width: 33%; float: left; display:inline-block; padding: 5px;">' +
  1422. '<span style="text-decoration: underline;">Description</span>' +
  1423. '<div style="padding: 2px;">' + hit_log.desc +'</div>' +
  1424. '<span style="text-decoration: underline;">Time</span>' +
  1425. '<div style="padding: 2px;">' + hit_log.time +'</div>' +
  1426. '</span>' +
  1427.  
  1428. '<span style="width: 33%; float: left; display:inline-block; padding: 5px;">' +
  1429. '<span style="text-decoration: underline;">Qualifications</span>' +
  1430. qualif +
  1431. '</span>' +
  1432.  
  1433. '<span style="width: calc(34% - 30px); float: right; display:inline-block; padding: 5px;">' +
  1434. '<span style="text-decoration: underline;">Turkopticon</span>' +
  1435. '<br>' +
  1436. '<span style="width: 70px; display:inline-block; padding: 2px;">Pay : ' + hit_log.to.pay +'</span>' +
  1437. '<span style="width: 70px; display:inline-block; padding: 2px;">Fair : ' + hit_log.to.fair +'</span>' +
  1438. '<br>' +
  1439. '<span style="width: 70px; display:inline-block; padding: 2px;">Comm : ' + hit_log.to.comm +'</span>' +
  1440. '<span style="width: 70px; display:inline-block; padding: 2px;">Fast : ' + hit_log.to.fast +'</span>' +
  1441. '</span>' +
  1442.  
  1443. '</div>' +
  1444. '</div>';
  1445.  
  1446. logged ++;
  1447. }
  1448. if (config.new) {
  1449. _sound('new');
  1450. }
  1451. }
  1452. $('#new_hits_').html(hit_html);
  1453. $('#log_hits_').prepend(log_html);
  1454.  
  1455. searches ++;
  1456. 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>';
  1457. var logged_hits_data = '<span style="float: right;">' + logged + '</span>';
  1458.  
  1459. $('#hits_data').html(hits_data);
  1460. $('#logged_hits_data').html(logged_hits_data);
  1461.  
  1462. if ($('#scan_button').text() === 'Stop') {
  1463. setTimeout(function () {
  1464. _scan();
  1465. }, $('#delay').val() * 1000);
  1466. }
  1467. }
  1468.  
  1469. function _sound (sound) {
  1470. if (sound === 'new') { $('#audio_' + config.newaudio) [0].play(); }
  1471. if (sound === 'include') { $('#audio_' + config.newaudio) [0].play(); }
  1472. if (sound === 'il') { $('#audio_' + $('#il_sound').val()) [0].play(); }
  1473. if (sound === 'il_edit') { $('#audio_' + $('#edit_il_sound').val()) [0].play(); }
  1474. }
  1475.  
  1476. function _check_block (hit) {
  1477. for (var key in blocklist) {
  1478. var obj = blocklist[key];
  1479. 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()) {
  1480. return obj;
  1481. }
  1482. }
  1483. }
  1484.  
  1485. function _check_include (hit) {
  1486. for (var key in includelist) {
  1487. var obj = includelist[key];
  1488. 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()) {
  1489. return obj;
  1490. }
  1491. }
  1492. }
  1493.  
  1494. function _included (obj, hit) {
  1495. var check = noti_delay.indexOf(hit.key) !== -1;
  1496. var pushcheck = push_delay.indexOf(hit.key) !== -1;
  1497.  
  1498. if (!check) {
  1499. noti_delay.unshift(hit.key);
  1500. setTimeout(function () { noti_delay.pop(); }, config.alert * 1000);
  1501. }
  1502. if (obj.noti_cb && !check) {
  1503. Notification.requestPermission();
  1504. var n = new Notification(hit.reqname + ' | ' + hit.reward, {
  1505. icon : 'http://nopurpose.org/stuff/avatars/Lj21396.gif',
  1506. body : hit.title,
  1507. });
  1508. setTimeout(n.close.bind(n), 5000);
  1509.  
  1510. n.onclick = function(e) {
  1511. e.preventDefault();
  1512. window.open(hit.prevlink, '_blank');
  1513. };
  1514.  
  1515. }
  1516. if (obj.sound_cb && !check) {
  1517. if ( !config.tts ) {
  1518. $('#audio_' + obj.sound)[0].play();
  1519. }
  1520. else {
  1521. //Console.log("BOOM, TTS");
  1522. slothbearsTTS(obj);
  1523. }
  1524. }
  1525. if (obj.push_cb && !pushcheck && config.pb) {
  1526. push_delay.unshift(hit.key);
  1527. setTimeout(function () { push_delay.pop(); }, 900000);
  1528.  
  1529. var push = {};
  1530.  
  1531. push['type'] = 'note';
  1532. push['title'] = 'HIT Finder';
  1533. push['body'] = '[' + hit.reqname + ']\n[' + hit.safetitle + ']\n[' + hit.reward + ']\n[' + hit.prevlink + ']';
  1534.  
  1535. $.ajax({
  1536. type : 'POST',
  1537. headers : {'Authorization': 'Bearer ' + config.push},
  1538. url : 'https://api.pushbullet.com/v2/pushes',
  1539. data : push
  1540. });
  1541.  
  1542. }
  1543. }
  1544.  
  1545. function _color_tv(hit) {
  1546. var tvHourly = hit.tv.replace(/\$/g, '').replace(/\/hr/g, '');
  1547.  
  1548. if (tvHourly == '-') return 'toNone';
  1549.  
  1550. if (config.theme == "light") {
  1551. if (tvHourly >= 10.00) { return 'tvHigh'; }
  1552. else if (tvHourly >= 7.25) { return 'tvFair'; }
  1553. else { return 'tvLow'; }
  1554. }
  1555. else {
  1556. if (tvHourly >= 10.00) { return 'toHigh'; }
  1557. else if (tvHourly >= 7.25) { return 'toAverage'; }
  1558. else { return 'toLow'; }
  1559.  
  1560. }
  1561. }
  1562.  
  1563. function _color_to (hit) {
  1564. var to = hit.to.pay;
  1565.  
  1566. if (config.theme == "light") {
  1567. if (to > 4) { return 'tvHigh'; }
  1568. else if (to > 2.5) { return 'tvFair'; }
  1569. else if (to > 0) { return 'tvLow'; }
  1570. else { return 'tvNone'; }
  1571. }
  1572. else {
  1573. if (to > 4) { return 'toHigh'; }
  1574. else if (to > 3) { return 'toGood'; }
  1575. else if (to > 2.25) { return 'toAverage'; }
  1576. else if (to > 1.25) { return 'toLow'; }
  1577. else if (to > 0) { return 'toPoor'; }
  1578. else { return 'toNone'; }
  1579.  
  1580. }
  1581. }
  1582.  
  1583. function _convert_seconds (seconds) {
  1584. seconds = Number(seconds);
  1585. var h = Math.floor(seconds / 3600);
  1586. var m = Math.floor(seconds % 3600 / 60);
  1587. var s = Math.floor(seconds % 3600 % 60);
  1588. var time = '';
  1589. if (h > 0) { time += h + ' hour(s) '; }
  1590. if (m > 0) { time += m + ' minutes(s) '; }
  1591. if (s > 0) { time += s + ' seconds(s)'; }
  1592. return time;
  1593. }
  1594.  
  1595. function _block (term, name, gid) {
  1596. $('#bl_term') .val(term);
  1597. $('#bl_name') .val(name);
  1598. $('#bl_gid').val(gid);
  1599. $('#bl') .show();
  1600. }
  1601.  
  1602. function _includerid( term, name, gid ) {
  1603. $('#il_term') .val(term);
  1604. $('#il_name') .val(name);
  1605. $('#il') .show();
  1606. }
  1607.  
  1608. function _panda(term, reqname, reqid, title, value, name, button) {
  1609. var hitData = {
  1610. hitTitle: title,
  1611. requesterName: reqname,
  1612. requesterId: reqid,
  1613. hitValue: value
  1614. }
  1615.  
  1616. var once = name == "panda" ? false : true;
  1617.  
  1618. PandaCrazy.online().then (
  1619. function(successResp) {
  1620. PandaCrazy.addJob( term, once, hitData );
  1621. button.addClass("clicked")
  1622. },
  1623. function(failedResp) {
  1624. 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");
  1625. }
  1626. );
  1627. //console.log ( running );
  1628. }
  1629.  
  1630.  
  1631. function _add_block (obj) {
  1632. if (!blocklist[obj.term]) {
  1633. blocklist[obj.term] = obj;
  1634. _init_lists();
  1635. }
  1636. }
  1637.  
  1638. function _edit_block (term) {
  1639. var obj = blocklist[term];
  1640. $('#edit_bl_term') .val(obj.term) .text(obj.term);
  1641. $('#edit_bl_name') .val(obj.name);
  1642. $('#edit_bl_save') .val(obj.term);
  1643. $('#edit_bl_delete') .val(obj.term);
  1644. $('#edit_bl') .show();
  1645. }
  1646.  
  1647. function _update_block (block) {
  1648. var obj = blocklist[block];
  1649. obj.name = $('#edit_bl_name').val();
  1650. _init_lists();
  1651. }
  1652.  
  1653. function _delete_block (block) {
  1654. delete blocklist[block];
  1655. _init_lists();
  1656. }
  1657.  
  1658. function _add_include (obj) {
  1659. if (!includelist[obj.term]) {
  1660. includelist[obj.term] = obj;
  1661. _init_lists();
  1662. }
  1663. }
  1664.  
  1665. function _edit_include (term) {
  1666. var obj = includelist[term];
  1667.  
  1668. $('#edit_il_term') .val(obj.term) .text(obj.term);
  1669. $('#edit_il_name') .val(obj.name);
  1670. $('#edit_il_sound') .val(obj.sound);
  1671.  
  1672. $('#edit_il_noti_cb') .prop('checked', obj.noti_cb);
  1673. $('#edit_il_sound_cb') .prop('checked', obj.sound_cb);
  1674. $('#edit_il_push_cb') .prop('checked', obj.push_cb);
  1675.  
  1676. $('#edit_il_save') .val(obj.term);
  1677. $('#edit_il_delete') .val(obj.term);
  1678.  
  1679. $('#edit_il').show();
  1680. }
  1681.  
  1682. function _update_include (term) {
  1683. var obj = includelist[term];
  1684. obj.name = $('#edit_il_name') .val().trim();
  1685. obj.sound = $('#edit_il_sound') .val().trim();
  1686. obj.noti_cb = $('#edit_il_noti_cb') .prop('checked');
  1687. obj.sound_cb = $('#edit_il_sound_cb') .prop('checked');
  1688. obj.push_cb = $('#edit_il_push_cb') .prop('checked');
  1689. _init_lists();
  1690. }
  1691.  
  1692. function _delete_include (term) {
  1693. delete includelist[term];
  1694. _init_lists();
  1695. }
  1696.  
  1697. function _hide_hit_list( hide ) {
  1698. if (hide) {
  1699. $("#hits_button").text('Show New HITs');
  1700. $('#hits_table').hide();
  1701. $('#hits_hidden').show();
  1702. config.h_hidden = '1';
  1703. }
  1704. else {
  1705. $("#hits_button").text('Hide New HITs');
  1706. $('#hits_table').show();
  1707. $('#hits_hidden').hide();
  1708. config.h_hidden = '0';
  1709. }
  1710.  
  1711. _save( 'showhide' );
  1712. }
  1713.  
  1714. function _hide_log_list( hide ) {
  1715. if (hide) {
  1716. $("#logg_button").text('Show Logged HITs');
  1717. $('#log_table').hide();
  1718. $('#log_hidden').show();
  1719. config.l_hidden = '1';
  1720. }
  1721. else {
  1722. $("#logg_button").text('Hide Logged HITs');
  1723. $('#log_table').show();
  1724. $('#log_hidden').hide();
  1725. config.l_hidden = '0';
  1726. }
  1727.  
  1728. _save( 'showhide' );
  1729. }
  1730.  
  1731. function _init_lists () {
  1732. var bl_sort = [], il_sort = [], bl_html = '', il_html = '';
  1733.  
  1734. for (var bl_key in blocklist) {
  1735. bl_sort.push([bl_key, blocklist[bl_key].name]);
  1736. }
  1737.  
  1738. bl_sort.sort(function (a, b) {
  1739. if (a[1].toLowerCase() < b[1].toLowerCase()) return -1;
  1740. if (a[1].toLowerCase() > b[1].toLowerCase()) return 1;
  1741. return 0;
  1742. });
  1743.  
  1744. for (var i = 0; i < bl_sort.length; i ++) {
  1745. var bl_obj = blocklist[bl_sort[i][0]];
  1746. bl_html += '<button class="blockit" style="margin: 2px;" value="' + bl_obj.term + '" title="' + bl_obj.term + '">' + bl_obj.name + '</button>';
  1747. }
  1748.  
  1749. for (var il_key in includelist) {
  1750. il_sort.push([il_key, includelist[il_key].name]);
  1751. }
  1752.  
  1753. il_sort.sort(function (a, b) {
  1754. if (a[1].toLowerCase() < b[1].toLowerCase()) return -1;
  1755. if (a[1].toLowerCase() > b[1].toLowerCase()) return 1;
  1756. return 0;
  1757. });
  1758.  
  1759. for (var j = 0; j < il_sort.length; j ++) {
  1760. var il_obj = includelist[il_sort[j][0]];
  1761. il_html += '<button class="includeit" style="margin: 2px;" value="' + il_obj.term + '" title="' + il_obj.term + '">' + il_obj.name + '</button>';
  1762. }
  1763.  
  1764. $('#bl_items') .html(bl_html);
  1765. $('#il_items') .html(il_html);
  1766. _save('init');
  1767. }
  1768.  
  1769. function _import_block () {
  1770. var import_bl = prompt(
  1771. 'Block List Import\n\n' +
  1772. 'You can import from HIT Finder or HIT Scraper.\n\n' +
  1773. 'This will not delete your current block list, only add to it.\n\n' +
  1774. 'Please enter your block list here.',
  1775. ''
  1776. );
  1777.  
  1778. if (import_bl) {
  1779. var json = _json_validator(import_bl);
  1780.  
  1781. if (json) {
  1782. var _bl_obj = JSON.parse(import_bl);
  1783. for (var key in _bl_obj) {
  1784. if (_bl_obj[key].hasOwnProperty('term') && _bl_obj[key].hasOwnProperty('name') && !_bl_obj[key].hasOwnProperty('sound')) {
  1785. if (!blocklist[key]) {
  1786. blocklist[key] = {
  1787. term : _bl_obj[key].term,
  1788. name : _bl_obj[key].name
  1789. };
  1790. }
  1791. }
  1792. else {
  1793. alert('An error occured while importing.\n\n Please check if you have a valid import and try again.');
  1794. break;
  1795. }
  1796. }
  1797. _init_lists();
  1798. }
  1799. else if (import_bl.match(/^/)) {
  1800. var _bl_arr = import_bl.trim().split('^');
  1801. for (var i = 0; i < _bl_arr.length; i ++) {
  1802. if (!blocklist[_bl_arr[i]]) {
  1803. blocklist[_bl_arr[i]] = {
  1804. term : _bl_arr[i],
  1805. name : _bl_arr[i]
  1806. };
  1807. }
  1808. }
  1809. _init_lists();
  1810. }
  1811. }
  1812. else {
  1813. alert('An error occured while importing.\n\n Please check if you have a valid import and try again.');
  1814. }
  1815. }
  1816.  
  1817. function _export_block () {
  1818. GM_setClipboard(localStorage.getItem('_finder_bl'));
  1819. alert('Your block list has been copied to your clipboard.');
  1820. }
  1821.  
  1822. function _import_include () {
  1823. var import_il = prompt(
  1824. 'Include List Import\n\n' +
  1825. 'You can import from HIT Finder or HIT Scraper.\n\n' +
  1826. 'This will not delete your current include list, only add to it.\n\n' +
  1827. 'Please enter your include list here.',
  1828. ''
  1829. );
  1830.  
  1831. if (import_il) {
  1832. var json = _json_validator(import_il);
  1833.  
  1834. if (json) {
  1835. var _il_obj = JSON.parse(import_il);
  1836.  
  1837. for (var key in _il_obj) {
  1838. if (_il_obj[key].hasOwnProperty('term') && _il_obj[key].hasOwnProperty('name') && _il_obj[key].hasOwnProperty('sound')) {
  1839. if (!includelist[key]) {
  1840. includelist[key] = {
  1841. term : _il_obj[key].term,
  1842. name : _il_obj[key].name,
  1843. sound : _il_obj[key].sound,
  1844. noti_cb : _il_obj[key].noti_cb,
  1845. sound_cb : _il_obj[key].sound_cb,
  1846. push_cb : _il_obj[key].push_cb
  1847. };
  1848. }
  1849. }
  1850. else {
  1851. alert('An error occured while importing.\n\n Please check that you have a valid import and try again.');
  1852. break;
  1853. }
  1854. }
  1855. _init_lists();
  1856. }
  1857. else if (import_il.match(/^/)) {
  1858. var _il_arr = import_il.split('^');
  1859.  
  1860. for (var i = 0; i < _il_arr.length; i ++) {
  1861. if (!includelist[_il_arr[i]]) {
  1862. includelist[_il_arr[i]] = {
  1863. term : _il_arr[i],
  1864. name : _il_arr[i],
  1865. sound : '1',
  1866. noti_cb : true,
  1867. sound_cb : true,
  1868. push_cb : false
  1869. };
  1870. }
  1871. }
  1872. _init_lists();
  1873. }
  1874. }
  1875. else {
  1876. alert('An error occured while importing.\n\n Please check that you have a valid import and try again.');
  1877. }
  1878. }
  1879.  
  1880. function _export_include () {
  1881. GM_setClipboard(localStorage.getItem('_finder_il'));
  1882. alert('Your include list has been copied to your clipboard.');
  1883. }
  1884.  
  1885. function _export_vb (key) {
  1886. var hit = hitlog[key];
  1887.  
  1888. var pay = hit.to.pay, _pay = '#B30000';
  1889. if (pay > 3.99) { _pay = '#00B300'; }
  1890. else if (pay > 2.99) { _pay = '#B3B300'; }
  1891. else if (pay > 1.99) { _pay = '#B37400'; }
  1892.  
  1893. var fair = hit.to.fair, _fair = '#B30000';
  1894. if (fair > 3.99) { _fair = '#00B300'; }
  1895. else if (fair > 2.99) { _fair = '#B3B300'; }
  1896. else if (fair > 1.99) { _fair = '#B37400'; }
  1897.  
  1898. var comm = hit.to.comm, _comm = '#B30000';
  1899. if (comm > 3.99) { _comm = '#00B300'; }
  1900. else if (comm > 2.99) { _comm = '#B3B300'; }
  1901. else if (comm > 1.99) { _comm = '#B37400'; }
  1902.  
  1903. var fast = hit.to.fast, _fast = '#B30000';
  1904. if (fast > 3.99) { _fast = '#00B300'; }
  1905. else if (fast > 2.99) { _fast = '#B3B300'; }
  1906. else if (fast > 1.99) { _fast = '#B37400'; }
  1907.  
  1908. var tv = hit.tv.replace(/\$/g, ''), _tvhourly = '#B30000';
  1909. if ( tv != 'N/A' ) {
  1910. if ( tv >= 10 ) { _tvhourly = '#00B300'; }
  1911. else if ( tv >= 7.25 ) { _tvhourly = '#B3B300'; }
  1912. tv = '$' + tv + '/hr';
  1913. }
  1914.  
  1915. var quals = hit.quals.split(';');
  1916. var qualif = '';
  1917.  
  1918. for (var k = 0; k < quals.length; k ++) {
  1919. if (quals[k] !== '') {
  1920. if( quals[k].indexOf('~!~') != -1 ) {
  1921. var temp = quals[k].split('~!~');
  1922. quals[k] = temp[0];
  1923. if (temp[1].indexOf('request') == -1 ) {
  1924. //Qual test
  1925. quals[k] += '[URL=' +temp[1] +']Take Test[/URL]';
  1926. }
  1927. else {
  1928. //Request Qual
  1929. //quals[k] += '<form action="' +temp[1] +'" method="post"><button>Request</button></form>';
  1930. }
  1931. }
  1932. qualif += quals[k] + ';';
  1933. }
  1934. }
  1935.  
  1936. var exportcode = '[table][tr][td]'+
  1937. '[b]Title:[/b] [URL=' + pandaurl + hit.prevlink + ']' + hit.safetitle + '[/URL] | [URL=' + pandaurl + hit.pandlink + ']PANDA[/URL]\n' +
  1938. '[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' +
  1939. '([URL='+hit.tolink+']TO[/URL]):'+
  1940. '[b] \[Pay: [COLOR=' + _pay + ']' + pay + '[/COLOR]\][/b]'+
  1941. '[b] \[Fair: [COLOR=' + _fair + ']' + fair + '[/COLOR]\][/b]' +
  1942. '[b] \[Comm: [COLOR=' + _comm +']' + comm + '[/COLOR]\][/b]' +
  1943. '[b] \[Fast: [COLOR=' + _fast + ']' + fast + '[/COLOR]\][/b]\n' +
  1944. '[b]Description:[/b] ' + hit.desc + '\n' +
  1945. '[b]Time:[/b] ' + hit.time + '\n' +
  1946. '[b]HITs Available:[/b] ' + hit.avail + '\n' +
  1947. '[b]Reward:[/b] [COLOR=green][b] ' + hit.reward + '[/b][/COLOR]\n' +
  1948. '[b]Qualifications:[/b] ' + qualif + '\n' +
  1949. '[/td][/tr][/table]';
  1950.  
  1951. GM_setClipboard(exportcode);
  1952. alert('Forum export has been copied to your clipboard.');
  1953. }
  1954.  
  1955. function _export_irc (key) {
  1956. var hit = hitlog[key];
  1957.  
  1958. $.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) {
  1959. var urls = data.split(';'),
  1960. preview = urls[0],
  1961. panda = urls[1];
  1962.  
  1963. var exportcode = 'Req: ' + hit.reqname + ' ■ Title: ' + hit.safetitle + ' ■ Reward: ' + hit.reward;
  1964. exportcode += preview !== panda ? ' ■ Prev: ' + preview + ' ■ PandA: '+ panda : ' ■ Search: ' + preview;
  1965. exportcode += ' ■ TO: (Pay: ' + hit.to.pay + ') (Fair: ' + hit.to.fair + ') (Comm: ' + hit.to.comm + ') (Fast: ' + hit.to.fast + ')';
  1966.  
  1967. GM_setClipboard(exportcode);
  1968. alert('IRC export has been copied to your clipboard.');
  1969.  
  1970. }).fail(function () {
  1971. alert('Failed to shorten links.');
  1972. });
  1973. }
  1974.  
  1975. function _json_validator (data) {
  1976. try {
  1977. JSON.parse(data);
  1978. return true;
  1979. }
  1980. catch (e) {
  1981. return false;
  1982. }
  1983. }
  1984.  
  1985. function _save (type) {
  1986. if (type !== 'init' && type !== 'custom') {
  1987. config.delay = $('#delay') .val();
  1988. config.rew = $('#min_rew') .val();
  1989. config.avail = $('#min_avail') .val();
  1990. config.mto = $('#min_to') .val();
  1991. config.alert = $('#alert_delay') .val();
  1992. config.type = $('#type') .val();
  1993. config.size = $('#size') .val();
  1994. config.newaudio = $('#new_audio') .val();
  1995. config.theme = $('#adv_theme') .val();
  1996. config.to_theme = $('#to_theme') .val();
  1997.  
  1998. config.new = $('#new_sound') .prop('checked');
  1999. config.pb = $('#pb') .prop('checked');
  2000. config.tts = $('#tts') .prop('checked');
  2001. config.to = $('#to') .prop('checked');
  2002. config.qual = $('#qual') .prop('checked');
  2003. config.nl = $('#nl_hide') .prop('checked');
  2004. config.bl = $('#bl_hide') .prop('checked');
  2005. config.m = $('#m_hide') .prop('checked');
  2006. console.log($('#push').val());
  2007.  
  2008. }
  2009. if (type === 'custom' && $('#adv_theme').val() === 'custom') {
  2010. config.custom = {
  2011. main : $('#theme_main') .val(),
  2012. primary : $('#theme_primary') .val(),
  2013. secondary : $('#theme_secondary') .val(),
  2014. text : $('#theme_text') .val(),
  2015. link : $('#theme_link') .val(),
  2016. visited : $('#theme_visited') .val(),
  2017. prop : false
  2018. };
  2019. themes.custom = config.custom;
  2020. }
  2021. config.push = $('#push').val();
  2022. config.tv_api_key = $('#tv_api_key').val();
  2023.  
  2024. localStorage.setItem('_finder', JSON.stringify(config));
  2025. localStorage.setItem('_finder_bl', JSON.stringify(blocklist));
  2026. localStorage.setItem('_finder_il', JSON.stringify(includelist));
  2027.  
  2028. if (config.nl) { $('.nl').toggleClass('nl nl_hidden'); }
  2029. else { $('.nl_hidden').toggleClass('nl nl_hidden'); }
  2030.  
  2031. if (config.bl) { $('.bl').toggleClass('bl bl_hidden'); }
  2032. else { $('.bl_hidden').toggleClass('bl bl_hidden'); }
  2033.  
  2034. if (config.m) { $('.m').toggleClass('m m_hidden'); }
  2035. else { $('.m_hidden').toggleClass('m m_hidden'); }
  2036. }
  2037.  
  2038. function _theme () {
  2039. var theme = themes[config.theme];
  2040.  
  2041. $('#theme_main') .val(theme.main) .prop('disabled', theme.prop);
  2042. $('#theme_primary') .val(theme.primary) .prop('disabled', theme.prop);
  2043. $('#theme_secondary') .val(theme.secondary) .prop('disabled', theme.prop);
  2044. $('#theme_text') .val(theme.text) .prop('disabled', theme.prop);
  2045. $('#theme_link') .val(theme.link) .prop('disabled', theme.prop);
  2046. $('#theme_visited') .val(theme.visited) .prop('disabled', theme.prop);
  2047. _write_theme();
  2048. }
  2049.  
  2050. function _write_theme () {
  2051. var css = _to_theme(), theme = themes[config.theme];
  2052.  
  2053. css +=
  2054. 'html {color: #' + theme.text + '; background-color: #' + theme.main + '; line-height: 1.5; font-family: "Roboto", sans-serif; font-size: 15px; font-weight: normal;}' +
  2055. 'body {margin: 0px;}' +
  2056. '#menubar { background-color: #' + theme.menu + '; margin: 0px; padding: 3px; height:30px; color: #' + theme.menutext + ' }' +
  2057. '#latest_hits { margin: 5px; }' +
  2058. '#logged_hits { margin: 5px; }' +
  2059. '#config { background-color: #' + theme.primary + '; border: 2px #' + theme.text + ' solid; padding: 2px;}' +
  2060.  
  2061. '#bl_items, #il_items {background-color: #'+theme.main+'; height: calc(100% - 64px); overflow-y: scroll;}' +
  2062. '#bl_div, #il_div {background-color: #'+theme.primary+'; border: 2px solid #'+theme.secondary+';}' +
  2063.  
  2064. '.add {background-color: #'+theme.primary+'; border: 2px solid #'+theme.secondary+';}' +
  2065.  
  2066. '.bl {border: 2px solid #FF0000;}' +
  2067. '.il {border: 2px solid #009900;}' +
  2068. '.hidden, .nl_hidden, .bl_hidden, .m_hidden {display: none;}' +
  2069. 'button:focus {outline: none !important;}';
  2070.  
  2071. if (config.theme == 'light' ) {
  2072. css +=
  2073. '.tvHigh {background-color: rgba(0,128,0,0.3); }' +
  2074. '.tvFair {background-color: rgba(255,165, 0, 0.3);}' +
  2075. '.tvLow {background-color: rgba(255,0,0,0.3); }' +
  2076. '.tvNone {background-color: rgba(128,128,128, 0.3); }'
  2077. }
  2078.  
  2079. $('#css').html(css);
  2080. }
  2081.  
  2082. function _to_theme () {
  2083. var to, theme = themes[config.theme], color = '';
  2084. console.log(config.to_theme);
  2085. if (config.theme === 'default') {
  2086. color = 'd9d9d9';
  2087. }
  2088. else {
  2089. color = '262626';
  2090. }
  2091.  
  2092. switch (config.to_theme) {
  2093. case '1':
  2094. to =
  2095. 'td {font-weight: bold;}' +
  2096. '.cont, .hit, .details {color: #000000;}' +
  2097. '.toHigh {background-color: #33cc59;}' +
  2098. '.toGood {background-color: #a6cc33;}' +
  2099. '.toAverage {background-color: #cccc33;}' +
  2100. '.toLow {background-color: #cca633;}' +
  2101. '.toPoor {background-color: #cc3333;}' +
  2102. '.toNone {background-color: #cccccc;}' +
  2103. '.rt, .it, .pc {width: 20px; height: 20px; background-color: transparent; margin: 1px; border: 1px solid #000000; font-size: 80%; padding: 1px;}' +
  2104. '.vb, .irc {width: 25px; height: 20px; background-color: transparent; margin: 1px; border: 1px solid #000000; font-size: 80%; padding: 1px;}' +
  2105. '.clicked {background-color:grey;}';
  2106. ;
  2107. return to;
  2108. case '2':
  2109. to =
  2110. 'a {color: #'+theme.link+';}' +
  2111. 'a:visited {color: #'+theme.visited+';}' +
  2112. 'tbody td {color: #'+theme.text+';}' +
  2113. '.to a {color: #000000;}' +
  2114.  
  2115. '.cont, .details {color: #'+theme.text+';}' +
  2116. '.toHigh {background-color: #'+color+';}' +
  2117. '.toGood {background-color: #'+color+';}' +
  2118. '.toAverage {background-color: #'+color+';}' +
  2119. '.toLow {background-color: #'+color+';}' +
  2120. '.toPoor {background-color: #'+color+';}' +
  2121. '.toNone {background-color: #'+color+';}' +
  2122.  
  2123. '.toHigh .to {background-color: #33cc59;}' +
  2124. '.toGood .to {background-color: #a6cc33;}' +
  2125. '.toAverage .to {background-color: #cccc33;}' +
  2126. '.toLow .to {background-color: #cca633;}' +
  2127. '.toPoor .to {background-color: #cc3333;}' +
  2128. '.toNone .to {background-color: #cccccc;}' +
  2129. '.rt, .pc {width: 20px; height: 20px; color: #'+theme.text+'; background-color: transparent; margin: 1px; border: 1px solid #'+theme.text+'; font-size: 80%; padding: 1px;}' +
  2130. '.vb, .irc {width: 25px; height: 20px; color: #'+theme.text+'; background-color: transparent; margin: 1px; border: 1px solid #'+theme.text+'; font-size: 80%; padding: 1px;}' +
  2131. '.clicked {background-color:grey;}';
  2132. ;
  2133. return to;
  2134. case '3':
  2135. to =
  2136. 'a {color: #'+theme.link+';}' +
  2137. 'a:visited {color: #'+theme.visited+';}' +
  2138. 'tbody td {color: #'+theme.text+';}' +
  2139.  
  2140. '.cont, .details {color: #'+theme.text+';}' +
  2141. '.toHigh {background-color: #'+color+';}' +
  2142. '.toGood {background-color: #'+color+';}' +
  2143. '.toAverage {background-color: #'+color+';}' +
  2144. '.toLow {background-color: #'+color+';}' +
  2145. '.toPoor {background-color: #'+color+';}' +
  2146. '.toNone {background-color: #'+color+';}' +
  2147.  
  2148. '.toHigh .to a {color: #33cc59;}' +
  2149. '.toGood .to a {color: #a6cc33;}' +
  2150. '.toAverage .to a {color: #cccc33;}' +
  2151. '.toLow .to a {color: #cca633;}' +
  2152. '.toPoor .to a {color: #cc3333;}' +
  2153. '.toNone .to a {color: #cccccc;}' +
  2154. '.rt, .pc {width: 20px; height: 20px; color: #'+theme.text+'; background-color: transparent; margin: 1px; border: 1px solid #'+theme.text+'; font-size: 80%; padding: 1px;}' +
  2155. '.vb, .irc {width: 25px; height: 20px; color: #'+theme.text+'; background-color: transparent; margin: 1px; border: 1px solid #'+theme.text+'; font-size: 80%; padding: 1px;}' +
  2156. '.clicked {background-color:grey;}';
  2157. ;
  2158. return to;
  2159. }
  2160. }
  2161.  
  2162. $('#type option[value="' + config.type + '"]') .prop('selected', true);
  2163. $('#size option[value="' + config.size + '"]') .prop('selected', true);
  2164. $('#new_audio option[value="' + config.newaudio + '"]') .prop('selected', true);
  2165. $('#adv_theme option[value="' + config.theme + '"]') .prop('selected', true);
  2166. $('#to_theme option[value="' + config.to_theme + '"]') .prop('selected', true);
  2167.  
  2168. _theme();
  2169. _init_lists();
  2170. _hide_hit_list( config.h_hidden == '1' ? true : false );
  2171. _hide_log_list( config.l_hidden == '1' ? true : false );

QingJ © 2025

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