Mturk Group IDs

Adds group ID to mturk hit frames

目前为 2018-08-17 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Mturk Group IDs
  3. // @description Adds group ID to mturk hit frames
  4. // @author DCI
  5. // @namespace https://www.redpandanetwork.org
  6. // @version 1.4
  7. // @include *
  8. // @run-at document-start
  9. // ==/UserScript==
  10.  
  11. if (~window.location.toString().indexOf("worker.mturk.com/projects/")){
  12. window.addEventListener("message", function(e){
  13. if (e.data == "I'm here!"){
  14. let iframe = document.getElementsByTagName("iframe")[0];
  15. let groupId = location.toString().split("projects/")[1].split("/")[0];
  16. iframe.contentWindow.postMessage("&groupId=" + groupId, "*");
  17. }
  18. });
  19. }
  20. if ((window.location != window.parent.location) && (!~window.location.toString().indexOf("externalSubmit"))){
  21. if (!~window.location.toString().indexOf("&groupId=")){
  22. window.addEventListener("message", function(e){
  23. if (~e.data.indexOf("&groupId=")){
  24. location.replace(location + e.data);
  25. }
  26. });
  27. }
  28. window.parent.postMessage("I'm here!", '*');
  29. }