BvS Thousand Separator

Adds thousand separators to numbers

  1. // ==UserScript==
  2. // @name BvS Thousand Separator
  3. // @namespace BvS
  4. // @version 1.2
  5. // @history 1.2 New domain - animecubedgaming.com - Channel28
  6. // @history 1.1 Now https compatible (Updated by Channel28)
  7. // @description Adds thousand separators to numbers
  8. // @include http*://*animecubed.com/billy/bvs/*
  9. // @include http*://*animecubedgaming.com/billy/bvs/*
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. // "\u00a0" = non-breaking space
  14. const separator = ",";
  15.  
  16. function separate(txt)
  17. {
  18. return txt.replace(/((\b\d{1,3})|(\d))(?=(\d)+\b)/g, "$&" + separator);
  19. }
  20.  
  21. function replace()
  22. {
  23. var parents = ['b', 'i', 'center', 'div', 'font', 'form', 'label', 'li', 'span', 'td'];
  24. var eval = "//text()[(parent::" + parents.join(" or parent::") + ")]";
  25. var textnodes = document.evaluate(eval, document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
  26. var i = 0;
  27. for (var node = textnodes.snapshotItem(i); node; node = textnodes.snapshotItem(++i))
  28. node.textContent = separate(node.textContent);
  29. }
  30.  
  31. window.addEventListener("load", replace, false);

QingJ © 2025

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