去除邪恶数字

去除邪恶数字,防止口算出错

  1. // ==UserScript==
  2. // @name 去除邪恶数字
  3. // @name:en Remove A Certain Evil Number
  4. // @name:zh 去除邪恶数字
  5. // @namespace https://github.com/KumaTea
  6. // @namespace https://gf.qytechs.cn/en/users/169784-kumatea
  7. // @version 0.1.0.0
  8. // @description 去除邪恶数字,防止口算出错
  9. // @description:en Removing a certain evil number to prevent calculation errors
  10. // @description:zh 去除邪恶数字,防止口算出错
  11. // @author KumaTea
  12. // @match https://twitter.com/*
  13. // @match https://x.com/*
  14. // @license GPLv3
  15. // ==/UserScript==
  16.  
  17. /* jshint esversion: 8 */
  18. // "use strict";
  19.  
  20.  
  21. let delay = 10*1000;
  22. const TwitterTextTag = 'span';
  23.  
  24. const evilNum = '\u0038\u0039\u0036\u0034';
  25. /* 备用
  26. 中文数字、全角数字、上标数字等
  27. 性能原因暂不启用
  28. const evilNumList = [
  29. '\u0038\u0039\u0036\u0034',
  30. ]
  31. */
  32. const goodNum = '\u0038\u0039\u0037\u0032';
  33.  
  34.  
  35. function sleep(ms) {
  36. return new Promise(resolve => setTimeout(resolve, ms));
  37. }
  38.  
  39. function replaceStrings() {
  40. let count = 0;
  41. var textNodes = document.querySelectorAll(TwitterTextTag);
  42.  
  43. for (var i = 0; i < textNodes.length; i++) {
  44. var textNode = textNodes[i];
  45. var originalText = textNode.textContent;
  46. var modifiedText = originalText;
  47.  
  48. /* for (var j = 0; j < evilNumList.length; j++) {
  49. var pattern = evilNumList[j];
  50. modifiedText = modifiedText.replace(pattern, goodNum);
  51. } */
  52. modifiedText = modifiedText.replace(evilNum, goodNum);
  53.  
  54. if (modifiedText !== originalText) {
  55. textNode.textContent = modifiedText;
  56. count += 1;
  57. }
  58. }
  59.  
  60. if (count) {
  61. console.log("replaced " + count + " string(s) in a total of " + textNodes.length + "!");
  62. }
  63. }
  64.  
  65. async function main() {
  66. while (1) {
  67. await sleep(delay);
  68. replaceStrings();
  69. delay = Math.min(delay*2, 5*60*1000);
  70. }
  71. }
  72.  
  73. main();

QingJ © 2025

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