Relevance Groupon on Mturk

Hides instructions, auto opens link, when radio is clicked new window closes and hit submits.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        Relevance Groupon on Mturk
// @version    1.0
// @description  Hides instructions, auto opens link, when radio is clicked new window closes and hit submits.
// @author     Cristo
// @include    https://s3.amazonaws.com/mturk_bulk/*
// @copyright  2012+, You
// @namespace https://greasyfork.org/users/1973
// ==/UserScript==

if (window.location.toString().indexOf("ASSIGNMENT_ID_NOT_AVAILABLE") === -1){
    
    var page = document.getElementById("mturk_form");
    var instructions = page.getElementsByClassName("panel panel-primary")[0];
    var site = page.getElementsByTagName("a")[1].href;
    var inputs = page.getElementsByTagName("input");
    var sub = document.getElementById("submitButton");
    instructions.style.display = "none";
    
    var but = document.createElement("input");
    but.type = "button";
    but.value = "Instructions";
    instructions.parentNode.insertBefore(but, instructions.nextSibling);
    
    var newWidth;
    var newLeft;
    var windowTo;
    var windowEnd = window.screenX + window.outerWidth;
    var leftSpace = window.screenX;
    var rightSpace = screen.width - windowEnd;
    if (leftSpace > rightSpace) {
        newWidth = window.screenX;
        newLeft = "0";
    } else {
        newWidth = screen.width - windowEnd;
        newLeft = windowEnd;
    }
    windowTo  = 'width=' + newWidth;
    windowTo += ', height=' + screen.height;
    windowTo += ', top=' + "0"; 
    windowTo += ', left=' + newLeft;
    var newin = window.open(site, "name", windowTo);
    
    document.addEventListener( "click", cas, false );
    function cas (d) {
        if(d.target == but){
            if(instructions.style.display == "none") {
                instructions.style.display = "block";
            } else if (instructions.style.display == "block") {
                instructions.style.display = "none";
            }
                }
        if(d.target == inputs[2]){
            newin.close();
            sub.click();
        }
        if(d.target == inputs[3]){
            newin.close();
            sub.click();
        }
    }
    
}