Fix date formats

Replace month-day-year dates with day-month-year dates.

  1. // ==UserScript==
  2. // @name Fix date formats
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description Replace month-day-year dates with day-month-year dates.
  6. // @match *://*/*
  7. // @require https://code.jquery.com/jquery-3.6.0.min.js
  8. // @license MIT
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. //Get all text nodes in a given container
  15. //Source: http://stackoverflow.com/a/4399718/560114
  16. function getTextNodesIn(node, includeWhitespaceNodes) {
  17. var textNodes = [], nonWhitespaceMatcher = /\S/;
  18.  
  19. function getTextNodes(node) {
  20. if (node.nodeType == 3) {
  21. if (includeWhitespaceNodes || nonWhitespaceMatcher.test(node.nodeValue)) {
  22. textNodes.push(node);
  23. }
  24. } else {
  25. for (var i = 0, len = node.childNodes.length; i < len; ++i) {
  26. getTextNodes(node.childNodes[i]);
  27. }
  28. }
  29. }
  30.  
  31. getTextNodes(node);
  32. return textNodes;
  33. }
  34.  
  35. var j = jQuery.noConflict();
  36. var textNodes = getTextNodesIn( j("body")[0], false );
  37. var i = textNodes.length;
  38. var node;
  39. while (i--) {
  40. node = textNodes[i];
  41. node.textContent = node.textContent.replace(/([A-Z][a-z]{2,8}|[A-Z][a-z]{2}\.) (\d{1,2}), (\d{4})/g, '$2 $1 $3');
  42. }
  43. })();

QingJ © 2025

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