AMT Searchbar

A Simple Mturk/Greasyfork/MTG search bar

  1. // ==UserScript==
  2. // @name AMT Searchbar
  3. // @namespace http://i.imgur.com/UNrCfvr.gif
  4. // @version 1.01
  5. // @description A Simple Mturk/Greasyfork/MTG search bar
  6. // @author Ethraiel
  7. // @contributor R.Daneel
  8. // @include *.mturkgrind.*
  9. // @include *.reddit.*
  10. // @include *.mturk.*
  11. // @require https://code.jquery.com/jquery-3.0.0-alpha1.min.js
  12. // ==/UserScript==
  13. //press backtick [`] to toggle the searchbar
  14. var theme_no = "0";//***0******1*******2******3*******4************5*******the names of the themes are below their respective numbers because im lazy :P
  15. var theme_name = ["Custom","Dark","Frost","Mint","Ole'Greg","Dark_plain","",""];//set the theme_no to set the theme...
  16. var search = "";//This is a default value for the searchbar, i.e. "survey" will make "survey" appear when you bring up the searchbar.
  17. var minpay = ("0.00");//Same as above, but for the minimum pay field.
  18. var qual = "false";//Set to "true" to automatically check the box "Qualled For" everytime you bring up the searchbar. *note any string other than "true" will return false.
  19. var master = "false";//Same as above but for "Masters Only"
  20.  
  21. if ( localStorage.getItem("AMTSBtheme") ) {
  22. theme_no = localStorage.getItem("AMTSBtheme");
  23. }
  24.  
  25. if (theme_no == "0"){
  26. var panel_bg = "white";//CUSTOM********[theme_no = 0]*************CUSTOM
  27. var text_color = "black";//sets the text color*note the above var sets the panel background color
  28. var border_color = "grey";//the color of all the borders
  29. var text_bg = "white";//sets the textfield background color
  30. var button_bg = "white";//sets the button background color
  31. var button_hover ="white";//sets the color of the button when hovered over
  32. var button_hover_text = "blue";//sets the color of the text when the button is hovered over
  33. var greyed_out_payfield_bg = "grey";//sets the color of the minpay field when disabled
  34. }
  35.  
  36. else if (theme_no == 1){//Dark**********[ theme_no = 1 ]****************Dark
  37. var panel_bg = "-webkit-linear-gradient(top,rgb(67, 66, 66) 0,rgb(32, 32, 32) 100%) repeat-y; background: -moz-linear-gradient(top,rgb(67, 66, 66) 0,rgb(32, 32, 32) 100%) repeat-y";
  38. var text_bg = "-webkit-linear-gradient(top,rgb(56, 56, 56) 0,rgb(25, 25, 25) 100%) repeat-x; background: -moz-linear-gradient(top,rgb(56, 56, 56) 0,rgb(25, 25, 25) 100%) repeat-x";
  39. var button_bg = "-webkit-linear-gradient(top,rgb(84, 83, 83) 0,rgb(48, 48, 48) 100%) repeat-x; background: -moz-linear-gradient(top,rgb(84, 83, 83) 0,rgb(48, 48, 48) 100%) repeat-x";
  40. var border_color = "rgb(15, 15, 22)";
  41. var text_color = "rgb(12, 144, 195)";
  42. var button_hover ="-webkit-linear-gradient(top,rgb(85, 91, 101) 0,rgb(48, 48, 48) 100%) repeat-x; background: -moz-linear-gradient(top,rgb(85, 91, 101) 0,rgb(48, 48, 48) 100%) repeat-x";
  43. var button_hover_text = "rgb(30, 165, 220)";
  44. var greyed_out_payfield_bg = "rgb(60, 45, 45)";
  45. }
  46. else if (theme_no == 2){//Frost**********[ theme_no = 2 ]****************Frost
  47. var panel_bg = "-webkit-linear-gradient(top,rgb(225, 244, 251) 0,rgb(121, 190, 255) 100%) repeat-x; background: -moz-linear-gradient(top,rgb(225, 244, 251) 0,rgb(121, 190, 255) 100%) repeat-x";
  48. var text_bg = "-webkit-linear-gradient(top,rgb(241, 241, 241) 0,rgb(198, 216, 232) 100%) repeat-x !important; background: -moz-linear-gradient(top,rgb(241, 241, 241) 0,rgb(198, 216, 232) 100%) repeat-x !important";
  49. var button_bg = "-webkit-linear-gradient(top,rgba(151, 182, 250, 0.97) 0,rgb(51, 95, 162) 100%) repeat-x; background: -moz-linear-gradient(top,rgba(151, 182, 250, 0.97) 0,rgb(51, 95, 162) 100%) repeat-x";
  50. var border_color = "rgb(70, 110, 180)";
  51. var text_color = "rgb(0, 57, 79)";
  52. var button_hover ="-webkit-linear-gradient(top,rgba(175, 195, 255, 0.97) 0,rgb(70, 110, 180) 100%) repeat-x; background: -moz-linear-gradient(top,rgba(175, 195, 255, 0.97) 0,rgb(70, 110, 180) 100%) repeat-x";
  53. var button_hover_text = "rgb(1, 69, 85)";
  54. var greyed_out_payfield_bg = "rgb(210, 145, 145)";
  55. }
  56. else if (theme_no == 3){//Mint**********[ theme_no = 3 ]****************Mint
  57. var panel_bg = "-webkit-linear-gradient(top,rgb(176, 251, 170) 0,rgb(142, 255, 151) 100%) repeat-x; background: -moz-linear-gradient(top,rgb(176, 251, 170) 0,rgb(142, 255, 151) 100%) repeat-x";
  58. var text_bg = "-webkit-linear-gradient(top,rgba(233, 249, 235, 0.97) 0,rgb(245, 179, 234) 100%) repeat-x; background: -moz-linear-gradient(top,rgba(233, 249, 235, 0.97) 0,rgb(245, 179, 234) 100%) repeat-x";
  59. var button_bg = "-webkit-linear-gradient(top,rgba(255, 200, 236, 0.97) 0,rgb(255, 108, 231) 100%) repeat-x; background: -moz-linear-gradient(top,rgba(255, 200, 236, 0.97) 0,rgb(255, 108, 231) 100%) repeat-x";
  60. var border_color = "rgb(6, 170, 53)";
  61. var text_color = "rgb(116, 27, 81)";
  62. var button_hover ="-webkit-linear-gradient(top,rgba(255, 200, 236, 0.97) 0,rgb(255, 125, 255) 100%) repeat-x; background: -moz-linear-gradient(top,rgba(255, 200, 236, 0.97) 0,rgb(255, 125, 255) 100%) repeat-x";
  63. var button_hover_text = "rgb(196, 47, 138)";
  64. var greyed_out_payfield_bg = "rgb(150, 190, 75)";
  65. }
  66. else if (theme_no == 4){//Ole'Gregg**********[ theme_no = 4 ]****************Ole'Gregg
  67. var panel_bg = "-webkit-linear-gradient(top,rgb(236, 69, 236) 0,rgb(159, 37, 119) 100%) repeat-x; background: -moz-linear-gradient(top,rgb(236, 69, 236) 0,rgb(159, 37, 119) 100%) repeat-x";
  68. var text_bg = "-webkit-linear-gradient(top,rgba(158, 230, 79, 0.97) 0,rgb(143, 194, 141) 100%); background: -moz-linear-gradient(top,rgba(158, 230, 79, 0.97) 0,rgb(143, 194, 141) 100%)";
  69. var button_bg = "-webkit-linear-gradient(top,rgba(130, 191, 64, 0.97) 0,rgb(10, 148, 4) 100%) repeat-x; background: -moz-linear-gradient(top,rgba(130, 191, 64, 0.97) 0,rgb(10, 148, 4) 100%) repeat-x";
  70. var border_color = "rgb(48, 94, 48)";
  71. var text_color = "rgb(75, 25, 75)";
  72. var button_hover ="-webkit-linear-gradient(top,rgba(145, 210, 79, 0.97) 0,rgb(27, 159, 10) 100%) repeat-x; background: -moz-linear-gradient(top,rgba(145, 210, 79, 0.97) 0,rgb(27, 159, 10) 100%) repeat-x";
  73. var button_hover_text = "rgb(55, 99, 55)";
  74. var greyed_out_payfield_bg = "rgb(100, 55, 100)";
  75. }
  76. else if (theme_no == 5){//Dark_plain**********[ theme_no = 5 ]****************Dark_plain
  77. var panel_bg = "rgb(45, 45, 45)";
  78. var text_bg = "rgb(30, 30, 30)";
  79. var button_bg = "rgb(40, 40, 40)";
  80. var border_color = "rgb(15, 15, 22)";
  81. var text_color = "rgb(12, 144, 195)";
  82. var button_hover ="rgb(45, 45, 55)";
  83. var button_hover_text = "rgb(30, 165, 220)";
  84. var greyed_out_payfield_bg = "rgb(60, 45, 45)";
  85. }
  86. //note you can also add new custom themes here... simply add another "else if (theme_no == [your theme number]){" then copy and paste your custom theme under it and dont forget to add the closing "}"
  87.  
  88. var textfield_focus = "";//".eJtextfields:focus {box-shadow: 0px 0px 7px 1.5px rgba(15, 15, 20, 0.75);}";(this is a style that i'd like to have on some themes and not on others... just replace "" with what comes after //)
  89.  
  90. //you can play with some of the finer details below, note that any changes you make will apply to all themes
  91. var theme =`<style id= "Theme_No.`+theme_no+`" name="`+theme_name[theme_no]+`">
  92. .eJmain {
  93. position: relative;
  94. color: `+text_color+`;
  95. box-sizing: initial;
  96. border-radius: 2em;
  97. font: bold 15px Arial;
  98. margin: 0;
  99. outline: none !important;
  100. padding: 2px !important;
  101. min-height: 0px;
  102. text-align: left;
  103.  
  104. }
  105.  
  106. .eJpanel {
  107. height: 85px;
  108. width: 440px;
  109. background: `+panel_bg+`;
  110. border: 2.5px solid `+border_color+`;
  111. box-shadow: 5px 7px 5px 3px rgba(15, 15, 20, 0.72);
  112. transition-property: height;
  113. transition-duration: 0.65s;
  114. }
  115.  
  116. .eJtop_row {
  117. width: 500px;
  118. position: relative;
  119. top: 20px;
  120. left: 7.5px;
  121. }
  122.  
  123. .eJtextfields {
  124. height: 18px;
  125. background: `+text_bg+` !important;
  126. border: .5px solid `+border_color+`;
  127. box-shadow: inset 0px 4px 6px -2px rgba(15, 15, 20, 0.8);
  128. font-stretch: normal;
  129. transition-property: border, background, box-shadow;
  130. transition-duration: 1s;
  131. }
  132. `+textfield_focus+`
  133. .eJalign_right {
  134. text-align: right;
  135. }
  136.  
  137. .eJbutton {
  138. height: 18px;
  139. width: 75px;
  140. background: `+button_bg+`;
  141. border: 0px solid `+border_color+`;
  142. box-shadow: 1.5px 1.5px 2px 1px rgba(15, 15, 20, 0.75);
  143. text-align: center;
  144. }
  145.  
  146. .eJbutton:hover {
  147. box-shadow: 1.5px 2px 2px 1px rgba(15, 15, 20, 0.55);
  148. background: `+button_hover+`;
  149. color: `+button_hover_text+`;
  150. cursor:pointer;
  151. }
  152.  
  153. .eJbutton:active {
  154. box-shadow: 1px 1px 0px 0px rgba(15, 15, 20, 0.55);
  155. }
  156.  
  157. .eJtoggle_button {
  158. height: 15px;
  159. width: 15px;
  160. }
  161.  
  162. .eJsecond_row {
  163. position: relative;
  164. top: 15px;
  165. left: 215px;
  166. }
  167.  
  168. .eJanimate {
  169. height: 165px;
  170. }
  171.  
  172. .eJsmallfont {
  173. font: bold 12px Arial;
  174. position: relative;
  175. top: 25px;
  176. left: 20px;
  177. opacity: 1;
  178. transition-property: opacity;
  179. transition-duration: 1s;
  180. }
  181.  
  182. .eJcheckbox {
  183. height: 14px;
  184. width: 14px;
  185. margin-left 15px;
  186. vertical-align: middle;
  187. }
  188.  
  189. .eJdrop_menu {
  190. height: 18px;
  191. width: 100px;
  192. position: relative;
  193. top: 12.5px;
  194. left: 235px;
  195. opacity: 1;
  196. transition-property: opacity, display;
  197. transition-duration: 1s;
  198. }
  199. .eJdisable {
  200. background: `+greyed_out_payfield_bg+` !important;
  201. box-shadow: 0px 0px 0px 0px rgba(1, 1, 1, 0.0);
  202. border: none;
  203. }
  204.  
  205. .eJhidden_menu {
  206. opacity: 0;
  207. }
  208.  
  209. </style>`;
  210.  
  211.  
  212. var AMT_Searchbar =/*div structure-you should only have to edit the theme dropdown menu if you want to add a theme to that menu*/`
  213. <div id="eJAMTcapsule" class="cap" style="position: fixed; top: 24%; left: 31%; z-index: 3; display: none;">
  214.  
  215. <div id="eJmain_panel" class="eJmain eJpanel">
  216.  
  217. <div id="eJhomebar" class="eJtop_row">
  218.  
  219. <input type="text" id="eJsearch_field" class="eJmain eJtextfields" size="30">
  220. <input type="text" id="eJpay_field" class="eJmain eJtextfields eJalign_right" size="3">
  221. <button type="button" id="eJsearch_button" class="eJmain eJbutton">Search</button>
  222.  
  223. <div style="height: 1px;">
  224. <select name="eJdropdown" id="eJgreasy_drop" class="eJmain eJtextfields eJdrop_menu eJhidden_menu">
  225. <option value="">Relevance</option>
  226. <option value="&sort=daily_installs">Daily Installs</option>
  227. <option value="&sort=total_installs">Total Installs</option>
  228. <option value="&sort=ratings">Ratings</option>
  229. <option value="&sort=created">Created Date</option>
  230. <option value="&sort=updated">Updated Date</option>
  231. <option value="&sort=name">Name</option>
  232. </select>
  233. </div>
  234.  
  235. </div></br>
  236.  
  237. <button type="button" id="eJanimate_button" class="eJmain eJbutton eJtoggle_button eJsecond_row">⇕</button>
  238.  
  239. <div id="eJchecks" class="eJsmallfont eJhidden_menu">
  240. <input type="checkbox" id="eJqual_box" class="eJmain eJcheckbox" value="Qualed"> Qualified For
  241. <span style="display:inline-block; width: 180px;"></span>
  242. Search GreasyFork <input type="checkbox" id="eJgreasy_box" class="eJmain eJcheckbox eJalign_right" value="urls"></br>
  243. <input type="checkbox" id="eJmaster_box" class="eJmain eJcheckbox" value="Masters"> Masters Only
  244. <span style="display:inline-block; width: 218px;"></span>
  245. Search MTG <input type="checkbox" id="eJMTG_box" class="eJmain eJcheckbox eJalign_right" value="urls"></br></br>
  246. <button type="button" id="eJtheme_button" class="eJmain eJbutton eJtoggle_button"><img src="http://i.imgur.com/dvGS1s8.png"></button>
  247. <select name="eJ1dropdown" id="eJtheme_drop" class="eJmain eJtextfields eJhidden_menu">
  248. <option value="`+theme_no+`">`+theme_name[theme_no]+`</option>
  249. <option value="0">`+theme_name[0]+`</option>
  250. <option value="1">`+theme_name[1]+`</option>
  251. <option value="2">`+theme_name[2]+`</option>
  252. <option value="3">`+theme_name[3]+`</option>
  253. <option value="4">`+theme_name[4]+`</option>
  254. <option value="5">`+theme_name[5]+`</option>
  255. </select>
  256. </div>
  257.  
  258. </div>
  259.  
  260. </div>
  261. ;`;
  262.  
  263. $("head").append($(theme));
  264. $("body").append($(AMT_Searchbar));
  265. $("#eJgreasy_drop").prop("disabled", true);
  266. $("#eJtheme_drop").prop("disabled", true);
  267.  
  268. var search1 = "";//Using the var "search" as a default would not work without this var. neither would using "" as a defualt clear the searchbar on toggle
  269. var eJflag1 = -1;//flag used to control the dropdown of the hidden menu
  270. var inject_search = "";//general var that will carry any of the URLs required for search
  271.  
  272. $.fn.extend({valid_num: function() {//to escape the minpay field of any invalid characters *Thanks R.Daneel*
  273. vn = this.val().replace(/[^\d\.]/g, '');
  274. return (vn.length > 0 && /\d/.test(vn)) ? vn : minpay;
  275. }});
  276.  
  277. $.fn.extend({valid_srch: function() {//to make sure there are not just spaces typed into the searchbar (probably not needed, but i like it)
  278. vs = this.val();
  279. return (vs.trim().length > 0) ? vs : search;
  280. }});
  281.  
  282. $.fn.extend({box_manager: function() {//this is important... it manages the url injection for "qualed" and "masters" as well as assigning the var "inject_search" with the proper URL later on
  283. cb = this.prop("checked");
  284. if ($(this).attr("id") === "eJqual_box"){
  285. return (cb === true) ? "qualifiedFor=on" : "";
  286. }
  287. else if ($(this).attr("id") === "eJmaster_box"){
  288. return (cb === true) ? "requiresMasterQual=on" : "";
  289. }
  290. else if ($(this).attr("id") === "eJgreasy_box"){
  291. return (cb === true) ? "https://gf.qytechs.cn/en/scripts/search?q="+($("#eJsearch_field").valid_srch())+""+($("#eJgreasy_drop").val()) : "https://www.mturk.com/mturk/searchbar?selectedSearchType=hitgroups&searchWords="+$("#eJsearch_field").valid_srch()+"&minReward="+$("#eJpay_field").valid_num()+"&"+$("#eJqual_box").box_manager()+"&"+$("#eJmaster_box").box_manager();
  292. }
  293. else if ($(this).attr("id") === "eJMTG_box"){
  294. return (cb === true) ? "http://www.mturkgrind.com/search/7230196/?q="+($("#eJsearch_field").valid_srch())+"&o=date" : inject_search;
  295. }
  296. }});
  297.  
  298. $(document).keydown(function(e){//toggle function--- press[`] (backtick) to toggle the searchbar *note this is also responsible for applying most of the default values
  299. if (e.which == 192) {
  300. search1 = search;
  301. if (qual == "true"){
  302. $("#eJqual_box").prop("checked", true);
  303. }
  304. if (master == "true"){
  305. $("#eJmaster_box").prop("checked", true);
  306. }
  307. if (window.getSelection().toString() !== ""){//this will paste whatever you have selected on the page into the searchbar when you press the toggle button (select a requester name in the forum, then toggle the searchbar and the name will already be in the searchbar)
  308. search1 = window.getSelection().toString();
  309. }
  310. $("#eJsearch_field").val(search1);
  311. $("#eJpay_field").prop("readonly") === true ? $("#eJpay_field").val("") : $("#eJpay_field").val(minpay);
  312. $("#eJAMTcapsule").toggle();
  313. (e.preventDefault());
  314. $("#eJsearch_field").focus();//this can be changed to ".select();" to select all the text in the searchfield as you toggle the searchbar
  315. }
  316. });
  317.  
  318. $(".eJcheckbox").click(function(e){//this messy logic makes sure that, when you change which site you want to search, the proper things happen...i.e. disabling the minpay field, toggling the hidden dropmenu...
  319. if ($(this).attr("id") === "eJgreasy_box") {//this manages the greasyfork checkbox and everything that happens when you click it
  320. if (eJflag1 == 1) {
  321. $(this).prop("checked") === true ? ($("#eJpay_field").addClass("eJdisable").val("").prop("readonly", true)) : ($("#eJpay_field").removeClass("eJdisable").val(minpay).prop("readonly", false));
  322. $("#eJgreasy_drop").prop("disabled") === true ? ($("#eJgreasy_drop").prop("disabled", false).toggleClass("eJhidden_menu")) : ($("#eJgreasy_drop").prop("disabled", true).toggleClass("eJhidden_menu"));
  323. $("#eJMTG_box").prop("checked", false);
  324. }
  325. else (e.preventDefault());
  326. }
  327. if ($(this).attr("id") === "eJMTG_box") {//this manages the MTG checkbox and everything that happens when you click it
  328. if (eJflag1 == 1) {
  329. $(this).prop("checked") === true ? ($("#eJpay_field").addClass("eJdisable").val("").prop("readonly", true)) : ($("#eJpay_field").removeClass("eJdisable").val(minpay).prop("readonly", false));
  330. $("#eJgreasy_drop").prop("disabled") === true ? $("#eJgreasy_drop").prop("disabled", true) : ($("#eJgreasy_drop").prop("disabled", true).toggleClass("eJhidden_menu"));
  331. $("#eJgreasy_box").prop("checked", false);
  332. }
  333. else (e.preventDefault());
  334. }
  335. });
  336.  
  337.  
  338. $(".eJbutton").click(function(e){//this makes things happen when you click any button
  339. if ($(this).attr("id") === "eJsearch_button") {//this is the search button
  340. inject_search = $("#eJgreasy_box").box_manager();
  341. inject_search = $("#eJMTG_box").box_manager();
  342. $("#eJAMTcapsule").toggle();
  343. window.open(inject_search);
  344. }
  345. if ($(this).attr("id") === "eJtheme_button") {//this is the theme changing button, click once to bring up the drop menu and select your theme, click again to save your theme...*note the line directly beneath this one places the text in the search bar when you click the theme button, you can change this text to whatever you like.
  346. $("#eJtheme_drop").prop("disabled") === true ? $("#eJsearch_field").val("Press again to save your theme...") : $("#eJsearch_field").val("Please refresh the page");
  347. $("#eJtheme_drop").prop("disabled") === true ? $("#eJtheme_drop").toggleClass("eJhidden_menu").prop("disabled", false) : $("#eJtheme_drop").toggleClass("eJhidden_menu").prop("disabled", true);
  348. localStorage.AMTSBtheme = $("#eJtheme_drop").val();
  349. }
  350. if ($(this).attr("id") === "eJanimate_button") {//this is the hidden menu toggle button
  351. if (eJflag1 == -1) {
  352. $("#eJmain_panel").toggleClass("eJanimate");
  353. setTimeout(function(){$(".eJsmallfont").toggleClass("eJhidden_menu");}, 500);
  354. eJflag1 = (eJflag1)*-1;
  355. }
  356. else {
  357. $(".eJsmallfont").toggleClass("eJhidden_menu");
  358. setTimeout(function(){$("#eJmain_panel").toggleClass("eJanimate");}, 650);
  359. eJflag1 = (eJflag1)*-1;
  360. }
  361. }
  362. });
  363.  
  364. $(".eJtextfields").keyup(function(e){//this makes things happen when you press enter in a searchfield
  365. if (e.which == 13) {
  366. inject_search = $("#eJgreasy_box").box_manager();
  367. inject_search = $("#eJMTG_box").box_manager();
  368. $("#eJAMTcapsule").toggle();
  369. window.open(inject_search);
  370. }
  371. });

QingJ © 2025

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