TimerInTitlebar

Puts the remaining HIT time in the titlebar.

  1. // ==UserScript==
  2. // @name TimerInTitlebar
  3. // @namespace https://greasyfork.org/en/users/6503-turk05022014
  4. // @description Puts the remaining HIT time in the titlebar.
  5. // @match https://*.mturk.com/projects/*/tasks/*
  6. // @grant none
  7. // @require http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js
  8. // @version 1.3.20180405
  9. // ==/UserScript==
  10. this.$ = this.jQuery = jQuery.noConflict(true);
  11. var originalTitle = document.title;
  12. $(document).ready(function () {
  13. setInterval(function () {
  14. var otime = $(".completion-timer").parent().filter(":first").data().reactProps.originalTimeToCompleteInSeconds;
  15. var ct = $(".completion-timer").text().split(" ")[0].split(":").reverse();
  16. var s = (otime - (parseInt(ct[0]) + (parseInt(ct[1])*60) + (ct[2]?parseInt(ct[2])*60*60:0))) * 1000;
  17. var d = new Date(s).toUTCString().replace(/:/g, " ").split(" ");
  18. if (d[1] > 1) { document.title = [d[1]-1,d[4],d[5],d[6]].join(":") }
  19. else if (d[4] > 0) { document.title = [d[4],d[5],d[6]].join(":") }
  20. else { document.title = [d[5],d[6]].join(":") }
  21. document.title += " " + originalTitle;
  22. }, 1000);
  23. });