Crowdsource Workstation Monitor

Monitors your CrowdSource work center for favorite tasks

目前为 2015-02-16 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Crowdsource Workstation Monitor
  3. // @namespace mralaska
  4. // @description Monitors your CrowdSource work center for favorite tasks
  5. // @include https://work.crowdsource.com/*
  6. // @exclude https://work.crowdsource.com/login*
  7. // @exclude https://work.crowdsource.com/amt/*
  8. // @exclude https://work.crowdsource.com/history*
  9. // @exclude https://work.crowdsource.com/feedback*
  10. // @exclude https://work.crowdsource.com/profile/*
  11. // @version 0.1
  12. // @grant none
  13. // ==/UserScript==
  14.  
  15. /*********************************
  16. * This script is still experimental. It was adapted by modifying the DCI Hit Monitor script.
  17. * ALERT mode (default) is activated by setting SOUND_DELAY with any positive number greater than zero (2 should be plenty unless speed is limited)
  18. * best when working this script solely, or have it running in another browser.
  19. * when an alert pops you stop what you are doing and visit the link from the frozen page
  20. * it is best to freeze the page using SLEEP_DELAY for a long enough time to investigate the linke
  21. * LINK mode can be activated by setting SOUND_DELAY to 0 (sound delay is not needed in link mode)
  22. * best when multitasking or if you have a lot of search queries and wish to ignore some alerts
  23. * the script will continue adding links to the capture page but will not force immediate action
  24. * you can still set SLEEP_DELAY to give you time to investigate from the search page or set it similar to RELOAD_TIME to keep searching
  25. *
  26. * To activate this script simply log into your account at https://work.crowdsource.com
  27. * This script will refresh the page at your specified interval using seach queries reflecting your favorite tasks
  28. *********************************/
  29. //===[Settings]===\\
  30. var RELOAD_TIME = '15'; //==[This is the number of seconds between page reloads. Set to '0' to disable script reloading]
  31. // * 5 by default - any number above 0 but I have had crowdsource crash on me going too fast. 0 will disable reloading.
  32. var SLEEP_DELAY = '600'; //==[This is the number of seconds HIT monitor waits after a notification]
  33. // * 15 by default - setting SLEEP_DELAY to 300 will give you five minutes - you can refresh the page manually to start it again sooner
  34. var SOUND_DELAY = '2'; //==[This is the number of seconds the alert waits to give the sound time to load]
  35. // * prevents the alert from snipping the sound
  36. // * SOUND_DELAY ALSO SETS ALERT/LINK MODE:
  37. // * Set to 0 for LINK WINDOW MODE (delay not required for link window)
  38. // * set to any number above 0 for ALERT MODE (try 2 for normal speed)
  39. var POPUP_WIDTH = '600'; // link page width in pixels
  40. var POPUP_HEIGHT= '650'; // link page height in pixels
  41. var SOUND_BYTE = "http://static1.grsites.com/archive/sounds/musical/musical002.wav";
  42. //==[Change the SOUND_BYTE URL to use whatever sound you want]==\\
  43. //
  44. // Customize your search strings (below)
  45.  
  46. var needles = new Array(
  47. //==[Below is your requester list. Add or remove whatever you like]==\\
  48. //==[If you make a typo and break it, you'll know, because it won't reload]==\\
  49. // Proper format is QUOTE-STRING-QUOTE-COMMA (adding white space before or after queries does not matter)
  50.  
  51. // regular searches can use either single quote or double quote if not encapsulating a another quote mark.
  52. // Note that the first entry uses single quotes to include a double quote as part of the search
  53. // Using the double quote as part of the search is copied from the source (inspect element) of the CrowdSource page
  54. 'Search: Keywords on Google.com"', // will not alert on similar searches such as "Search: Keywords on Google.com and ..."
  55. "Keywords on Google.ng",
  56. "Keywords on Google.it",
  57. "Keywords on Google.co.uk",
  58. "Keywords on Google.com.sg",
  59. 'Ranking of a Url"', //This query also uses the text and double quote as copied from the CrowdSource page via "Inspect Element"
  60. "Ranking of a Url on Google.co.uk",
  61. "Ranking of a Url on Google.it",
  62. "Ranking of a Url on Google.ng"
  63.  
  64.  
  65. //==[Be careful NOT to put a comma after the LAST item on your list]==\\
  66. );
  67.  
  68. var haystack = document.body.innerHTML;
  69. var my_pattern, my_matches, found = "", foundalert = "";
  70. for (var i=0; i<needles.length; i++){
  71. my_pattern = eval("/" + needles[i] + "/gi");
  72. my_matches = haystack.match(my_pattern);
  73. if (my_matches){
  74. // for alert option
  75. foundalert += "\n" + my_matches.length + " found for " + needles[i];
  76. // for link page option
  77. searchString = needles[i].replace(/ /g,"+");
  78. found += "\n \(Total queries="+ needles.length +"\) " + my_matches.length;
  79. found += " matches for <a target=_blank href=https://www.mturk.com/mturk/searchbar?selectedSearchType=hitgroups&searchWords=";
  80. found += searchString +">"+ needles[i] +"</a>";
  81. found += " \(All hits by <a target=_blank href=https://www.mturk.com/mturk/searchbar?selectedSearchType=hitgroups&requesterId=";
  82. found += "A2SUM2D7EOAK1T>CrowdSource</a>\)<br>";
  83. }
  84. }
  85.  
  86. // If matches were found, send to an alert window with links to open searches
  87. if (found != "") {
  88. mCoinSound = new Audio(SOUND_BYTE);
  89. mCoinSound.play();
  90. if (SOUND_DELAY > 0) {
  91. // create alert and freeze tab
  92. setTimeout(function(){alert("Alert" + foundalert)}, SOUND_DELAY*1000);
  93. } else {
  94. // call function to create link page
  95. CreateAlert(found);
  96. }
  97. var StRefTime = SLEEP_DELAY;
  98. if (StRefTime > 0) setTimeout("location.reload(true);",StRefTime*1000);
  99. } else {
  100. var StRefTime = RELOAD_TIME;
  101. if (StRefTime > 0) setTimeout("location.reload(true);",StRefTime*1000);
  102. }
  103.  
  104. function CreateAlert(found){
  105. var LinkWindow = window.open("","CrowdSourceTasks","width="+POPUP_WIDTH+",height="+POPUP_HEIGHT);
  106. LinkWindow.document.body.innerHTML += (found);
  107. checkTitle(LinkWindow,"CrowdSource Search Results");
  108. LinkWindow.document.close();
  109. }
  110. function checkTitle(win,tit) {
  111. if(win.document) { // if loaded
  112. win.document.title = tit; // set title
  113. } else { // if not loaded yet
  114. setTimeout(check, 10); // check in another 10ms
  115. }
  116. }