ID Copy/Paste

Places an unobtrusive button on the page which provides quick access to copy your mTurk worker ID. Edited by Tjololo12: Hover highlight for easy copy-paste, does not show on mturk pages

  1. // ==UserScript==
  2. // @name ID Copy/Paste
  3. // @author Sasquatch
  4. // @version 1.0.5
  5. // @namespace http://www.mturkforum.com
  6. // @homepage http://mturkforum.com/showthread.php?4443-Worker-ID-Copy-Paste&p=57029
  7. // @description Places an unobtrusive button on the page which provides quick access to copy your mTurk worker ID. Edited by Tjololo12: Hover highlight for easy copy-paste, does not show on mturk pages
  8. // @include https://www.mturk.com/mturk/dashboard
  9. // @include http://*.qualtrics.com/*
  10. // @include https://*.qualtrics.com/*
  11. // @include http://*surveygizmo.com/*
  12. // @include https://*surveygizmo.com/*
  13. // @include https://docs.google.com/forms/*
  14. // @include https://*.surveymonkey.com/*
  15. // ==/UserScript==
  16.  
  17. if (!this.GM_getValue || (this.GM_getValue.toString && this.GM_getValue.toString().indexOf("not supported")>-1)) {
  18. this.GM_getValue=function (key,def) {
  19. return localStorage[key] || def;
  20. };
  21. this.GM_setValue=function (key,value) {
  22. return localStorage[key]=value;
  23. };
  24. }
  25.  
  26. workerID = GM_getValue("workerID");
  27. if(!workerID || workerID == "") {
  28. if (window.location.href == "https://www.mturk.com/mturk/dashboard") {
  29. workerIDNode = document.evaluate("//span[@class='orange_text_right']",document,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);
  30. for (i=0; i<workerIDNode.snapshotLength; i++) {
  31. nd = workerIDNode.snapshotItem(i);
  32. idstring = nd.innerHTML;
  33. workerID = idstring.split(': ')[1];
  34. GM_setValue("workerID",workerID);
  35. }
  36. } else {
  37. workerID="";
  38. GM_setValue("workerID","");
  39. }
  40. } else {
  41. if (!/https?:\/\/www.mturk.com\/mturk\/*/.test(window.location.href)) {
  42. idDiv = document.createElement('div');
  43. idDiv.id = "workerIDDiv";
  44. idInner = "<input type='text' onmouseover='javascript:this.focus();this.select() ;' onmouseout='javascript:this.blur();' value='" + workerID + "' style='position:fixed;border:none;top:25px;z-index:10000;right:5px;padding:1px 3px;background:#33CC00;font-size:10px;color:white;' readonly/>";
  45. idDiv.innerHTML = idInner;
  46. document.body.insertBefore(idDiv,document.body.firstChild);
  47. }
  48. }