Google, 12 hour date-time picker

Switches the date time picker on google searches to a 12 hour clock

当前为 2017-08-04 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Google, 12 hour date-time picker
  3. // @namespace https://greasyfork.org/users/649
  4. // @version 1.0
  5. // @description Switches the date time picker on google searches to a 12 hour clock
  6. // @author Adrien Pyke
  7. // @include /^https?:\/\/www\.google\.[a-zA-Z]+\/.*$/
  8. // @grant none
  9. // @require https://greasyfork.org/scripts/5679-wait-for-elements/code/Wait%20For%20Elements.js?version=147465
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. var Util = {
  16. q: function(query, context) {
  17. return (context || document).querySelector(query);
  18. },
  19. qq: function(query, context) {
  20. return [].slice.call((context || document).querySelectorAll(query));
  21. }
  22. };
  23.  
  24. waitForElems({
  25. sel: '.tdu-datetime-picker > div.tdu-t > div:nth-child(1) > div > ul',
  26. onmatch: function(hourSelector) {
  27. Util.qq('li', hourSelector).forEach(function(hour) {
  28. var value = parseInt(hour.dataset.value);
  29. if (value === 0) {
  30. hour.textContent = 'AM 12';
  31. } else if (value === 12) {
  32. hour.textContent = 'PM 12';
  33. } else {
  34. hour.textContent = (value < 12 ? 'AM ' : 'PM ') + (value % 12);
  35. }
  36. });
  37. }
  38. });
  39. })();