Date Fix for Google.ca

Reformat dd/mm/yyyy to yyyy-mm-dd

  1. // ==UserScript==
  2. // @name Date Fix for Google.ca
  3. // @description Reformat dd/mm/yyyy to yyyy-mm-dd
  4. // @author Jefferson "jscher2000" Scher
  5. // @namespace JeffersonScher
  6. // @copyright Copyright 2015 Jefferson Scher
  7. // @license BSD with restriction
  8. // @include https://www.google.ca/search?*
  9. // @version 0.9.1
  10. // @grant none
  11. // @resource mycon http://www.jeffersonscher.com/gm/src/gfrk-DFGca-ver091.png
  12. // ==/UserScript==
  13.  
  14. // List of labels on the submit button that indicate a date fix is needed. Please edit as needed.
  15. var flipFor = ["Aller"]; // Separate with commas, e.g., ["apple","banana","carambola"]; case sensitive
  16.  
  17. // Add MutationObserver to catch dynamic generation of dialog
  18. var DFGca_MutOb = (window.MutationObserver) ? window.MutationObserver : window.WebKitMutationObserver;
  19. if (DFGca_MutOb){
  20. var DFGca_chgMon = new DFGca_MutOb(function(mutationSet){
  21. mutationSet.forEach(function(mutation){
  22. for (var i=0; i<mutation.addedNodes.length; i++){
  23. if (mutation.addedNodes[i].nodeType == 1){
  24. DFGca_checkNode(mutation.addedNodes[i]);
  25. }
  26. }
  27. });
  28. });
  29. // attach chgMon to document.body
  30. var opts = {childList: true, subtree: true};
  31. DFGca_chgMon.observe(document.body, opts);
  32. }
  33. // Check added element for date picker dialog
  34. function DFGca_checkNode(el){
  35. var btnsubmit = el.querySelector('input.cdr_go');
  36. if (btnsubmit){
  37. if (btnsubmit.type == "submit" && flipFor.indexOf(btnsubmit.value) > -1){
  38. btnsubmit.addEventListener("mouseover", DFGca_fixDates, false);
  39. }
  40. }
  41. }
  42. function DFGca_fixDates(e){
  43. document.getElementById("cdr_min").value = DFGca_flipDate(document.getElementById("cdr_min").value);
  44. document.getElementById("cdr_max").value = DFGca_flipDate(document.getElementById("cdr_max").value);
  45. }
  46. function DFGca_flipDate(inpVal){
  47. var dparts = inpVal.split("/");
  48. if (dparts.length != 3) return inpVal; // return the original value
  49. // reverse the order of the parts and separate with - characters
  50. return dparts[2] + "-" + dparts[1] + "-" + dparts[0];
  51. }
  52. /*
  53. Copyright (c) 2015 Jefferson Scher. All rights reserved.
  54.  
  55. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met and subject to the following restriction:
  56.  
  57. 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  58.  
  59. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  60.  
  61. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
  62.  
  63. RESTRICTION: USE WITH ANY @include or @match THAT COVERS FACEBOOK.COM IS PROHIBITED AND UNLICENSED.
  64.  
  65. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  66. */

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址