Mturk Group IDs

Adds group ID to mturk hit frames

As of 2018-08-17. See the latest version.

// ==UserScript==
// @name         Mturk Group IDs
// @description  Adds group ID to mturk hit frames
// @author       DCI
// @namespace    https://www.redpandanetwork.org
// @version      1.2
// @include      *
// @exclude      https://worker.mturk.com/mturk/externalSubmit*
// @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.src = iframe.src + "&groupId=" + groupId;
        }
    });
}
if ((window.location != window.parent.location) && (!~window.location.toString("externalSubmit"))){
    if (!~window.location.toString().indexOf("&groupId=")){
        window.parent.postMessage("I'm here!", '*');
    }
}