您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Replace words. Store replacements in flexible json (loaded by url). Share config with other, best for reading books with translate. Traditional to simplified chinese option.
Just copy replacement.js to Tampermonkey / Userscripts.
Change url to your config.
Here is small js script for word replacements.
include
, you can add configs from other pplit's small config at the beginning of the scirpt
const config = {
"json_url": "https://api.npoint.io/adca32df1622919ca5bd",
"traditional_to_simple_chinese": true,
"default_priority_level": 1,
"binds": {
"click_interval": 3000,
"n": 3,
"m": 2,
"events": {
[known_events.config_update]: [4, 4, 6, 6],
[known_events.turn_on_off]: [6, 6, 4, 4],
}
}
};
url, with your config
Where you can store json?
true
, false
I readed chinese book with translation dubbing. I saw as original, as translated text.
So I added option to convert hard readable hieroglyphs to there simple version
optional, useful if you're experimenting with the order of substitutions
read about __level
in json
const known_events = {
config_update: "forse_update_replacements",
turn_on_off: "swap_on_off",
}
// ....
"binds": {
"click_interval": 3000,
"n": 3,
"m": 2,
"events": {
[known_events.config_update]: [4, 4, 6, 6],
[known_events.turn_on_off]: [6, 6, 4, 4],
}
}
Binds - settings - where and how click to run some options.
I want to work them as on PC, as on IOS - and don't want to add GUI buttons.
Idea is following:
Example for n=3, m=2
-------------
| 1 | 2 | 3 |
|---|---|---|
| 4 | 5 | 6 |
-------------
Next step is to set option - what to do and order - which block clicks expected.
It's interval, where you have to do all clicks.
"click_interval": 3000
- 3 seconds
[4, 4, 6, 6]
Expected order of clicks.
At this case - you should tap twice in left bottom screen
And after that - twice in right bottom.
config looks this way:
{
"__urls": [
"https://some_novel_site/my_novel/chapter_*"
],
"smthA": {
"a": "b",
"smthB": {
"smthC": {
"x": "y",
}
}
},
"smthD": {
"/val(.+)/": "test $1"
}
}
Check here mine current config:
[https://www.npoint.io/docs/adca32df1622919ca5bd]
[https://www.npoint.io/docs/97ef86b1e99dfc26c72d]
You can create so much nested nodes with any names, as you want.
Script recursively parse json and collect pairs
arr = [
["a", "b"],
["x", "y"],
["/val(.+)/", "test $1"],
]
Replacement have 2 options.
string: string
string: [str1, str2, ...str_n]
Only this things would be collected.
"x": ["a", "b", "c"]
"老三", ["Third Bro", "Younger Bro"],
Random value would be select for replacement.
"AAx" -> "AAb"
"AAx" -> "AAc"
Example:
"/(\\d)o/": "$10"
- change o after digit to 0
2o
-> 20
, 9o
-> 90
/
\\
i
, u
, e.t.c.g
auto insertedgoogle javascript regex
if want more examples
ab
"a": "Alice", "b": "Bob"
basicaly result would be AliceBob
Alice Bob
rules to convertion:
Alice
- start from letter, not hieroglyphAlice
"XXX<--aXXX"There are following key words:
__urls
- ignore node if not passed__include
- add other nodes from higher level, or url to load another json__level
- set priority level, probably some replacements should work first, another laterexample:
{
"common_replacements": {
...
"__urls": ["*"],
}
"MyNovel1": {
...
"arc 5": {
"specific per concrete chapters": {
"x": "y",
// chapters 1159-1212
"__urls": [
"1159",
"/11[6-9][0-9]/",
"/120[0-9]/",
"/121[0-2]/",
],
}
}
"__urls": [
"https://some_novel_site/my_novel/chapter_*",
"https://another_source_with_novel/chapt*"
]
}
}
Script recursively look in each node {}
.
If it see __urls
and they passed - it started to collect replacements in that node.
You can add __urls
in any subnode too.
If they not passed - that subnode would be ignored.
Usefull for specific chapters of book/ pages, check example.
use *
, it solves 99% cases
https://tw.wa01.com/novel/pagea/lunhuileyuan-nayizhiwenzi_*
if you really have *
in your url (some extreme cases) - then escape it \\*
https://tw.wa01.com/novel/\\*/lunhuileyuan-nayizhiwenzi_*
/
/lunhuileyuan-nayizhiwenzi_.*/
[]^&$.()?/\+{}|*
with \\
https:\\/\\/tw\\.wa01\\.com\\/novel\\/pagea\\/lunhuileyuan-nayizhiwenzi_
/https:\\/\\/tw\\.wa01\\.com\\/novel\\/pagea\\/lunhuileyuan-nayizhiwenzi_/
/https:\\/\\/tw\\.wa01\\.com\\/novel\\/pagea\\/lunhuileyuan-nayizhiwenzi_.+/
[1][0-9]
- chapters 10 - 19/https:\\/\\/tw\\.wa01\\.com\\/novel\\/pagea\\/lunhuileyuan-nayizhiwenzi_[1][0-9]/
example:
{
"commonA": {...},
"commonB": {...},
"Book1": {
...
"__include": {
"smth_name": "commonA",
"blockB": "commonB",
"engeneer terms": "https://some_server/engeneer_terms.json"
}
},
"news_portal": {
...
"__include": {"commonA": "commonA"}
}
}
As you see - it allows to include outer nodes or even load other jsons.
Firstly script recursively check all nodes
and collect all names on all depth like "name": {...}
Later script just insert in node with __include
all data by aliases
Example:
json by url1
{"x": "y", "z": {"a": "b"}} // url json
{
"commonA": {"nodeA": {"n": "m"}},
"ExampleNode": {
...
"__include": {
"alias1": "nodeA",
"engeneer_terms": "url1",
}
}
}
ExampleNode
converted to
{
...
"ExampleNode": {
...
"alias1": {"n": "m"},
"engeneer_terms": {"x": "y", "z": {"a": "b"}},
"__include": {...},
}
}
As earlier was mentioned - script build simple array from json
arr = [
["a1", "b1"],
["a2", "b2"],
["a3", "b3"],
]
and apply replacements in same order
Example:
text = "xxAAxx"
json = {"A": "B", "AA": "CC"}
replacements = [
["A", "B"],
["AA", "CC"],
]
we expect xxCCxx
basically result would be xxBBxx
But this problem is solved.
json
[
...,
->
["A", "B"],
...,
]
Problem But regular expressions can't be auto checked.
{
"100": "hundred",
"/o\d/": "0$1",
}
we expected "1o0" -> "hundred"
but if replacements collected in wrong order (which json not guaranteed)
replacements = [
["100", "hundred"],
["/o\d/", "o$1"],
]
here __level comes
{
"100": "hundred",
fixes: {
"/o\d/": "0$1",
"__level": 0,
}
}
Example:
{
"first_order_fixes": {
...,
"__level": 0,
},
...
"source_which_override_mine_replacements": {
"__include": {
"fiction terms": "some_url",
}
"__level": 2,
}
}
__level
allow you to solve problems with order
Default level set in javascript config:
let config = {
...
"default_priority_level": 1,
}
All replacements collected independently by this levels.
let arr = [
"-10": [['a1', 'a2'], ['a3', 'a4'], ...]
"0": [['b1', 'b2'], ['b3', 'b4'], ...]
"1": [['c1', 'c2'], ['c3', 'c4'], ...]
"5": [['d', 'd2'], ['d3', 'd4'], ...]
]
Autoorder, checking same key - works only on the same lvl
Finally they squashed in one array, ordered by levels
[
'a1','a2',
...,
'b1','b2',
...,
'd1','d2',
...
]
Inheriting
Level is inherited by child nodes.
Here is example.
{
"a1": "a2", // default level 1
"a": {
"b1": "b2" // level 1
"b": {
"c1": "c2", // level -100
"c": {
"d1": "d2", // level -100
"d": {
"e1": "e2", // level 5
"f": {
"f1": f2, // level 5
}
"__level": 5
}
}
"__level": -100
}
},
"x": {
"x1": "x2", // level 3
"__level": 3
}
}
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址