Skip to content

Instantly share code, notes, and snippets.

@cuylerstuwe
Created April 30, 2018 19:51
Show Gist options
  • Select an option

  • Save cuylerstuwe/dda1455b3a46c5b9d4f8abab6eb1fc0a to your computer and use it in GitHub Desktop.

Select an option

Save cuylerstuwe/dda1455b3a46c5b9d4f8abab6eb1fc0a to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Ben - Rewriting Club/Org Names
// @namespace salembeats
// @version 1
// @description .
// @author Cuyler Stuwe (salembeats)
// @include *
// @require https://gist.github.com/salembeats/3dd0c6c765a553c1184bc1d6d075bb9a/raw/5335a3ca833e5ccb7574c3c1d7b8af2e0e96a859/mselect.library.user.js
// @require https://gist.github.com/salembeats/6f50c37f7309fe1c7632376c4e2f3a1c/raw/bce38260696278c5cb42d0d8ee5f65125511577b/maction.library.user.js
// @require https://gist.github.com/salembeats/2661fe710d1520a50cb0f8fa8b23d052/raw/ec9a488a06227d8baf1729f30cfc3a985680e1fb/mutil.library.user.js
// @grant none
// ==/UserScript==
const GID = "3PUN5J88E7T1E3XFEVJDOS6LBXHADR";
if(GID && window === window.top) {return;}
if(GID && !document.referrer.includes(GID)) {return;}
async function main() {
// Entry point.
let text = M$.$("b").innerText;
M$.$("textarea").value = text;
M$.$("textarea").addEventListener("keydown", event => {
if(event.keyCode === 13) {
event.preventDefault();
M$.$("[type=submit]").click();
}
});
M$.$$("p, b").forEach(el => el.style.display = "none");
M$.$(".panel.panel-primary").style.display = "none";
M$.$("textarea").focus();
}
main();
/*
==================================================================================================================================================
Template Quickstart
==================================================================================================================================================
NOTE: The question mark (?) before a parameters means that parameter is optional.
M$ ("MTurk $electors")
.$(selector)
Selects the first element that matches the CSS selector. Alias for document.querySelector(selector).
.$$(selector)
Selects all elements that match the CSS selector. Alias for document.querySelectorAll(selector).
.$$$(selector)
Selects all elements on the page. Alias for document.querySelectorAll("*").
.$text(selector, text, ?options)
Selects the first element that matches a given CSS selector and contains the given text.
.$$aText(selector, text, ?options)
Returns an array which contains all elements matching a given CSS selector and given text.
.$rads()
Selects all radio buttons. Alias for document.querySelectorAll("input[type='radio']").
.$sub()
Selects the submit button - first by input type, and then by ID as a fallback.
.$0()
Selects the last-clicked element.
MA ("MTurk Actions")
.click(element)
If the element exists, it will be clicked.
.hide(element)
If the element exists, it will be hidden.
.show(element)
If the element exists, it will be shown.
.remove(element)
If the element exists, it will be removed.
.text(element, ?options)
If the element exists, this method will either: A) Set the text and return the element, or B) Return the text inside the element.
options: string | object
If options is a string, the selected element will have its text changed to that string.
Otherwise, the options have the following effect:
{
lowercase|lower|l: If set to true, the text is set or returned as lowercase.
text: If set, this will be used as the string to set the element's text to.
}
MU ("MTurk Utilities")
.$wait(selector, ?pollRate)
Returns a Promise that polls the page for a selector and ultimately returns the first element selected by that selector as soon as it is found.
Example Usage:
MU.$wait(".alert-this-text-on-insert").then( insertedElement => alert( insertedElement.innerText ) );
==================================================================================================================================================
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment