Advertisement
Guest User

Untitled

a guest
Jul 29th, 2015
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        DCI New HIT Monitor for mturk (with links) (mralaska version)
  3. // @namespace   mralaska
  4. // @description Monitors for new HITs from requesters on your list
  5. // @include     *mturk.com/*HITMONITOR*
  6. // @include     https://www.mturk.com/mturk/searchbar?selectedSearchType=hitgroups&qualifiedFor=on&sortType=LastUpdatedTime%3A1
  7. // @version     9000.1
  8. // @grant       none
  9. // ==/UserScript==
  10.  
  11. /*********************************
  12. * This script is based on the DCI script version 9000 from <a href="http://userscripts.org/scripts/show/399555">http://userscripts.org/scripts/show/399555</a>
  13. * The major difference is that this version selects an option by default to create a link page instead of freezing the tab using an alert
  14. * Query lists can be copied and pasted to and from the DCI script
  15. * LINK mode (default) opens a new page and adds links and makes a noise every new match
  16.   * best when multitasking or if you have a lot of search queries and wish to ignore some alerts
  17.   * the script will continue adding links to the capture page but will not force immediate action
  18.   * you can increase SLEEP_DELAY to give you time to investigate from the search page but default is to slow it down only briefly
  19.   * Chrome users especially will find more use for the LINK mode (FireFox alert is less intrusive)
  20. * ALERT mode will make a noise and then freeze the tab until you clear the alert.
  21.   * best when working this script solely, or have it running in another browser.
  22.   * when an alert pops you stop what you are doing and visit the link from the frozen page
  23.   * it is best to freeze the page using SLEEP_DELAY for a long enough time to investigate the link
  24. *
  25. * To activate this script visit or bookmark one of the links below.
  26. https://www.mturk.com/mturk/searchbar?selectedSearchType=hitgroups&qualifiedFor=on&sortType=LastUpdatedTime%3A1
  27. https://www.mturk.com/mturk/findhits?match=true&qualifiedFor=on&sortType=LastUpdatedTime%3A1&queryflag=HITMONITOR
  28. * You can change the search parameters on Mturk as long as HITMONITOR is added as a query -> &queryflag=HITMONITOR (see link above)
  29. *** How to eliminate YOU HAVE EXCEEDED THE MAXIMUM ALLOWED PAGE REQUEST RATE FOR THIS WEBSITE.
  30.     * PRO TIP: By using this script with the second link or any page using the method: &queryflag=HITMONITOR
  31.     * AND ALSO modifying all other mturk scripts to EXCLUDE the HITMONITOR search page
  32.         example: insert this line into each script header after the includes: // @exclude  *mturk.com/*HITMONITOR*
  33.     * AND ALSO (if applicable) disabling or using Page Monitor type programs on a VERY limited basis
  34.     * will allow you to operate very fast without activating this error
  35.     * (tested <0.01 second refresh with 500 queries nearly continuous for a week with no errors)
  36.     * DISCLAIMER: If you continue to search even by hand on pages with scripts enabled it may still trigger the error
  37.         (some scripts are more likely than others depending on how often they hit Amazon for data)
  38. *********************************/
  39.  
  40. //===[Settings]===\\ //==[To change alert sound just change the url to use whatever sound you want]==\\
  41. var SOUND_BYTE  = "http://static1.grsites.com/archive/sounds/musical/musical002.wav"; //==[This is the path to the mp3 used for the alert]==\\
  42. var RELOAD_TIME = '5';     //==[default 5 seconds - This is the number of seconds between page reloads - 0 will disable reloading (use 0.xx if 1 second is too long)]
  43. var SLEEP_TIME  = '15';   //==[default 15 seconds - (300 suggested (5 minutes) for alert mode) Number of seconds HIT monitor sleeps after the alert is clicked]  
  44. var SOUND_DELAY = '2';     //==[Required for Alert mode - Number of seconds between your sound alert and popup alert - ignored for link mode.]
  45. //You may need to increase the delay if the popup is frequently cutting off your sound before it can play
  46. var ALERT_MODE  = "FALSE";  //==[Method of notification TRUE or FALSE - if FALSE you can set SOUND_DELAY to '0']
  47. var LINK_MODE   = "TRUE"; //==[Generates a page with search link (does not affect SOUND_DELAY)]
  48. var POPUP_WIDTH = '650'; // link page width in pixels
  49. var POPUP_HEIGHT= '600'; // link page height in pixels
  50. //===[END Settings]===\\
  51. // Customize your search strings (below)
  52.  
  53. var needles = new Array(
  54. //==[Below is your requester list. Add or remove whatever you like]==\\
  55. //==[If you make a typo and break it, you'll know, because it won't reload]==\\
  56. // Proper format is QUOTE-STRING-QUOTE-COMMA (adding white space before or after queries does not matter)
  57.  
  58. "TaskRabbit", // you can use double hash marks to insert comments AFTER the code (anything after will be ignored)
  59. "Set Master", // good for building numbers - post almost every day
  60. "Acme Data Collection",
  61. "A3A1AJ4RPLTOLY", // requester ID for acme
  62. "agent agent",
  63. //"AJ Ghergich",
  64. "Andy K",
  65. "BICC",
  66. "Bluejay Labs",
  67. "carnegie mellon social computing group",
  68. "Christos Koritos",    
  69. "Dan Shaffer",
  70. "David Mease",
  71. "Funicular Heavy Industries",
  72. "Gaddy",    
  73.     //You can search by user ID but the alert will not identify the requester:
  74. "A17KLBWRZ7M97G", //will show alerts for D. M. [A17KLBWRZ7M97G]
  75.     //You can also search by query string but it must have an exact match in the HIT headline
  76. "Urgent Priority", //will show alerts for all hit titles that contain the phrase, Urgent Priority
  77.     //You can arrange query strings by row if you wish as long as you continue to follow the correct format.
  78. "JASON W GULLIFER",
  79. "Jeff Foster",
  80. "jesse egbert",
  81. "Jonathan Frates",
  82. "Leonid",
  83. "nabirds",
  84. "nlp",
  85. "OCMP",
  86. "OhGodScience",
  87. "Parisa",
  88. "Personagraph",
  89. "PickFu",
  90. "Procore",
  91. "Project Endor",
  92. "Project Gandolph",
  93. "Sergey Schmidt",
  94. "SIRIUSProject",
  95. "Spreecast",
  96. "Stiglitz",
  97. "Tag Requester",
  98. "Two Lakes",
  99. "User Manual",
  100. "vaplab",
  101. "Vesterman",
  102. "UW Social",
  103. "Wharton",
  104. "World Vision",
  105. "Heather Walters",
  106. "John Roberts", // some decent batches, some are a grind
  107. "Get Number of Search Results", // from john roberts - ok for numbers - requires 1000 min & 95% approved
  108. "NoblisCV", // great penny batches for numbers - only requires approval rate over 50%
  109. "x8 data",
  110.  
  111. //==[Begin user modified list]==\\
  112. //YO READ THE STUFF HERE
  113. "peter burke", //anything followed by two slashes is a comment, and will not affect the code at all
  114. //"pi search", //this IS NOT being looked for by HIT monitor. take off the slash and save the file so it starts to look for it again
  115. "simple title for a piece of adult content" //the last member of the list cannot have a comma at the end
  116.  
  117. // if the page doesn't reload chances are you have a misplaced comma
  118.  
  119. //==[DO NOT to put a comma after the LAST ITEM on your list]==\\    
  120. );
  121.  
  122. var haystack = document.body.innerHTML;
  123. var my_pattern, my_matches, found = "", foundlink="";
  124. for (var i=0; i<needles.length; i++){
  125.   my_pattern = eval("/" + needles[i] + "/gi");
  126.   my_matches = haystack.match(my_pattern);
  127.   if (my_matches){
  128.            // for Alert
  129.     found += "\n" + my_matches.length + " found for " + needles[i];
  130.           // for link page option
  131.     searchString = needles[i].replace(/ /g,"+");
  132.     foundlink += "\n \(Total queries="+ needles.length +"\) " + my_matches.length;
  133.     foundlink += " matches for <a target=_blank href=https://www.mturk.com/mturk/searchbar?selectedSearchType=hitgroups&searchWords=";
  134.     foundlink += searchString +">"+ needles[i] +"</a>";
  135.     foundlink += " \(alt srch if <a target=_blank href=https://www.mturk.com/mturk/searchbar?selectedSearchType=hitgroups&requesterId=";
  136.     foundlink += searchString +">ID</a> provided\) ";
  137.     foundlink += time()+"<br>";
  138.   }
  139. }
  140.  
  141. if (found != "") {
  142.     var mCoinSound = new Audio(SOUND_BYTE);
  143.     mCoinSound.play();
  144.     if (ALERT_MODE == "TRUE") {
  145.        setTimeout(function(){alert("Alert" + found)}, (SOUND_DELAY*1000));
  146.     }
  147.     if (LINK_MODE == "TRUE") {
  148.         LinkAlert(foundlink);
  149.     }
  150.     if (SLEEP_TIME > 0) setTimeout("location.reload(true);",SLEEP_TIME*1000);
  151. } else {
  152.     if (RELOAD_TIME > 0) setTimeout("location.reload(true);",RELOAD_TIME*1000);    
  153. }
  154.  
  155. function time(){
  156.     var d = new Date(),
  157.     minutes = d.getMinutes().toString().length == 1 ? '0'+d.getMinutes() : d.getMinutes(),
  158.     hours = d.getHours(), //.toString().length == 1 ? '0'+d.getHours() : d.getHours(),
  159.     hours = hours > 12 ? hours - 12 : hours,
  160.     hours = hours < 1  ? hours + 12 : hours,
  161.     seconds = d.getSeconds().toString().length == 1 ? '0'+d.getSeconds() : d.getSeconds(),
  162.     ampm = d.getHours() >= 12 ? 'pm' : 'am',
  163.     //months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],
  164.     days = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];
  165.     //return days[d.getDay()]+' '+months[d.getMonth()]+' '+d.getDate()+' '+d.getFullYear()+' '+hours+':'+minutes+":"+seconds+" "+ampm;
  166.     return days[d.getDay()]+' '+(d.getMonth()+1)+'/'+d.getDate()+'/'+d.getFullYear()+' '+hours+':'+minutes+':'+seconds+' '+ampm;
  167. }
  168. function LinkAlert(foundlink){
  169.     var LinkWindow = window.open("","MturkHitSearch","width="+POPUP_WIDTH+",height="+POPUP_HEIGHT);
  170.     LinkWindow.document.body.innerHTML += (foundlink);
  171.     checkTitle(LinkWindow,"Mturk Search Results");
  172.     LinkWindow.document.close();
  173. }
  174. function checkTitle(win,tit) {
  175.     if(win.document) { // if loaded
  176.         win.document.title = tit; // set title
  177.     } else { // if not loaded yet
  178.         setTimeout(check, 10); // check in another 10ms
  179.     }
  180. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement