Non-Printable Character Detection

Replace non-printable characters, e.g., zero-width spaces, with a visible symbol.

目前為 2021-09-16 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Non-Printable Character Detection
// @namespace    https://greasyfork.org/users/193469
// @description  Replace non-printable characters, e.g., zero-width spaces, with a visible symbol.
// @version      1.0
// @author       Rui LIU (@liurui39660)
// @match        *://*/*
// @icon         https://icons.duckduckgo.com/ip2/example.com.ico
// @license      MIT
// @run-at       document-end
// ==/UserScript==

(function () {
	'use strict';

	const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT);
	let node;
	while (node = walker.nextNode()) {
		node.nodeValue = node.nodeValue.replaceAll(/\p{Cf}/gu, '❖');
	}
})();