🏠 Home 

Greasy Fork is available in English.

解码“禁用S1繁简转换”造成的乱码

解码因为使用unlsycn编写“禁用S1的繁简转换”脚本造成的“乱码”,以方便阅读。感谢之前“unlsycn”提供的简繁转换脚本。


安装此脚本?
  1. // ==UserScript==
  2. // @name 解码“禁用S1繁简转换”造成的乱码
  3. // @license GPL v3
  4. // @namespace http://tampermonkey.net/
  5. // @version 0.11
  6. // @description 解码因为使用unlsycn编写“禁用S1的繁简转换”脚本造成的“乱码”,以方便阅读。感谢之前“unlsycn”提供的简繁转换脚本。
  7. // @author X.Y.Z
  8. // @match https://*.saraba1st.com/2b/*
  9. // @icon https://bbs.saraba1st.com/favicon.ico
  10. // ==/UserScript==
  11. (function() {
  12. function convertHexToUnicode(text) {
  13. return text.replace(/&#x([0-9A-Fa-f]+);/g, function(match, hex) {
  14. return String.fromCharCode(parseInt(hex, 16));
  15. });
  16. }
  17. function processTextNode(node) {
  18. let text = node.textContent;
  19. let newText = convertHexToUnicode(text);
  20. if (newText !== text) {
  21. node.textContent = newText;
  22. }
  23. }
  24. function traverseNodes(node) {
  25. if (node.nodeType === Node.TEXT_NODE) {
  26. processTextNode(node);
  27. } else {
  28. for (let child = node.firstChild; child; child = child.nextSibling) {
  29. traverseNodes(child);
  30. }
  31. }
  32. }
  33. traverseNodes(document.body);
  34. })();