Mturk Group IDs

Adds group ID to mturk hit frames

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         Mturk Group IDs
// @description  Adds group ID to mturk hit frames
// @author       DCI
// @namespace    https://www.redpandanetwork.org
// @version      1.4
// @include      *
// @run-at       document-start
// ==/UserScript==

if (~window.location.toString().indexOf("worker.mturk.com/projects/")){
    window.addEventListener("message", function(e){
        if (e.data == "I'm here!"){
            let iframe = document.getElementsByTagName("iframe")[0];
            let groupId = location.toString().split("projects/")[1].split("/")[0];
            iframe.contentWindow.postMessage("&groupId=" + groupId, "*");
        }
    });
}
if ((window.location != window.parent.location) && (!~window.location.toString().indexOf("externalSubmit"))){
    if (!~window.location.toString().indexOf("&groupId=")){
        window.addEventListener("message", function(e){
            if (~e.data.indexOf("&groupId=")){
                location.replace(location + e.data);
            }
        });
    }
    window.parent.postMessage("I'm here!", '*');
}