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. Edited by Swole_hamster to add more domains.

当前为 2015-05-19 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name ID Copy/Paste
  3. // @author Sasquatch
  4. // @version 1.0.7
  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. Edited by Swole_hamster to add more domains.
  8. // @grant GM_setValue
  9. // @grant GM_getValue
  10. // @grant GM_registerMenuCommand
  11. // @include https://www.mturk.com/mturk/dashboard
  12. // @include http://*.qualtrics.com/*
  13. // @include https://*.qualtrics.com/*
  14. // @include http://*surveygizmo.com/*
  15. // @include https://*surveygizmo.com/*
  16. // @include https://docs.google.com/forms/*
  17. // @include https://*.surveymonkey.com/*
  18. // @include https://*soscisurvey.de/*
  19. // @include http://*.dartmouth.edu/*
  20. // @include https://*.dartmouth.edu/*
  21. // @include https://*.vennliapp.com/*
  22. // ==/UserScript==
  23.  
  24. if (!this.GM_getValue || (this.GM_getValue.toString && this.GM_getValue.toString().indexOf("not supported")>-1)) {
  25. this.GM_getValue=function (key,def) {
  26. return localStorage[key] || def;
  27. };
  28. this.GM_setValue=function (key,value) {
  29. return localStorage[key]=value;
  30. };
  31. }
  32.  
  33. workerID = GM_getValue("workerID");
  34. if(!workerID || workerID == "") {
  35. if (window.location.href == "https://www.mturk.com/mturk/dashboard") {
  36. workerIDNode = document.evaluate("//span[@class='orange_text_right']",document,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);
  37. for (i=0; i<workerIDNode.snapshotLength; i++) {
  38. nd = workerIDNode.snapshotItem(i);
  39. idstring = nd.innerHTML;
  40. workerID = idstring.split(': ')[1];
  41. GM_setValue("workerID",workerID);
  42. }
  43. } else {
  44. workerID="";
  45. GM_setValue("workerID","");
  46. }
  47. } else {
  48. if (!/https?:\/\/www.mturk.com\/mturk\/*/.test(window.location.href)) {
  49. idDiv = document.createElement('div');
  50. idDiv.id = "workerIDDiv";
  51. 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/>";
  52. idDiv.innerHTML = idInner;
  53. document.body.insertBefore(idDiv,document.body.firstChild);
  54. }
  55. }