0

我给魔电官网的文档做了一个中文化的油猴脚本,只是代码太简陋,并且运行效率低下,导致打开时需要等待好久,请教大神们有没有什么办法可以优化一下这个脚本

// ==UserScript==
// @name         魔电官网文档中文化
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  实用工具
// @author       黑本
// @match        https://docs.median-xl.com/doc/items/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
//符文
    document.body.innerHTML = document.body.innerHTML.replace(/El Rune/g, '1# El');
    document.body.innerHTML = document.body.innerHTML.replace(/Eld Rune/g, '2# Eld');
    document.body.innerHTML = document.body.innerHTML.replace(/Tir Rune/g, '3# Tir');
    document.body.innerHTML = document.body.innerHTML.replace(/Nef Rune/g, '4# Nef');
    document.body.innerHTML = document.body.innerHTML.replace(/Eth Rune/g, '5# Eth');
    document.body.innerHTML = document.body.innerHTML.replace(/Ith Rune/g, '6# Ith');
    document.body.innerHTML = document.body.innerHTML.replace(/Tal Rune/g, '7# Tal');
    document.body.innerHTML = document.body.innerHTML.replace(/Ral Rune/g, '8# Ral');
    document.body.innerHTML = document.body.innerHTML.replace(/Ort Rune/g, '9# Ort');
    document.body.innerHTML = document.body.innerHTML.replace(/Thul Rune/g, '10# Thul');
    document.body.innerHTML = document.body.innerHTML.replace(/Amn Rune/g, '11# Amn');
    document.body.innerHTML = document.body.innerHTML.replace(/Sol Rune/g, '12# Sol');
    document.body.innerHTML = document.body.innerHTML.replace(/Shael Rune/g, '13# Shael');
    document.body.innerHTML = document.body.innerHTML.replace(/Dol Rune/g, '14# Dol');
    document.body.innerHTML = document.body.innerHTML.replace(/Hel Rune/g, '15# Hel');
    document.body.innerHTML = document.body.innerHTML.replace(/Io Rune/g, '16# Io');
    document.body.innerHTML = document.body.innerHTML.replace(/Lum Rune/g, '17# Lum');
    document.body.innerHTML = document.body.innerHTML.replace(/Ko Rune/g, '18# Ko');
    document.body.innerHTML = document.body.innerHTML.replace(/Fal Rune/g, '19# Fal');
    document.body.innerHTML = document.body.innerHTML.replace(/Lem Rune/g, '20# Lem');
    document.body.innerHTML = document.body.innerHTML.replace(/Pul Rune/g, '21# Pul');
    document.body.innerHTML = document.body.innerHTML.replace(/Um Rune/g, '22# Um');
    document.body.innerHTML = document.body.innerHTML.replace(/Mal Rune/g, '23# Mal');
    document.body.innerHTML = document.body.innerHTML.replace(/Ist Rune/g, '24# Ist');
    document.body.innerHTML = document.body.innerHTML.replace(/Gul Rune/g, '25# Gul');
    document.body.innerHTML = document.body.innerHTML.replace(/Vex Rune/g, '26# Vex');
    document.body.innerHTML = document.body.innerHTML.replace(/Ohm Rune/g, '27# Ohm');
    document.body.innerHTML = document.body.innerHTML.replace(/Lo Rune/g, '28# Lo');
    document.body.innerHTML = document.body.innerHTML.replace(/Sur Rune/g, '29# Sur');
    document.body.innerHTML = document.body.innerHTML.replace(/Ber Rune/g, '30# Ber');
    document.body.innerHTML = document.body.innerHTML.replace(/Jah Rune/g, '31# Jah');
    document.body.innerHTML = document.body.innerHTML.replace(/Cham Rune/g, '32# Cham');
    document.body.innerHTML = document.body.innerHTML.replace(/Zod Rune/g, '33# Zod');
    document.body.innerHTML = document.body.innerHTML.replace(/Sha Rune/g, '34# Sha');
    document.body.innerHTML = document.body.innerHTML.replace(/Lah Rune/g, '35# Lah');
    document.body.innerHTML = document.body.innerHTML.replace(/Kur Rune/g, '36# Kur');
    document.body.innerHTML = document.body.innerHTML.replace(/Ix Rune/g, '37# Ix');
    document.body.innerHTML = document.body.innerHTML.replace(/Thur Rune/g, '38# Thur');
    document.body.innerHTML = document.body.innerHTML.replace(/Nas Rune/g, '39# Nas');
    document.body.innerHTML = document.body.innerHTML.replace(/Ath Rune/g, '40# Ath');
    document.body.innerHTML = document.body.innerHTML.replace(/Kra Rune/g, '41# Kra');
    document.body.innerHTML = document.body.innerHTML.replace(/Vith Rune/g, '42# Vith');
    document.body.innerHTML = document.body.innerHTML.replace(/No Rune/g, '43# No');
    document.body.innerHTML = document.body.innerHTML.replace(/Yul Rune/g, '44# Yul');
    document.body.innerHTML = document.body.innerHTML.replace(/Thai Rune/g, '45# Thai');
    document.body.innerHTML = document.body.innerHTML.replace(/Rha Rune/g, '46# Rha');
    document.body.innerHTML = document.body.innerHTML.replace(/Xar Rune/g, '47# Xar');
    document.body.innerHTML = document.body.innerHTML.replace(/Nih Rune/g, '48# Nih');
    document.body.innerHTML = document.body.innerHTML.replace(/Lai Rune/g, '49# Lai');
    document.body.innerHTML = document.body.innerHTML.replace(/On Rune/g, '50# On');
    document.body.innerHTML = document.body.innerHTML.replace(/Taha Rune/g, '51# Taha');
    document.body.innerHTML = document.body.innerHTML.replace(/Ghal Rune/g, '52# Ghal');
    document.body.innerHTML = document.body.innerHTML.replace(/Qor Rune/g, '53# Qor');
    document.body.innerHTML = document.body.innerHTML.replace(/Krys Rune/g, '54# Krys');
    document.body.innerHTML = document.body.innerHTML.replace(/Auhe Rune/g, '55# Auhe');
    document.body.innerHTML = document.body.innerHTML.replace(/Shaad Rune/g, '56# Shaad');
    document.body.innerHTML = document.body.innerHTML.replace(/Ma Rune/g, '魔法符文');
    document.body.innerHTML = document.body.innerHTML.replace(/Po Rune/g, '毒素符文');
    document.body.innerHTML = document.body.innerHTML.replace(/Fi Rune/g, '火焰符文');
    document.body.innerHTML = document.body.innerHTML.replace(/Ea Rune/g, '大地符文');
    document.body.innerHTML = document.body.innerHTML.replace(/Co Rune/g, '寒冰符文');
    document.body.innerHTML = document.body.innerHTML.replace(/Li Rune/g, '闪电符文');
    document.body.innerHTML = document.body.innerHTML.replace(/Xis Rune/g, '卡布符文');

//装备
    document.body.innerHTML = document.body.innerHTML.replace(/Weapons<br>/g, '武器<br>');
    document.body.innerHTML = document.body.innerHTML.replace(/Throwing Knives/g, '飞刀');
    document.body.innerHTML = document.body.innerHTML.replace(/Necromancer Scythes/g, '死灵法师专属镰刀');
    document.body.innerHTML = document.body.innerHTML.replace(/Throwing Axes/g, '飞斧');
    document.body.innerHTML = document.body.innerHTML.replace(/Amazon Spears/g, '亚马逊专属矛');
    document.body.innerHTML = document.body.innerHTML.replace(/Paladin Spears/g, '圣骑士专属矛');
    document.body.innerHTML = document.body.innerHTML.replace(/Paladin Clubs, Paladin Maces, Paladin Hammers/g, '圣骑士专属棍,棒,锤');
    document.body.innerHTML = document.body.innerHTML.replace(/Spears/g, '长矛');
    document.body.innerHTML = document.body.innerHTML.replace(/Sorceress Orbs/g, '法师单手法球');
    document.body.innerHTML = document.body.innerHTML.replace(/Sorceress Crystal Swords/g, '扭曲之刃(法师)');
    document.body.innerHTML = document.body.innerHTML.replace(/Sorceress Body Armor/g, '法师专属衣服');
    document.body.innerHTML = document.body.innerHTML.replace(/Paladin Shields/g, '圣骑士专属盾');
    document.body.innerHTML = document.body.innerHTML.replace(/Barbarian Shields/g, '野蛮人专属盾');
    document.body.innerHTML = document.body.innerHTML.replace(/Assassin Shields/g, '刺客专属盾');
    document.body.innerHTML = document.body.innerHTML.replace(/Necromancer Shields/g, '死灵法师专属盾');
    document.body.innerHTML = document.body.innerHTML.replace(/Amazon Shields/g, '亚马逊专属盾');
    document.body.innerHTML = document.body.innerHTML.replace(/Scythes/g, '镰刀');
    document.body.innerHTML = document.body.innerHTML.replace(/Sceptres/g, '权杖');
    document.body.innerHTML = document.body.innerHTML.replace(/Paladin Helms/g, '圣骑士专属头盔');
    document.body.innerHTML = document.body.innerHTML.replace(/Paladin Clubs, Paladin Maces, Paladin Hammers/g, '圣骑士专属钝器');
    document.body.innerHTML = document.body.innerHTML.replace(/Barbarian Swords/g, '野蛮人专属剑');
    document.body.innerHTML = document.body.innerHTML.replace(/Barbarian One-Handed Axes/g, '野蛮人单手斧');
    document.body.innerHTML = document.body.innerHTML.replace(/Barbarian Two-Handed Axes/g, '野蛮人双手斧');
    document.body.innerHTML = document.body.innerHTML.replace(/One-Handed Swords/g, '单手剑');
    document.body.innerHTML = document.body.innerHTML.replace(/One-Handed Axes/g, '单手斧');
    document.body.innerHTML = document.body.innerHTML.replace(/Necromancer Wands/g, '死灵法师单手短杖');
    document.body.innerHTML = document.body.innerHTML.replace(/Necromancer Staves/g, '死灵法师双手长杖');
    document.body.innerHTML = document.body.innerHTML.replace(/Necromancer Daggers/g, '死灵法师专属匕首');
    document.body.innerHTML = document.body.innerHTML.replace(/Necromancer Crossbows/g, '死灵法师专属十字弓');
    document.body.innerHTML = document.body.innerHTML.replace(/Druid Staves/g, '德鲁伊专属法杖');
    document.body.innerHTML = document.body.innerHTML.replace(/Druid Helms/g, '德鲁伊专属头盔');
    document.body.innerHTML = document.body.innerHTML.replace(/Maces/g, '钉锤(棍棒顶端圆形发展 偏小)');
    document.body.innerHTML = document.body.innerHTML.replace(/Hammers/g, '锤子(顶端为横向发展 偏大)');
    document.body.innerHTML = document.body.innerHTML.replace(/Amazon Javelins/g, '亚马逊专属标枪');
    document.body.innerHTML = document.body.innerHTML.replace(/Javelins/g, '标枪');
    document.body.innerHTML = document.body.innerHTML.replace(/Barbarian Helms/g, '野蛮人头盔');
    document.body.innerHTML = document.body.innerHTML.replace(/Staves/g, '长柄法杖');
    document.body.innerHTML = document.body.innerHTML.replace(/Crossbows/g, '十字弓');
    document.body.innerHTML = document.body.innerHTML.replace(/Druid Bows/g, '德鲁伊专属弓');
    document.body.innerHTML = document.body.innerHTML.replace(/Amazon Bows/g, '亚马逊专属弓');
    document.body.innerHTML = document.body.innerHTML.replace(/Amazon Helms/g, '亚马逊专属头盔');
    document.body.innerHTML = document.body.innerHTML.replace(/Bows/g, '弓');
    document.body.innerHTML = document.body.innerHTML.replace(/Daggers/g, '匕首');
    document.body.innerHTML = document.body.innerHTML.replace(/Assassin Claws/g, '刺客爪');
    document.body.innerHTML = document.body.innerHTML.replace(/Assassin Naginatas/g, '眉间刀(刺客)');
    document.body.innerHTML = document.body.innerHTML.replace(/Body Armor/g, '衣服');
    document.body.innerHTML = document.body.innerHTML.replace(/Circlets/g, '头环');
    document.body.innerHTML = document.body.innerHTML.replace(/Shields/g, '盾牌');
    document.body.innerHTML = document.body.innerHTML.replace(/Belts/g, '腰带');
    document.body.innerHTML = document.body.innerHTML.replace(/Boots/g, '鞋子');
    document.body.innerHTML = document.body.innerHTML.replace(/Helms/g, '头盔');
    document.body.innerHTML = document.body.innerHTML.replace(/Gloves/g, '手套');












    //装备属性词条
    document.body.innerHTML = document.body.innerHTML.replace(/ Chance to cast level /g, ' 的机会施展等级 ');
    document.body.innerHTML = document.body.innerHTML.replace(/ Hit Recovery/g, ' 快速打击恢复(FHR)');
    document.body.innerHTML = document.body.innerHTML.replace(/ Block Speed/g, ' 格挡速度(FBR)');
    document.body.innerHTML = document.body.innerHTML.replace(/ on Kill/g, ' 当杀死怪物');
    document.body.innerHTML = document.body.innerHTML.replace(/ Enhanced damage/g, ' 增强伤害(ED)');
    document.body.innerHTML = document.body.innerHTML.replace(/ Bonus to Attack Rating/g, ' 额外准确率(AR)');
    document.body.innerHTML = document.body.innerHTML.replace(/ to All Attributes/g, ' 所有属性');
    document.body.innerHTML = document.body.innerHTML.replace(/ Gold Find/g, ' 更多金币');
    document.body.innerHTML = document.body.innerHTML.replace(/ to Light Radius/g, ' 照亮范围');
    document.body.innerHTML = document.body.innerHTML.replace(/ Bonus Damage to/g, ' 更多伤害');
    document.body.innerHTML = document.body.innerHTML.replace(/ Attack Speed/g, ' 增加攻速(IAS)');
    document.body.innerHTML = document.body.innerHTML.replace(/Adds /g, '增加 ');
    document.body.innerHTML = document.body.innerHTML.replace(/ cold damage/g, ' 的冰冷伤害');
    document.body.innerHTML = document.body.innerHTML.replace(/ poison damage/g, ' 的毒素伤害');
    document.body.innerHTML = document.body.innerHTML.replace(/ fire damage/g, ' 的火焰伤害');
    document.body.innerHTML = document.body.innerHTML.replace(/ lightning damage/g, ' 的闪电伤害');
    document.body.innerHTML = document.body.innerHTML.replace(/ magic damage/g, ' 的魔法伤害');
    document.body.innerHTML = document.body.innerHTML.replace(/ damage/g, ' 的伤害');
    document.body.innerHTML = document.body.innerHTML.replace(/ to Maximum Damage/g, ' 最大伤害');
    document.body.innerHTML = document.body.innerHTML.replace(/Based on Character Level/g, '基于角色等级');
    document.body.innerHTML = document.body.innerHTML.replace(/ to all Attributes/g, ' 至所有属性');
    document.body.innerHTML = document.body.innerHTML.replace(/ to Mana Sweep/g, ' 法力扫荡');
    document.body.innerHTML = document.body.innerHTML.replace(/ to Mana Tide Totem/g, '法力潮汐图腾');
    document.body.innerHTML = document.body.innerHTML.replace(/ to Mana/g, ' 法力值');
    document.body.innerHTML = document.body.innerHTML.replace(/ on Melee Attack/g, ' 当近战攻击时');
    document.body.innerHTML = document.body.innerHTML.replace(/ to All Skills/g, ' 所有技能');
    document.body.innerHTML = document.body.innerHTML.replace(/ to Minimum Damage/g, ' 最小伤害');
    document.body.innerHTML = document.body.innerHTML.replace(/Stun Attack/g, '晕眩攻击');
    document.body.innerHTML = document.body.innerHTML.replace(/ to Summoned Minion Life/g, '召唤物生命');
    document.body.innerHTML = document.body.innerHTML.replace(/ to Strength/g, ' 力量');
    document.body.innerHTML = document.body.innerHTML.replace(/ Bonus to Energy Factor/g, ' 增加精力因子');
    document.body.innerHTML = document.body.innerHTML.replace(/ to Energy/g, ' 精力');
    document.body.innerHTML = document.body.innerHTML.replace(/ to Dexterity/g, ' 敏捷');
    document.body.innerHTML = document.body.innerHTML.replace(/ Reanimate as/g, ' 复活为');
    document.body.innerHTML = document.body.innerHTML.replace(/ Cast Speed/g, ' 快速施法(FCR)');
    document.body.innerHTML = document.body.innerHTML.replace(/ Life stolen per Hit/g, ' 生命偷取(LL)');
    document.body.innerHTML = document.body.innerHTML.replace(/ Mana stolen per Hit/g, '法力偷取(LM)');
    document.body.innerHTML = document.body.innerHTML.replace(/ to Life/g, ' 生命值');
    document.body.innerHTML = document.body.innerHTML.replace(/Maximum Fire Resist /g, '最大火焰抗性 ');
    document.body.innerHTML = document.body.innerHTML.replace(/Maximum Cold Resist /g, '最大冰冷抗性 ');
    document.body.innerHTML = document.body.innerHTML.replace(/Maximum Lightning Resist /g, '最大闪电抗性 ');
    document.body.innerHTML = document.body.innerHTML.replace(/Maximum Poison Resist /g, '最大毒素抗性 ');
    document.body.innerHTML = document.body.innerHTML.replace(/Fire Resist /g, '火焰抗性(fr)');
    document.body.innerHTML = document.body.innerHTML.replace(/Slow Target /g, '减慢目标');
    document.body.innerHTML = document.body.innerHTML.replace(/Cold Resist /g, '冰冷抗性(cr)');
    document.body.innerHTML = document.body.innerHTML.replace(/Lightning Resist /g, '闪电抗性(lr)');
    document.body.innerHTML = document.body.innerHTML.replace(/Poison Resist /g, '毒素抗性(lr)');
    document.body.innerHTML = document.body.innerHTML.replace(/Physical Resist /g, '物理抗性 ');
    document.body.innerHTML = document.body.innerHTML.replace(/Physical Damage Reduced by /g, '物理伤害降低(dr) ');
    document.body.innerHTML = document.body.innerHTML.replace(/ to Poison Spell Damage/g, ' 至毒素法术伤害');
    document.body.innerHTML = document.body.innerHTML.replace(/ to Lightning Spell Damage/g, ' 至闪电法术伤害');
    document.body.innerHTML = document.body.innerHTML.replace(/ to Cold Spell Damage/g, ' 至冰冷法术伤害');
    document.body.innerHTML = document.body.innerHTML.replace(/ to Fire Spell Damage/g, ' 至火焰法术伤害');
    document.body.innerHTML = document.body.innerHTML.replace(/ to Physical\/Magic Spell Damage/g, ' 至物理/魔法伤害');
    document.body.innerHTML = document.body.innerHTML.replace(/ Energy Factor to Spell Damage/g, ' 法力因子至法术伤害');
    document.body.innerHTML = document.body.innerHTML.replace(/ to Spell Damage/g, ' 至所有法术伤害');
    document.body.innerHTML = document.body.innerHTML.replace(/ Chance of Crushing Blow/g, ' 压碎性打击(CB)');
    document.body.innerHTML = document.body.innerHTML.replace(/ Charges/g, ' 聚气');
    document.body.innerHTML = document.body.innerHTML.replace(/ Combat Speeds/g, ' 所有战斗速度');
    document.body.innerHTML = document.body.innerHTML.replace(/ Increased Healing Rate from Apples/g, '增加食用苹果的恢复效率');
    document.body.innerHTML = document.body.innerHTML.replace(/ Chance of Uninterruptable Attack/g, ' 不间断攻击(UA)');
    document.body.innerHTML = document.body.innerHTML.replace(/Total Character Defense /g, '角色整体防御 ');
    document.body.innerHTML = document.body.innerHTML.replace(/ to Enemy Cold Resistance/g, ' 敌人冰冷抗性');
    document.body.innerHTML = document.body.innerHTML.replace(/ to Enemy Poison Resistance/g, ' 敌人毒素抗性');
    document.body.innerHTML = document.body.innerHTML.replace(/ to Enemy Fire Resistance/g, ' 敌人火焰抗性');
    document.body.innerHTML = document.body.innerHTML.replace(/ to Enemy Lightning Resistance/g, ' 敌人冰冷抗性');
    document.body.innerHTML = document.body.innerHTML.replace(/Increase Maximum Life and Mana /g, '增加最大生命和法力值 ');
    document.body.innerHTML = document.body.innerHTML.replace(/Requirements /g, '需求 ');
    document.body.innerHTML = document.body.innerHTML.replace(/ Damage to Demons/g, ' 对恶魔的伤害(DTD)');
    document.body.innerHTML = document.body.innerHTML.replace(/ Life Regenerated per Second/g, ' 每秒生命恢复');
    document.body.innerHTML = document.body.innerHTML.replace(/ Life on Striking/g, ' 击中时恢复生命');
    document.body.innerHTML = document.body.innerHTML.replace(/ Mana on Striking/g, ' 击中时恢复法力');
    document.body.innerHTML = document.body.innerHTML.replace(/ Life on Attack/g, '打击时恢复生命');
    document.body.innerHTML = document.body.innerHTML.replace(/ Life after each Kill/g, '杀死怪物获取生命(LAEK)');
    document.body.innerHTML = document.body.innerHTML.replace(/ Mana after each Kill/g, '杀死怪物获取法力(MAEK)');
    document.body.innerHTML = document.body.innerHTML.replace(/Target Takes Additional Damage of /g, '目标受到额外伤害 ');
    document.body.innerHTML = document.body.innerHTML.replace(/Indestructible/g, '无法破坏');
    document.body.innerHTML = document.body.innerHTML.replace(/ Movement Speed/g, ' 移动速度');
    document.body.innerHTML = document.body.innerHTML.replace(/ Magic Find/g, ' 魔法物品获取(MF)');
    document.body.innerHTML = document.body.innerHTML.replace(/Enhanced Weapon Damage /g, '增强武器伤害 ');
    document.body.innerHTML = document.body.innerHTML.replace(/ to Vitality/g, ' 体力');
    document.body.innerHTML = document.body.innerHTML.replace(/Hit Causes Monster to Flee /g, '击中使怪物逃跑');
    document.body.innerHTML = document.body.innerHTML.replace(/Attacker Flees after Striking /g, '受到打击时恐吓怪物');
    document.body.innerHTML = document.body.innerHTML.replace(/Half Freeze Duration/g, '冰冻时间减半');
    document.body.innerHTML = document.body.innerHTML.replace(/Cannot Be Frozen/g, '无法冰冻');
    document.body.innerHTML = document.body.innerHTML.replace(/Maximum Mana /g, '增加法力值 ');
    document.body.innerHTML = document.body.innerHTML.replace(/Maximum Life /g, '增加生命值 ');
    document.body.innerHTML = document.body.innerHTML.replace(/Regenerate Mana /g, '法力恢复速度 ');
    document.body.innerHTML = document.body.innerHTML.replace(/ Bonus to Buff\/Debuff\/Cold Skill Duration/g, '延长Buff/Debuff/冰冻技能的效果时间');
    document.body.innerHTML = document.body.innerHTML.replace(/ Energy Factor to Spell Damage/g, ' 精力因子至法术伤害');
    document.body.innerHTML = document.body.innerHTML.replace(/ to Enemy Elemental Resistances/g, ' 敌人元素抗性');
    document.body.innerHTML = document.body.innerHTML.replace(/Maximum Elemental Resists/g, '最大元素抗性');
    document.body.innerHTML = document.body.innerHTML.replace(/Elemental Resists /g, '元素抗性 ');
    document.body.innerHTML = document.body.innerHTML.replace(/ Deadly Strike/g, ' 致命一击(DS)');
    document.body.innerHTML = document.body.innerHTML.replace(/ to Summoned Minion Resistances/g, ' 召唤物抗性');
    document.body.innerHTML = document.body.innerHTML.replace(/ to Summoned Minion Damage/g, '召唤物伤害');
    document.body.innerHTML = document.body.innerHTML.replace(/ to Summoned Minion Attack Rating/g, '召唤物准确率');
    document.body.innerHTML = document.body.innerHTML.replace(/ to Maximum Barbarian Minions/g, ' 野蛮人召唤物数量');
    document.body.innerHTML = document.body.innerHTML.replace(/ to Maximum Necromancer Minions/g, '死灵法师召唤物数量');
    document.body.innerHTML = document.body.innerHTML.replace(/ Damage to Undead/g, '对不死生物的伤害(DTU)');
    document.body.innerHTML = document.body.innerHTML.replace(/ Defense vs. Missile/g, '对飞弹的防御');
    document.body.innerHTML = document.body.innerHTML.replace(/Ignore Target's Defense/g, '忽视目标防御');
    document.body.innerHTML = document.body.innerHTML.replace(/ Enhanced Defense/g, '增强防御');
    document.body.innerHTML = document.body.innerHTML.replace(/ Defense/g, ' 防御值');
    document.body.innerHTML = document.body.innerHTML.replace(/ Skill Levels/g, '技能等级');
    document.body.innerHTML = document.body.innerHTML.replace(/ to Druid/g, ' 德鲁伊');
    document.body.innerHTML = document.body.innerHTML.replace(/ to Assassin/g, ' 刺客');
    document.body.innerHTML = document.body.innerHTML.replace(/ to Barbarian/g, ' 野蛮人');
    document.body.innerHTML = document.body.innerHTML.replace(/ to Amazon/g, ' 亚马逊');
    document.body.innerHTML = document.body.innerHTML.replace(/ to Sorceress/g, ' 法师');
    document.body.innerHTML = document.body.innerHTML.replace(/ to Necromancer/g, ' 死灵法师');
    document.body.innerHTML = document.body.innerHTML.replace(/ to Paladin/g, ' 圣骑士');
    document.body.innerHTML = document.body.innerHTML.replace(/Amazon Only/g, '限亚马逊');
    document.body.innerHTML = document.body.innerHTML.replace(/Druid Only/g, '限德鲁伊');
    document.body.innerHTML = document.body.innerHTML.replace(/Assassin Only/g, '限刺客');
    document.body.innerHTML = document.body.innerHTML.replace(/Barbarian Only/g, '限野蛮人');
    document.body.innerHTML = document.body.innerHTML.replace(/Sorceress Only/g, '限法师');
    document.body.innerHTML = document.body.innerHTML.replace(/Necromancer Only/g, '限死灵法师');
    document.body.innerHTML = document.body.innerHTML.replace(/Paladin Only/g, '限圣骑士');
    document.body.innerHTML = document.body.innerHTML.replace(/ over 1 seconds/g, '在1秒内');
    document.body.innerHTML = document.body.innerHTML.replace(/ to Experience Gained/g, '经验获取');
    document.body.innerHTML = document.body.innerHTML.replace(/ Life when Struck by an Enemy/g, '生命受打击时');
    document.body.innerHTML = document.body.innerHTML.replace(/Mana when Struck by an Enemy/g, '法力受打击时');
    document.body.innerHTML = document.body.innerHTML.replace(/ on Striking/g, '在打击时');
    document.body.innerHTML = document.body.innerHTML.replace(/ when Struck/g, ' 受到打击时');
    document.body.innerHTML = document.body.innerHTML.replace(/ when Attacked/g, ' 当击中时');
    document.body.innerHTML = document.body.innerHTML.replace(/Slows Attacker by /g, ' 减慢攻击者 ');
    document.body.innerHTML = document.body.innerHTML.replace(/Slows Ranged Attacker by /g, '减慢远程攻击者 ');
    document.body.innerHTML = document.body.innerHTML.replace(/Slows Melee Target by /g, '减慢近战目标 ');
    document.body.innerHTML = document.body.innerHTML.replace(/ Damage to The Zakarum/g, ' 对萨卡兰姆的伤害(DTZ)');
    document.body.innerHTML = document.body.innerHTML.replace(/Attacker Takes Cold Damage of /g, '攻击者受到冰冷伤害 ');
    document.body.innerHTML = document.body.innerHTML.replace(/Attacker Takes Fire Damage of /g, '攻击者受到火焰伤害');
    document.body.innerHTML = document.body.innerHTML.replace(/ Bonus Elemental Damage to Bloodlust/g, ' 增加嗜血的元素伤害');
    document.body.innerHTML = document.body.innerHTML.replace(/You may Only use Melee, Summon and Support Skills/g, '仅可使用近战,召唤和支援技能');
    document.body.innerHTML = document.body.innerHTML.replace(/ Base Block Chance/g, '基础格挡值');
    document.body.innerHTML = document.body.innerHTML.replace(/ Bonus to Poison Skill Duration/g, ' 增加毒素技能持续时间');
    document.body.innerHTML = document.body.innerHTML.replace(/Poison Length Reduced by /g, '中毒时间减少 ');
    document.body.innerHTML = document.body.innerHTML.replace(/Lion Stance Damage Bonus /g, '狮子姿态伤害增加 ');
    document.body.innerHTML = document.body.innerHTML.replace(/ Slower Block Rate/g, '降低格挡速度');
    document.body.innerHTML = document.body.innerHTML.replace(/Cold Absorb /g, '冰冷吸收');
    document.body.innerHTML = document.body.innerHTML.replace(/Fire Absorb /g, '火焰吸收');
    document.body.innerHTML = document.body.innerHTML.replace(/Lightning Absorb /g, '闪电吸收');
    document.body.innerHTML = document.body.innerHTML.replace(/Poison Absorb /g, '毒素吸收');
    document.body.innerHTML = document.body.innerHTML.replace(/ Chance to Avoid Damage/g, ' 躲避伤害');
    document.body.innerHTML = document.body.innerHTML.replace(/Druid Morph/g, '德鲁伊形态');
    document.body.innerHTML = document.body.innerHTML.replace(/Based on Blessed Life Skill Level/g, '基于 Blessed Life 的等级');
    document.body.innerHTML = document.body.innerHTML.replace(/ when using an Apple/g, ' 当食用苹果时');
    document.body.innerHTML = document.body.innerHTML.replace(/ Damage Taken Goes To Mana/g, ' 受到伤害转化为法力');
    document.body.innerHTML = document.body.innerHTML.replace(/Attacker Takes Elemental Damage of /g, '攻击者受到元素伤害 ');

    //技能
    document.body.innerHTML = document.body.innerHTML.replace(/ to Divine Apparition/g, 'Divine Apparition(神圣显现,3秒一次带冰冻的瞬移)');
    document.body.innerHTML = document.body.innerHTML.replace(/ Mark of the Wild/g, '野性印记');
    document.body.innerHTML = document.body.innerHTML.replace(/ to Hamstring/g, '断筋(Hamstring)');



//其他
    document.body.innerHTML = document.body.innerHTML.replace(/Many runewords contain only one rune, but you can fill up the sockets /g, '许多神符之语仅需要一枚符文,但是你需要在镶嵌这枚符文');
    document.body.innerHTML = document.body.innerHTML.replace(/before/g, '之前');
    document.body.innerHTML = document.body.innerHTML.replace(/ the rune with jewels. To make a runeword in an item with 4 sockets, for example,/g, '用珠宝填满前面的孔,举个栗子,有一件装备有4个孔');
    document.body.innerHTML = document.body.innerHTML.replace(/you must/g, '你必须按顺序');
    document.body.innerHTML = document.body.innerHTML.replace(/ insert 3 jewels \+ 1 rune/g, '镶嵌 3枚珠宝和1枚符文');
    document.body.innerHTML = document.body.innerHTML.replace(/Grey items only!/g, '只能用于灰色装备!');
    document.body.innerHTML = document.body.innerHTML.replace(/Some people do not seem to know this. You can only make runewords in nonmagical socketed \(grey\) items!/g, '很多人看来不知道,你只能在普通带孔装备(灰色)上装备神符之语!');

    document.body.innerHTML = document.body.innerHTML.replace(/ contains 537 all-new runewords./g, ' 包含了 537 个全新的神符之语');
    document.body.innerHTML = document.body.innerHTML.replace(/LIST OF RUNEWORDS/g, '神符之语列表');
    document.body.innerHTML = document.body.innerHTML.replace(/RUNEWORDS/g, '神符之语');
    document.body.innerHTML = document.body.innerHTML.replace(/except /g, '除了 ');
    document.body.innerHTML = document.body.innerHTML.replace(/Cannot be Unsocketed/g, '无法取出镶嵌物');


})();

脚本适配页面链接
萌新求大神指导。

hibem 3
5月15日提问

查看全部 5 个回答

2
  1. 可以考虑document.body.innerHTML只获取一次,所有的都替换完了,再统一更新document.body而不是替换一个更新一个
  2. 将脚本放在文档最后加载</body>前后,而不是再文档开头 不要影响原页面的效果渲染

    (function () {
        'use strict';
        //符文
        document.body.innerHTML = document.body.innerHTML.replace(/El Rune/g, '1# El')
        .replace(/Eld Rune/g, '2# Eld')
        .replace(/Tir Rune/g, '3# Tir')
        .replace(/Nef Rune/g, '4# Nef')
        .replace(/Eth Rune/g, '5# Eth')
        .replace(/Ith Rune/g, '6# Ith')
        .replace(/Tal Rune/g, '7# Tal')
        .replace(/Ral Rune/g, '8# Ral')
        .replace(/Ort Rune/g, '9# Ort')
        .replace(/Thul Rune/g, '10# Thul')
        .replace(/Amn Rune/g, '11# Amn')
        .replace(/Sol Rune/g, '12# Sol')
        .replace(/Shael Rune/g, '13# Shael')
        .replace(/Dol Rune/g, '14# Dol')
        .replace(/Hel Rune/g, '15# Hel')
        .replace(/Io Rune/g, '16# Io')
        .replace(/Lum Rune/g, '17# Lum')
        .replace(/Ko Rune/g, '18# Ko')
        .replace(/Fal Rune/g, '19# Fal')
        .replace(/Lem Rune/g, '20# Lem')
        .replace(/Pul Rune/g, '21# Pul')
        .replace(/Um Rune/g, '22# Um')
        .replace(/Mal Rune/g, '23# Mal')
        .replace(/Ist Rune/g, '24# Ist')
        .replace(/Gul Rune/g, '25# Gul')
        .replace(/Vex Rune/g, '26# Vex')
        .replace(/Ohm Rune/g, '27# Ohm')
        .replace(/Lo Rune/g, '28# Lo')
        .replace(/Sur Rune/g, '29# Sur')
        .replace(/Ber Rune/g, '30# Ber')
        .replace(/Jah Rune/g, '31# Jah')
        .replace(/Cham Rune/g, '32# Cham')
        .replace(/Zod Rune/g, '33# Zod')
        .replace(/Sha Rune/g, '34# Sha')
        .replace(/Lah Rune/g, '35# Lah')
        .replace(/Kur Rune/g, '36# Kur')
        .replace(/Ix Rune/g, '37# Ix')
        .replace(/Thur Rune/g, '38# Thur')
        .replace(/Nas Rune/g, '39# Nas')
        .replace(/Ath Rune/g, '40# Ath')
        .replace(/Kra Rune/g, '41# Kra')
        .replace(/Vith Rune/g, '42# Vith')
        .replace(/No Rune/g, '43# No')
        .replace(/Yul Rune/g, '44# Yul')
        .replace(/Thai Rune/g, '45# Thai')
        .replace(/Rha Rune/g, '46# Rha')
        .replace(/Xar Rune/g, '47# Xar')
        .replace(/Nih Rune/g, '48# Nih')
        .replace(/Lai Rune/g, '49# Lai')
        .replace(/On Rune/g, '50# On')
        .replace(/Taha Rune/g, '51# Taha')
        .replace(/Ghal Rune/g, '52# Ghal')
        .replace(/Qor Rune/g, '53# Qor')
        .replace(/Krys Rune/g, '54# Krys')
        .replace(/Auhe Rune/g, '55# Auhe')
        .replace(/Shaad Rune/g, '56# Shaad')
        .replace(/Ma Rune/g, '魔法符文')
        .replace(/Po Rune/g, '毒素符文')
        .replace(/Fi Rune/g, '火焰符文')
        .replace(/Ea Rune/g, '大地符文')
        .replace(/Co Rune/g, '寒冰符文')
        .replace(/Li Rune/g, '闪电符文')
        .replace(/Xis Rune/g, '卡布符文')
        .replace(/Weapons<br>/g, '武器<br>')
        .replace(/Throwing Knives/g, '飞刀')
        .replace(/Necromancer Scythes/g, '死灵法师专属镰刀')
        .replace(/Throwing Axes/g, '飞斧')
        .replace(/Amazon Spears/g, '亚马逊专属矛')
        .replace(/Paladin Spears/g, '圣骑士专属矛')
        .replace(/Paladin Clubs, Paladin Maces, Paladin Hammers/g, '圣骑士专属棍,棒,锤')
        .replace(/Spears/g, '长矛')
        .replace(/Sorceress Orbs/g, '法师单手法球')
        .replace(/Sorceress Crystal Swords/g, '扭曲之刃(法师)')
        .replace(/Sorceress Body Armor/g, '法师专属衣服')
        .replace(/Paladin Shields/g, '圣骑士专属盾')
        .replace(/Barbarian Shields/g, '野蛮人专属盾')
        .replace(/Assassin Shields/g, '刺客专属盾')
        .replace(/Necromancer Shields/g, '死灵法师专属盾')
        .replace(/Amazon Shields/g, '亚马逊专属盾')
        .replace(/Scythes/g, '镰刀')
        .replace(/Sceptres/g, '权杖')
        .replace(/Paladin Helms/g, '圣骑士专属头盔')
        .replace(/Paladin Clubs, Paladin Maces, Paladin Hammers/g, '圣骑士专属钝器')
        .replace(/Barbarian Swords/g, '野蛮人专属剑')
        .replace(/Barbarian One-Handed Axes/g, '野蛮人单手斧')
        .replace(/Barbarian Two-Handed Axes/g, '野蛮人双手斧')
        .replace(/One-Handed Swords/g, '单手剑')
        .replace(/One-Handed Axes/g, '单手斧')
        .replace(/Necromancer Wands/g, '死灵法师单手短杖')
        .replace(/Necromancer Staves/g, '死灵法师双手长杖')
        .replace(/Necromancer Daggers/g, '死灵法师专属匕首')
        .replace(/Necromancer Crossbows/g, '死灵法师专属十字弓')
        .replace(/Druid Staves/g, '德鲁伊专属法杖')
        .replace(/Druid Helms/g, '德鲁伊专属头盔')
        .replace(/Maces/g, '钉锤(棍棒顶端圆形发展 偏小)')
        .replace(/Hammers/g, '锤子(顶端为横向发展 偏大)')
        .replace(/Amazon Javelins/g, '亚马逊专属标枪')
        .replace(/Javelins/g, '标枪')
        .replace(/Barbarian Helms/g, '野蛮人头盔')
        .replace(/Staves/g, '长柄法杖')
        .replace(/Crossbows/g, '十字弓')
        .replace(/Druid Bows/g, '德鲁伊专属弓')
        .replace(/Amazon Bows/g, '亚马逊专属弓')
        .replace(/Amazon Helms/g, '亚马逊专属头盔')
        .replace(/Bows/g, '弓')
        .replace(/Daggers/g, '匕首')
        .replace(/Assassin Claws/g, '刺客爪')
        .replace(/Assassin Naginatas/g, '眉间刀(刺客)')
        .replace(/Body Armor/g, '衣服')
        .replace(/Circlets/g, '头环')
        .replace(/Shields/g, '盾牌')
        .replace(/Belts/g, '腰带')
        .replace(/Boots/g, '鞋子')
        .replace(/Helms/g, '头盔')
        .replace(/Gloves/g, '手套')
        .replace(/ Chance to cast level /g, ' 的机会施展等级 ')
        .replace(/ Hit Recovery/g, ' 快速打击恢复(FHR)')
        .replace(/ Block Speed/g, ' 格挡速度(FBR)')
        .replace(/ on Kill/g, ' 当杀死怪物')
        .replace(/ Enhanced damage/g, ' 增强伤害(ED)')
        .replace(/ Bonus to Attack Rating/g, ' 额外准确率(AR)')
        .replace(/ to All Attributes/g, ' 所有属性')
        .replace(/ Gold Find/g, ' 更多金币')
        .replace(/ to Light Radius/g, ' 照亮范围')
        .replace(/ Bonus Damage to/g, ' 更多伤害')
        .replace(/ Attack Speed/g, ' 增加攻速(IAS)')
        .replace(/Adds /g, '增加 ')
        .replace(/ cold damage/g, ' 的冰冷伤害')
        .replace(/ poison damage/g, ' 的毒素伤害')
        .replace(/ fire damage/g, ' 的火焰伤害')
        .replace(/ lightning damage/g, ' 的闪电伤害')
        .replace(/ magic damage/g, ' 的魔法伤害')
        .replace(/ damage/g, ' 的伤害')
        .replace(/ to Maximum Damage/g, ' 最大伤害')
        .replace(/Based on Character Level/g, '基于角色等级')
        .replace(/ to all Attributes/g, ' 至所有属性')
        .replace(/ to Mana Sweep/g, ' 法力扫荡')
        .replace(/ to Mana Tide Totem/g, '法力潮汐图腾')
        .replace(/ to Mana/g, ' 法力值')
        .replace(/ on Melee Attack/g, ' 当近战攻击时')
        .replace(/ to All Skills/g, ' 所有技能')
        .replace(/ to Minimum Damage/g, ' 最小伤害')
        .replace(/Stun Attack/g, '晕眩攻击')
        .replace(/ to Summoned Minion Life/g, '召唤物生命')
        .replace(/ to Strength/g, ' 力量')
        .replace(/ Bonus to Energy Factor/g, ' 增加精力因子')
        .replace(/ to Energy/g, ' 精力')
        .replace(/ to Dexterity/g, ' 敏捷')
        .replace(/ Reanimate as/g, ' 复活为')
        .replace(/ Cast Speed/g, ' 快速施法(FCR)')
        .replace(/ Life stolen per Hit/g, ' 生命偷取(LL)')
        .replace(/ Mana stolen per Hit/g, '法力偷取(LM)')
        .replace(/ to Life/g, ' 生命值')
        .replace(/Maximum Fire Resist /g, '最大火焰抗性 ')
        .replace(/Maximum Cold Resist /g, '最大冰冷抗性 ')
        .replace(/Maximum Lightning Resist /g, '最大闪电抗性 ')
        .replace(/Maximum Poison Resist /g, '最大毒素抗性 ')
        .replace(/Fire Resist /g, '火焰抗性(fr)')
        .replace(/Slow Target /g, '减慢目标')
        .replace(/Cold Resist /g, '冰冷抗性(cr)')
        .replace(/Lightning Resist /g, '闪电抗性(lr)')
        .replace(/Poison Resist /g, '毒素抗性(lr)')
        .replace(/Physical Resist /g, '物理抗性 ')
        .replace(/Physical Damage Reduced by /g, '物理伤害降低(dr) ')
        .replace(/ to Poison Spell Damage/g, ' 至毒素法术伤害')
        .replace(/ to Lightning Spell Damage/g, ' 至闪电法术伤害')
        .replace(/ to Cold Spell Damage/g, ' 至冰冷法术伤害')
        .replace(/ to Fire Spell Damage/g, ' 至火焰法术伤害')
        .replace(/ to Physical\/Magic Spell Damage/g, ' 至物理/魔法伤害')
        .replace(/ Energy Factor to Spell Damage/g, ' 法力因子至法术伤害')
        .replace(/ to Spell Damage/g, ' 至所有法术伤害')
        .replace(/ Chance of Crushing Blow/g, ' 压碎性打击(CB)')
        .replace(/ Charges/g, ' 聚气')
        .replace(/ Combat Speeds/g, ' 所有战斗速度')
        .replace(/ Increased Healing Rate from Apples/g, '增加食用苹果的恢复效率')
        .replace(/ Chance of Uninterruptable Attack/g, ' 不间断攻击(UA)')
        .replace(/Total Character Defense /g, '角色整体防御 ')
        .replace(/ to Enemy Cold Resistance/g, ' 敌人冰冷抗性')
        .replace(/ to Enemy Poison Resistance/g, ' 敌人毒素抗性')
        .replace(/ to Enemy Fire Resistance/g, ' 敌人火焰抗性')
        .replace(/ to Enemy Lightning Resistance/g, ' 敌人冰冷抗性')
        .replace(/Increase Maximum Life and Mana /g, '增加最大生命和法力值 ')
        .replace(/Requirements /g, '需求 ')
        .replace(/ Damage to Demons/g, ' 对恶魔的伤害(DTD)')
        .replace(/ Life Regenerated per Second/g, ' 每秒生命恢复')
        .replace(/ Life on Striking/g, ' 击中时恢复生命')
        .replace(/ Mana on Striking/g, ' 击中时恢复法力')
        .replace(/ Life on Attack/g, '打击时恢复生命')
        .replace(/ Life after each Kill/g, '杀死怪物获取生命(LAEK)')
        .replace(/ Mana after each Kill/g, '杀死怪物获取法力(MAEK)')
        .replace(/Target Takes Additional Damage of /g, '目标受到额外伤害 ')
        .replace(/Indestructible/g, '无法破坏')
        .replace(/ Movement Speed/g, ' 移动速度')
        .replace(/ Magic Find/g, ' 魔法物品获取(MF)')
        .replace(/Enhanced Weapon Damage /g, '增强武器伤害 ')
        .replace(/ to Vitality/g, ' 体力')
        .replace(/Hit Causes Monster to Flee /g, '击中使怪物逃跑')
        .replace(/Attacker Flees after Striking /g, '受到打击时恐吓怪物')
        .replace(/Half Freeze Duration/g, '冰冻时间减半')
        .replace(/Cannot Be Frozen/g, '无法冰冻')
        .replace(/Maximum Mana /g, '增加法力值 ')
        .replace(/Maximum Life /g, '增加生命值 ')
        .replace(/Regenerate Mana /g, '法力恢复速度 ')
        .replace(/ Bonus to Buff\/Debuff\/Cold Skill Duration/g, '延长Buff/Debuff/冰冻技能的效果时间')
        .replace(/ Energy Factor to Spell Damage/g, ' 精力因子至法术伤害')
        .replace(/ to Enemy Elemental Resistances/g, ' 敌人元素抗性')
        .replace(/Maximum Elemental Resists/g, '最大元素抗性')
        .replace(/Elemental Resists /g, '元素抗性 ')
        .replace(/ Deadly Strike/g, ' 致命一击(DS)')
        .replace(/ to Summoned Minion Resistances/g, ' 召唤物抗性')
        .replace(/ to Summoned Minion Damage/g, '召唤物伤害')
        .replace(/ to Summoned Minion Attack Rating/g, '召唤物准确率')
        .replace(/ to Maximum Barbarian Minions/g, ' 野蛮人召唤物数量')
        .replace(/ to Maximum Necromancer Minions/g, '死灵法师召唤物数量')
        .replace(/ Damage to Undead/g, '对不死生物的伤害(DTU)')
        .replace(/ Defense vs. Missile/g, '对飞弹的防御')
        .replace(/Ignore Target's Defense/g, '忽视目标防御')
        .replace(/ Enhanced Defense/g, '增强防御')
        .replace(/ Defense/g, ' 防御值')
        .replace(/ Skill Levels/g, '技能等级')
        .replace(/ to Druid/g, ' 德鲁伊')
        .replace(/ to Assassin/g, ' 刺客')
        .replace(/ to Barbarian/g, ' 野蛮人')
        .replace(/ to Amazon/g, ' 亚马逊')
        .replace(/ to Sorceress/g, ' 法师')
        .replace(/ to Necromancer/g, ' 死灵法师')
        .replace(/ to Paladin/g, ' 圣骑士')
        .replace(/Amazon Only/g, '限亚马逊')
        .replace(/Druid Only/g, '限德鲁伊')
        .replace(/Assassin Only/g, '限刺客')
        .replace(/Barbarian Only/g, '限野蛮人')
        .replace(/Sorceress Only/g, '限法师')
        .replace(/Necromancer Only/g, '限死灵法师')
        .replace(/Paladin Only/g, '限圣骑士')
        .replace(/ over 1 seconds/g, '在1秒内')
        .replace(/ to Experience Gained/g, '经验获取')
        .replace(/ Life when Struck by an Enemy/g, '生命受打击时')
        .replace(/Mana when Struck by an Enemy/g, '法力受打击时')
        .replace(/ on Striking/g, '在打击时')
        .replace(/ when Struck/g, ' 受到打击时')
        .replace(/ when Attacked/g, ' 当击中时')
        .replace(/Slows Attacker by /g, ' 减慢攻击者 ')
        .replace(/Slows Ranged Attacker by /g, '减慢远程攻击者 ')
        .replace(/Slows Melee Target by /g, '减慢近战目标 ')
        .replace(/ Damage to The Zakarum/g, ' 对萨卡兰姆的伤害(DTZ)')
        .replace(/Attacker Takes Cold Damage of /g, '攻击者受到冰冷伤害 ')
        .replace(/Attacker Takes Fire Damage of /g, '攻击者受到火焰伤害')
        .replace(/ Bonus Elemental Damage to Bloodlust/g, ' 增加嗜血的元素伤害')
        .replace(/You may Only use Melee, Summon and Support Skills/g, '仅可使用近战,召唤和支援技能')
        .replace(/ Base Block Chance/g, '基础格挡值')
        .replace(/ Bonus to Poison Skill Duration/g, ' 增加毒素技能持续时间')
        .replace(/Poison Length Reduced by /g, '中毒时间减少 ')
        .replace(/Lion Stance Damage Bonus /g, '狮子姿态伤害增加 ')
        .replace(/ Slower Block Rate/g, '降低格挡速度')
        .replace(/Cold Absorb /g, '冰冷吸收')
        .replace(/Fire Absorb /g, '火焰吸收')
        .replace(/Lightning Absorb /g, '闪电吸收')
        .replace(/Poison Absorb /g, '毒素吸收')
        .replace(/ Chance to Avoid Damage/g, ' 躲避伤害')
        .replace(/Druid Morph/g, '德鲁伊形态')
        .replace(/Based on Blessed Life Skill Level/g, '基于 Blessed Life 的等级')
        .replace(/ when using an Apple/g, ' 当食用苹果时')
        .replace(/ Damage Taken Goes To Mana/g, ' 受到伤害转化为法力')
        .replace(/Attacker Takes Elemental Damage of /g, '攻击者受到元素伤害 ')
        .replace(/ to Divine Apparition/g, 'Divine Apparition(神圣显现,3秒一次带冰冻的瞬移)')
        .replace(/ Mark of the Wild/g, '野性印记')
        .replace(/ to Hamstring/g, '断筋(Hamstring)')
        .replace(/Many runewords contain only one rune, but you can fill up the sockets /g, '许多神符之语仅需要一枚符文,但是你需要在镶嵌这枚符文')
        .replace(/before/g, '之前')
        .replace(/ the rune with jewels. To make a runeword in an item with 4 sockets, for example,/g, '用珠宝填满前面的孔,举个栗子,有一件装备有4个孔')
        .replace(/you must/g, '你必须按顺序')
        .replace(/ insert 3 jewels \+ 1 rune/g, '镶嵌 3枚珠宝和1枚符文')
        .replace(/Grey items only!/g, '只能用于灰色装备!')
        .replace(/Some people do not seem to know this. You can only make runewords in nonmagical socketed \(grey\) items!/g, '很多人看来不知道,你只能在普通带孔装备(灰色)上装备神符之语!')
        .replace(/ contains 537 all-new runewords./g, ' 包含了 537 个全新的神符之语')
        .replace(/LIST OF RUNEWORDS/g, '神符之语列表')
        .replace(/RUNEWORDS/g, '神符之语')
        .replace(/except /g, '除了 ')
        .replace(/Cannot be Unsocketed/g, '无法取出镶嵌物');
    })();

推荐答案

2

已采纳
document.body.innerHTML = document.body.innerHTML
.replace(/El Rune/g, '1# El')
.replace(/xxx/g, 'yyy');

可以这样写的。按你的写法会来回动dom,但到底怎么更好,我也不知道。

你的代码

// ==UserScript==
// @name         魔电官网文档中文化
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  实用工具
// @author       黑本
// @match        https://docs.median-xl.com/doc/items/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict'
//符文
    document.body.innerHTML = document.body.innerHTML
    .replace(/El Rune/g, '1# El')
    .replace(/Eld Rune/g, '2# Eld')
    .replace(/Tir Rune/g, '3# Tir')
    .replace(/Nef Rune/g, '4# Nef')
    .replace(/Eth Rune/g, '5# Eth')
    .replace(/Ith Rune/g, '6# Ith')
    .replace(/Tal Rune/g, '7# Tal')
    .replace(/Ral Rune/g, '8# Ral')
    .replace(/Ort Rune/g, '9# Ort')
    .replace(/Thul Rune/g, '10# Thul')
    .replace(/Amn Rune/g, '11# Amn')
    .replace(/Sol Rune/g, '12# Sol')
    .replace(/Shael Rune/g, '13# Shael')
    .replace(/Dol Rune/g, '14# Dol')
    .replace(/Hel Rune/g, '15# Hel')
    .replace(/Io Rune/g, '16# Io')
    .replace(/Lum Rune/g, '17# Lum')
    .replace(/Ko Rune/g, '18# Ko')
    .replace(/Fal Rune/g, '19# Fal')
    .replace(/Lem Rune/g, '20# Lem')
    .replace(/Pul Rune/g, '21# Pul')
    .replace(/Um Rune/g, '22# Um')
    .replace(/Mal Rune/g, '23# Mal')
    .replace(/Ist Rune/g, '24# Ist')
    .replace(/Gul Rune/g, '25# Gul')
    .replace(/Vex Rune/g, '26# Vex')
    .replace(/Ohm Rune/g, '27# Ohm')
    .replace(/Lo Rune/g, '28# Lo')
    .replace(/Sur Rune/g, '29# Sur')
    .replace(/Ber Rune/g, '30# Ber')
    .replace(/Jah Rune/g, '31# Jah')
    .replace(/Cham Rune/g, '32# Cham')
    .replace(/Zod Rune/g, '33# Zod')
    .replace(/Sha Rune/g, '34# Sha')
    .replace(/Lah Rune/g, '35# Lah')
    .replace(/Kur Rune/g, '36# Kur')
    .replace(/Ix Rune/g, '37# Ix')
    .replace(/Thur Rune/g, '38# Thur')
    .replace(/Nas Rune/g, '39# Nas')
    .replace(/Ath Rune/g, '40# Ath')
    .replace(/Kra Rune/g, '41# Kra')
    .replace(/Vith Rune/g, '42# Vith')
    .replace(/No Rune/g, '43# No')
    .replace(/Yul Rune/g, '44# Yul')
    .replace(/Thai Rune/g, '45# Thai')
    .replace(/Rha Rune/g, '46# Rha')
    .replace(/Xar Rune/g, '47# Xar')
    .replace(/Nih Rune/g, '48# Nih')
    .replace(/Lai Rune/g, '49# Lai')
    .replace(/On Rune/g, '50# On')
    .replace(/Taha Rune/g, '51# Taha')
    .replace(/Ghal Rune/g, '52# Ghal')
    .replace(/Qor Rune/g, '53# Qor')
    .replace(/Krys Rune/g, '54# Krys')
    .replace(/Auhe Rune/g, '55# Auhe')
    .replace(/Shaad Rune/g, '56# Shaad')
    .replace(/Ma Rune/g, '魔法符文')
    .replace(/Po Rune/g, '毒素符文')
    .replace(/Fi Rune/g, '火焰符文')
    .replace(/Ea Rune/g, '大地符文')
    .replace(/Co Rune/g, '寒冰符文')
    .replace(/Li Rune/g, '闪电符文')
    .replace(/Xis Rune/g, '卡布符文')

//装备
    .replace(/Weapons<br>/g, '武器<br>')
    .replace(/Throwing Knives/g, '飞刀')
    .replace(/Necromancer Scythes/g, '死灵法师专属镰刀')
    .replace(/Throwing Axes/g, '飞斧')
    .replace(/Amazon Spears/g, '亚马逊专属矛')
    .replace(/Paladin Spears/g, '圣骑士专属矛')
    .replace(/Paladin Clubs, Paladin Maces, Paladin Hammers/g, '圣骑士专属棍,棒,锤')
    .replace(/Spears/g, '长矛')
    .replace(/Sorceress Orbs/g, '法师单手法球')
    .replace(/Sorceress Crystal Swords/g, '扭曲之刃(法师)')
    .replace(/Sorceress Body Armor/g, '法师专属衣服')
    .replace(/Paladin Shields/g, '圣骑士专属盾')
    .replace(/Barbarian Shields/g, '野蛮人专属盾')
    .replace(/Assassin Shields/g, '刺客专属盾')
    .replace(/Necromancer Shields/g, '死灵法师专属盾')
    .replace(/Amazon Shields/g, '亚马逊专属盾')
    .replace(/Scythes/g, '镰刀')
    .replace(/Sceptres/g, '权杖')
    .replace(/Paladin Helms/g, '圣骑士专属头盔')
    .replace(/Paladin Clubs, Paladin Maces, Paladin Hammers/g, '圣骑士专属钝器')
    .replace(/Barbarian Swords/g, '野蛮人专属剑')
    .replace(/Barbarian One-Handed Axes/g, '野蛮人单手斧')
    .replace(/Barbarian Two-Handed Axes/g, '野蛮人双手斧')
    .replace(/One-Handed Swords/g, '单手剑')
    .replace(/One-Handed Axes/g, '单手斧')
    .replace(/Necromancer Wands/g, '死灵法师单手短杖')
    .replace(/Necromancer Staves/g, '死灵法师双手长杖')
    .replace(/Necromancer Daggers/g, '死灵法师专属匕首')
    .replace(/Necromancer Crossbows/g, '死灵法师专属十字弓')
    .replace(/Druid Staves/g, '德鲁伊专属法杖')
    .replace(/Druid Helms/g, '德鲁伊专属头盔')
    .replace(/Maces/g, '钉锤(棍棒顶端圆形发展 偏小)')
    .replace(/Hammers/g, '锤子(顶端为横向发展 偏大)')
    .replace(/Amazon Javelins/g, '亚马逊专属标枪')
    .replace(/Javelins/g, '标枪')
    .replace(/Barbarian Helms/g, '野蛮人头盔')
    .replace(/Staves/g, '长柄法杖')
    .replace(/Crossbows/g, '十字弓')
    .replace(/Druid Bows/g, '德鲁伊专属弓')
    .replace(/Amazon Bows/g, '亚马逊专属弓')
    .replace(/Amazon Helms/g, '亚马逊专属头盔')
    .replace(/Bows/g, '弓')
    .replace(/Daggers/g, '匕首')
    .replace(/Assassin Claws/g, '刺客爪')
    .replace(/Assassin Naginatas/g, '眉间刀(刺客)')
    .replace(/Body Armor/g, '衣服')
    .replace(/Circlets/g, '头环')
    .replace(/Shields/g, '盾牌')
    .replace(/Belts/g, '腰带')
    .replace(/Boots/g, '鞋子')
    .replace(/Helms/g, '头盔')
    .replace(/Gloves/g, '手套')
    //装备属性词条
    .replace(/ Chance to cast level /g, ' 的机会施展等级 ')
    .replace(/ Hit Recovery/g, ' 快速打击恢复(FHR)')
    .replace(/ Block Speed/g, ' 格挡速度(FBR)')
    .replace(/ on Kill/g, ' 当杀死怪物')
    .replace(/ Enhanced damage/g, ' 增强伤害(ED)')
    .replace(/ Bonus to Attack Rating/g, ' 额外准确率(AR)')
    .replace(/ to All Attributes/g, ' 所有属性')
    .replace(/ Gold Find/g, ' 更多金币')
    .replace(/ to Light Radius/g, ' 照亮范围')
    .replace(/ Bonus Damage to/g, ' 更多伤害')
    .replace(/ Attack Speed/g, ' 增加攻速(IAS)')
    .replace(/Adds /g, '增加 ')
    .replace(/ cold damage/g, ' 的冰冷伤害')
    .replace(/ poison damage/g, ' 的毒素伤害')
    .replace(/ fire damage/g, ' 的火焰伤害')
    .replace(/ lightning damage/g, ' 的闪电伤害')
    .replace(/ magic damage/g, ' 的魔法伤害')
    .replace(/ damage/g, ' 的伤害')
    .replace(/ to Maximum Damage/g, ' 最大伤害')
    .replace(/Based on Character Level/g, '基于角色等级')
    .replace(/ to all Attributes/g, ' 至所有属性')
    .replace(/ to Mana Sweep/g, ' 法力扫荡')
    .replace(/ to Mana Tide Totem/g, '法力潮汐图腾')
    .replace(/ to Mana/g, ' 法力值')
    .replace(/ on Melee Attack/g, ' 当近战攻击时')
    .replace(/ to All Skills/g, ' 所有技能')
    .replace(/ to Minimum Damage/g, ' 最小伤害')
    .replace(/Stun Attack/g, '晕眩攻击')
    .replace(/ to Summoned Minion Life/g, '召唤物生命')
    .replace(/ to Strength/g, ' 力量')
    .replace(/ Bonus to Energy Factor/g, ' 增加精力因子')
    .replace(/ to Energy/g, ' 精力')
    .replace(/ to Dexterity/g, ' 敏捷')
    .replace(/ Reanimate as/g, ' 复活为')
    .replace(/ Cast Speed/g, ' 快速施法(FCR)')
    .replace(/ Life stolen per Hit/g, ' 生命偷取(LL)')
    .replace(/ Mana stolen per Hit/g, '法力偷取(LM)')
    .replace(/ to Life/g, ' 生命值')
    .replace(/Maximum Fire Resist /g, '最大火焰抗性 ')
    .replace(/Maximum Cold Resist /g, '最大冰冷抗性 ')
    .replace(/Maximum Lightning Resist /g, '最大闪电抗性 ')
    .replace(/Maximum Poison Resist /g, '最大毒素抗性 ')
    .replace(/Fire Resist /g, '火焰抗性(fr)')
    .replace(/Slow Target /g, '减慢目标')
    .replace(/Cold Resist /g, '冰冷抗性(cr)')
    .replace(/Lightning Resist /g, '闪电抗性(lr)')
    .replace(/Poison Resist /g, '毒素抗性(lr)')
    .replace(/Physical Resist /g, '物理抗性 ')
    .replace(/Physical Damage Reduced by /g, '物理伤害降低(dr) ')
    .replace(/ to Poison Spell Damage/g, ' 至毒素法术伤害')
    .replace(/ to Lightning Spell Damage/g, ' 至闪电法术伤害')
    .replace(/ to Cold Spell Damage/g, ' 至冰冷法术伤害')
    .replace(/ to Fire Spell Damage/g, ' 至火焰法术伤害')
    .replace(/ to Physical\/Magic Spell Damage/g, ' 至物理/魔法伤害')
    .replace(/ Energy Factor to Spell Damage/g, ' 法力因子至法术伤害')
    .replace(/ to Spell Damage/g, ' 至所有法术伤害')
    .replace(/ Chance of Crushing Blow/g, ' 压碎性打击(CB)')
    .replace(/ Charges/g, ' 聚气')
    .replace(/ Combat Speeds/g, ' 所有战斗速度')
    .replace(/ Increased Healing Rate from Apples/g, '增加食用苹果的恢复效率')
    .replace(/ Chance of Uninterruptable Attack/g, ' 不间断攻击(UA)')
    .replace(/Total Character Defense /g, '角色整体防御 ')
    .replace(/ to Enemy Cold Resistance/g, ' 敌人冰冷抗性')
    .replace(/ to Enemy Poison Resistance/g, ' 敌人毒素抗性')
    .replace(/ to Enemy Fire Resistance/g, ' 敌人火焰抗性')
    .replace(/ to Enemy Lightning Resistance/g, ' 敌人冰冷抗性')
    .replace(/Increase Maximum Life and Mana /g, '增加最大生命和法力值 ')
    .replace(/Requirements /g, '需求 ')
    .replace(/ Damage to Demons/g, ' 对恶魔的伤害(DTD)')
    .replace(/ Life Regenerated per Second/g, ' 每秒生命恢复')
    .replace(/ Life on Striking/g, ' 击中时恢复生命')
    .replace(/ Mana on Striking/g, ' 击中时恢复法力')
    .replace(/ Life on Attack/g, '打击时恢复生命')
    .replace(/ Life after each Kill/g, '杀死怪物获取生命(LAEK)')
    .replace(/ Mana after each Kill/g, '杀死怪物获取法力(MAEK)')
    .replace(/Target Takes Additional Damage of /g, '目标受到额外伤害 ')
    .replace(/Indestructible/g, '无法破坏')
    .replace(/ Movement Speed/g, ' 移动速度')
    .replace(/ Magic Find/g, ' 魔法物品获取(MF)')
    .replace(/Enhanced Weapon Damage /g, '增强武器伤害 ')
    .replace(/ to Vitality/g, ' 体力')
    .replace(/Hit Causes Monster to Flee /g, '击中使怪物逃跑')
    .replace(/Attacker Flees after Striking /g, '受到打击时恐吓怪物')
    .replace(/Half Freeze Duration/g, '冰冻时间减半')
    .replace(/Cannot Be Frozen/g, '无法冰冻')
    .replace(/Maximum Mana /g, '增加法力值 ')
    .replace(/Maximum Life /g, '增加生命值 ')
    .replace(/Regenerate Mana /g, '法力恢复速度 ')
    .replace(/ Bonus to Buff\/Debuff\/Cold Skill Duration/g, '延长Buff/Debuff/冰冻技能的效果时间')
    .replace(/ Energy Factor to Spell Damage/g, ' 精力因子至法术伤害')
    .replace(/ to Enemy Elemental Resistances/g, ' 敌人元素抗性')
    .replace(/Maximum Elemental Resists/g, '最大元素抗性')
    .replace(/Elemental Resists /g, '元素抗性 ')
    .replace(/ Deadly Strike/g, ' 致命一击(DS)')
    .replace(/ to Summoned Minion Resistances/g, ' 召唤物抗性')
    .replace(/ to Summoned Minion Damage/g, '召唤物伤害')
    .replace(/ to Summoned Minion Attack Rating/g, '召唤物准确率')
    .replace(/ to Maximum Barbarian Minions/g, ' 野蛮人召唤物数量')
    .replace(/ to Maximum Necromancer Minions/g, '死灵法师召唤物数量')
    .replace(/ Damage to Undead/g, '对不死生物的伤害(DTU)')
    .replace(/ Defense vs. Missile/g, '对飞弹的防御')
    .replace(/Ignore Target's Defense/g, '忽视目标防御')
    .replace(/ Enhanced Defense/g, '增强防御')
    .replace(/ Defense/g, ' 防御值')
    .replace(/ Skill Levels/g, '技能等级')
    .replace(/ to Druid/g, ' 德鲁伊')
    .replace(/ to Assassin/g, ' 刺客')
    .replace(/ to Barbarian/g, ' 野蛮人')
    .replace(/ to Amazon/g, ' 亚马逊')
    .replace(/ to Sorceress/g, ' 法师')
    .replace(/ to Necromancer/g, ' 死灵法师')
    .replace(/ to Paladin/g, ' 圣骑士')
    .replace(/Amazon Only/g, '限亚马逊')
    .replace(/Druid Only/g, '限德鲁伊')
    .replace(/Assassin Only/g, '限刺客')
    .replace(/Barbarian Only/g, '限野蛮人')
    .replace(/Sorceress Only/g, '限法师')
    .replace(/Necromancer Only/g, '限死灵法师')
    .replace(/Paladin Only/g, '限圣骑士')
    .replace(/ over 1 seconds/g, '在1秒内')
    .replace(/ to Experience Gained/g, '经验获取')
    .replace(/ Life when Struck by an Enemy/g, '生命受打击时')
    .replace(/Mana when Struck by an Enemy/g, '法力受打击时')
    .replace(/ on Striking/g, '在打击时')
    .replace(/ when Struck/g, ' 受到打击时')
    .replace(/ when Attacked/g, ' 当击中时')
    .replace(/Slows Attacker by /g, ' 减慢攻击者 ')
    .replace(/Slows Ranged Attacker by /g, '减慢远程攻击者 ')
    .replace(/Slows Melee Target by /g, '减慢近战目标 ')
    .replace(/ Damage to The Zakarum/g, ' 对萨卡兰姆的伤害(DTZ)')
    .replace(/Attacker Takes Cold Damage of /g, '攻击者受到冰冷伤害 ')
    .replace(/Attacker Takes Fire Damage of /g, '攻击者受到火焰伤害')
    .replace(/ Bonus Elemental Damage to Bloodlust/g, ' 增加嗜血的元素伤害')
    .replace(/You may Only use Melee, Summon and Support Skills/g, '仅可使用近战,召唤和支援技能')
    .replace(/ Base Block Chance/g, '基础格挡值')
    .replace(/ Bonus to Poison Skill Duration/g, ' 增加毒素技能持续时间')
    .replace(/Poison Length Reduced by /g, '中毒时间减少 ')
    .replace(/Lion Stance Damage Bonus /g, '狮子姿态伤害增加 ')
    .replace(/ Slower Block Rate/g, '降低格挡速度')
    .replace(/Cold Absorb /g, '冰冷吸收')
    .replace(/Fire Absorb /g, '火焰吸收')
    .replace(/Lightning Absorb /g, '闪电吸收')
    .replace(/Poison Absorb /g, '毒素吸收')
    .replace(/ Chance to Avoid Damage/g, ' 躲避伤害')
    .replace(/Druid Morph/g, '德鲁伊形态')
    .replace(/Based on Blessed Life Skill Level/g, '基于 Blessed Life 的等级')
    .replace(/ when using an Apple/g, ' 当食用苹果时')
    .replace(/ Damage Taken Goes To Mana/g, ' 受到伤害转化为法力')
    .replace(/Attacker Takes Elemental Damage of /g, '攻击者受到元素伤害 ')
    //技能
    .replace(/ to Divine Apparition/g, 'Divine Apparition(神圣显现,3秒一次带冰冻的瞬移)')
    .replace(/ Mark of the Wild/g, '野性印记')
    .replace(/ to Hamstring/g, '断筋(Hamstring)')
//其他
    .replace(/Many runewords contain only one rune, but you can fill up the sockets /g, '许多神符之语仅需要一枚符文,但是你需要在镶嵌这枚符文')
    .replace(/before/g, '之前')
    .replace(/ the rune with jewels. To make a runeword in an item with 4 sockets, for example,/g, '用珠宝填满前面的孔,举个栗子,有一件装备有4个孔')
    .replace(/you must/g, '你必须按顺序')
    .replace(/ insert 3 jewels \+ 1 rune/g, '镶嵌 3枚珠宝和1枚符文')
    .replace(/Grey items only!/g, '只能用于灰色装备!')
    .replace(/Some people do not seem to know this. You can only make runewords in nonmagical socketed \(grey\) items!/g, '很多人看来不知道,你只能在普通带孔装备(灰色)上装备神符之语!')
    .replace(/ contains 537 all-new runewords./g, ' 包含了 537 个全新的神符之语')
    .replace(/LIST OF RUNEWORDS/g, '神符之语列表')
    .replace(/RUNEWORDS/g, '神符之语')
    .replace(/except /g, '除了 ')
    .replace(/Cannot be Unsocketed/g, '无法取出镶嵌物')
})()

推广链接