shakespeare.exe

Replaces modern words/phrases with Shakespearean language on dynamic websites like Medium.com

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         shakespeare.exe
// @namespace    http://github.com/pari55051
// @version      1.0
// @description  Replaces modern words/phrases with Shakespearean language on dynamic websites like Medium.com
// @author       You
// @match        https://*.medium.com/*
// @match        https://medium.com/*
// @match        https://*.wikipedia.org/*
// @match        https://*.reddit.com/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // dataset for replacements
    const phraseDict = {
        "how are you": "how doth thee fare",
        "what's up": "what news dost thou bring",
        "i don't know": "i knoweth not",
        "i'm tired": "i am weary",
        "i'm hungry": "my stomach doth rumble",
        "no way": "fie! it cannot be!",
        "okay": "'tis agreeable",
        "wait a minute": "prithee, tarry a moment",
        "be right back": "i shall return anon",
        "i'm sorry": "i beg thy pardon",
        "that's awesome": "'tis wondrous indeed",
        "that's amazing": "'tis wondrous indeed",
        "just kidding": "i jest, good sir/madam",
        "calm down": "hold thy tongue and be still",
        "i love you": "i doth adore thee",
        "i hate this": "i abhor this vile thing",
        "i'm so happy": "my heart singeth with joy",
        "i'm mad": "i am filled with wrath",
        "that's funny": "'tis a merry jest",
        "i'm scared": "i am afeard",
        "you're annoying": "thou art vexing",
        "shut up": "hold thy tongue",
        "you're stupid": "thou art a fool",
        "get lost": "remove thyself hence",
        "leave me alone": "remove thyself hence",
        "i don't care": "'tis naught to me",
        "see you soon": "i shall see thee anon",
        "let's go": "let us hence",
        "what the heck": "what devilry is this",
        "seriously?": "dost thou jest?",
        "good luck": "fortune smile upon thee",
        "who are you": "who art thou",
        "what are you doing": "what dost thou",
        "i am fine": "i fare well",
        "are you serious": "speaketh thou in earnest",
        "this is hard": "this task grieveth me",
        "it's not my fault": "the blame resteth not with me",
        "good morning": "good morrow",
        "good night": "good e'en",
        "thank you": "i give thee thanks",
        "you're welcome": "thou art welcome",
        "excuse me": "pardon me, good sir/madam",
        "congratulations": "well done, well said",
        "how old are you": "what age hast thou?",
        "i missed you": "i hath longed for thee",
        "what do you mean": "what dost thou intend?",
        "i agree": "'tis a notion most agreeable",
        "do you understand": "dost thou comprehend?",
        "what time is it": "which hour be it now?",
        "what's your name": "what be thy name?",
        "are you okay": "dost thou fare well?",
        "don't worry": "fret not thyself",
        "i'm bored": "i am listless of soul",
        "i'm busy": "i am o'ertasked"
    }

    const wordDict = {
        "shorten": "abate",
        "blunt": "abate",
        "diminution": "abatement",
        "protest": "abhor",
        "disgust": "abhor",
        "brook": "abrook",
        "abide": "abrook",
        "primer": "absey-book",
        "positive": "absolute",
        "deceive": "abuse",
        "deception": "abuse",
        "abyss": "abysm",
        "cite": "accite",
        "summon": "accite",
        "action": "acture",
        "title": "addition",
        "attribute": "addition",
        "prepared": "addressed",
        "prefer": "advance",
        "admonition": "advertisement",
        "attentive": "advertising",
        "consideration": "advice",
        "discretion": "advice",
        "consider": "advise",
        "considerate": "advised",
        "pleading": "advocation",
        "afraid": "afeared",
        "love": "affect",
        "acknowledge": "agnise",
        "plenteously": "a-good",
        "sea-term": "a-hold",
        "acceptance": "allowance",
        "alms": "almose",
        "aim": "level",
        "loyal": "amorous",
        "animal": "beast",
        "spirit": "sprite",
        "anger": "choler",
        "appeal": "solicitation",
        "appear": "present",
        "appearance": "show",
        "apply": "betake",
        "approach": "draw near",
        "argue": "dispute",
        "argument": "contention",
        "armor": "armour",
        "army": "host",
        "around": "about",
        "arrest": "attach",
        "arrive": "hither",
        "art": "craft",
        "ashamed": "confounded",
        "ask": "inquire",
        "assistance": "aidance",
        "atmosphere": "air",
        "attack": "assail",
        "attempt": "essai",
        "attention": "heed",
        "attract": "draw",
        "avoid": "eschew",
        "awake": "waken",
        "away": "hence",
        "awful": "direful",
        "baby": "babe",
        "back": "rearward",
        "bad": "vile",
        "bake": "sod",
        "balance": "poise",
        "banish": "exile",
        "bar": "obstruct",
        "bargain": "compact",
        "battle": "battalia",
        "beautiful": "beauteous",
        "beauty": "comeliness",
        "beg": "beseech",
        "begin": "commence",
        "beginning": "onset",
        "behavior": "demeanor",
        "believe": "credit",
        "beloved": "dear",
        "betray": "beguile",
        "better": "ameliorate",
        "between": "betwixt",
        "beware": "look to",
        "big": "vast",
        "bird": "fowl",
        "birth": "nativity",
        "bite": "nibble",
        "black": "swart",
        "blame": "censure",
        "bless": "benison",
        "blind": "sightless",
        "blood": "gore",
        "blow": "smite",
        "blue": "azure",
        "boast": "vaunt",
        "body": "trunk",
        "bold": "valiant",
        "book": "folio",
        "bore": "wearied",
        "borrow": "lend me",
        "bother": "vex",
        "brave": "gallant",
        "bread": "loaf",
        "break": "rend",
        "breathe": "respire",
        "bride": "new-made wife",
        "bright": "radiant",
        "bring": "fetch",
        "brother": "kinsman",
        "build": "erect",
        "burn": "scorch",
        "bury": "entomb",
        "busy": "engaged",
        "buy": "purchase",
        "by": "nigh",
        "call": "hail",
        "calm": "tranquil",
        "can": "mayst",
        "care": "regard",
        "carry": "bear",
        "cause": "occasion",
        "cease": "desist",
        "certainly": "forsooth",
        "chain": "fetter",
        "change": "alter",
        "charge": "impose",
        "charm": "enchant",
        "cheap": "base-born",
        "cheat": "cozen",
        "cheer": "mirth",
        "child": "urchin",
        "choice": "election",
        "choose": "prefer",
        "circle": "orb",
        "city": "town",
        "claim": "demand",
        "clarify": "expound",
        "clear": "lucid",
        "climb": "ascend",
        "close": "nigh",
        "cloud": "mist",
        "cold": "chill",
        "come": "approach",
        "comfort": "succor",
        "command": "bid",
        "companion": "compeer",
        "complain": "bemoan",
        "complete": "entire",
        "complexion": "hue",
        "compliment": "obeisance",
        "conceal": "shroud",
        "concern": "import",
        "confess": "acknowledge",
        "confidence": "assurance",
        "confuse": "perplex",
        "conquer": "o'ercome",
        "consider": "bethink",
        "constant": "steadfast",
        "content": "satisfied",
        "continue": "persist",
        "control": "govern",
        "conversation": "parley",
        "cook": "cater",
        "correct": "chasten",
        "courage": "mettle",
        "course": "progress",
        "court": "palace",
        "coward": "craven",
        "crazy": "mad",
        "create": "beget",
        "creature": "wight",
        "cry": "weep",
        "cut": "hew",
        "damage": "harm",
        "danger": "peril",
        "dare": "durst",
        "dark": "dismal",
        "daughter": "maid",
        "day": "morrow",
        "dead": "deceased",
        "dear": "belov’d",
        "death": "doom",
        "debt": "due",
        "deceive": "delude",
        "decide": "determine",
        "declare": "proclaim",
        "deep": "profound",
        "defend": "shield",
        "delay": "tarry",
        "delight": "joy",
        "deliver": "rescue",
        "demand": "require",
        "deny": "gainsay",
        "depart": "part",
        "depend": "rely",
        "describe": "depict",
        "desert": "wilderness",
        "deserve": "merit",
        "desire": "wish",
        "destroy": "ruin",
        "devil": "fiend",
        "die": "perish",
        "difficult": "arduous",
        "dinner": "repast",
        "dirty": "foul",
        "disappear": "vanish",
        "discuss": "confer",
        "dish": "trencher",
        "dislike": "mislike",
        "distant": "far-off",
        "disturb": "disquiet",
        "divide": "part",
        "do": "perform",
        "doctor": "leech",
        "dog": "cur",
        "door": "portal",
        "doubt": "mistrust",
        "down": "aloft",
        "dream": "vision",
        "drink": "quaff",
        "drive": "urge",
        "drunk": "besotted",
        "dry": "arid",
        "duke": "noble",
        "each": "every",
        "eager": "keen",
        "early": "anon",
        "earnest": "grave",
        "earth": "terra",
        "easy": "gentle",
        "eat": "devour",
        "education": "learning",
        "effort": "endeavor",
        "either": "aught",
        "elder": "ancient",
        "election": "choice",
        "else": "otherwise",
        "embrace": "enfold",
        "emotion": "passion",
        "emperor": "monarch",
        "empty": "bare",
        "end": "conclusion",
        "enemy": "foe",
        "energy": "vigor",
        "engage": "employ",
        "english": "anglish",
        "enjoy": "relish",
        "enough": "sufficient",
        "enter": "pass into",
        "entire": "whole",
        "envy": "malice",
        "equal": "alike",
        "error": "mistake",
        "escape": "flee",
        "especially": "specially",
        "esteem": "regard",
        "even": "e'en",
        "every": "each",
        "evil": "ill",
        "example": "precedent",
        "exchange": "barter",
        "excuse": "pardon",
        "exist": "be",
        "expect": "await",
        "explain": "expound",
        "eye": "orb",
        "face": "visage",
        "fail": "falter",
        "fair": "beauteous",
        "faith": "troth",
        "false": "untrue",
        "family": "kin",
        "famous": "renown’d",
        "far": "afar",
        "farewell": "adieu",
        "fast": "swift",
        "fat": "portly",
        "fault": "offense",
        "fear": "dread",
        "feast": "banquet",
        "feel": "perceive",
        "fellow": "sirrah",
        "fetch": "go bring",
        "few": "scant",
        "fight": "duel",
        "figure": "likeness",
        "fill": "stuff",
        "final": "utmost",
        "find": "discover",
        "fine": "dainty",
        "finger": "digit",
        "finish": "complete",
        "fire": "flame",
        "first": "foremost",
        "fish": "finny",
        "fit": "meet",
        "fix": "mend",
        "flesh": "meat",
        "flight": "soaring",
        "flourish": "blossom",
        "fly": "flee",
        "follow": "attend",
        "gift": "boon",
        "girl": "lass",
        "give": "bestow",
        "glad": "joyous",
        "glass": "looking-glass",
        "go": "wend",
        "god": "deity",
        "good": "virtuous",
        "goodbye": "fare thee well",
        "goose": "fowl",
        "grace": "favour",
        "great": "grand",
        "green": "verdant",
        "greet": "hail",
        "grief": "woe",
        "groan": "moan",
        "ground": "soil",
        "group": "company",
        "grow": "wax",
        "guard": "sentry",
        "guess": "reckon",
        "guide": "pilot",
        "guilty": "culpable",
        "gun": "culverin",
        "guy": "fellow",
        "habit": "custom",
        "hair": "locks",
        "half": "moiety",
        "hand": "palm",
        "handsome": "fair",
        "hang": "suspend",
        "happen": "befall",
        "happy": "blithe",
        "hard": "stiff",
        "hate": "abhor",
        "have": "possess",
        "head": "crown",
        "hear": "hearken",
        "heart": "bosom",
        "heaven": "paradise",
        "heavy": "weighty",
        "help": "succor",
        "her": "herself",
        "here": "hither",
        "hero": "champion",
        "hide": "conceal",
        "high": "lofty",
        "hill": "knoll",
        "hire": "engage",
        "hold": "grasp",
        "hole": "pit",
        "holy": "sacred",
        "home": "hearth",
        "honest": "true-hearted",
        "honor": "glory",
        "hope": "aspire",
        "horse": "steed",
        "host": "innkeeper",
        "hour": "clock's strike",
        "house": "dwelling",
        "how": "how now",
        "however": "nevertheless",
        "hug": "embrace",
        "humble": "lowly",
        "hunger": "famine",
        "hunt": "chase",
        "hurry": "haste",
        "hurt": "wound",
        "husband": "spouse",
        "idea": "notion",
        "idle": "slothful",
        "if": "an",
        "ill": "sickly",
        "image": "likeness",
        "imagine": "fancy",
        "important": "grave",
        "impossible": "unthinkable",
        "improve": "better",
        "in": "within",
        "include": "comprise",
        "increase": "wax",
        "indeed": "verily",
        "infant": "babe",
        "inquire": "demand",
        "inside": "within",
        "instead": "in lieu",
        "intelligent": "learned",
        "interest": "concern",
        "invite": "bid",
        "iron": "metal",
        "is": "be",
        "island": "isle",
        "it": "'tis",
        "item": "article",
        "its": "its own",
        "jail": "gaol",
        "joke": "jest",
        "joy": "glee",
        "judge": "magistrate",
        "jump": "leap",
        "keep": "retain",
        "kill": "slay",
        "kind": "gentle",
        "king": "sovereign",
        "kiss": "osculation",
        "know": "ken",
        "lad": "youth",
        "lady": "mistress",
        "lake": "mere",
        "land": "realm",
        "large": "ample",
        "last": "final",
        "laugh": "jest",
        "law": "edict",
        "lazy": "idle",
        "lead": "conduct",
        "leader": "chieftain",
        "learn": "study",
        "leave": "depart",
        "left": "port",
        "lend": "loan",
        "less": "fewer",
        "let": "allow",
        "letter": "missive",
        "lie": "falsehood",
        "life": "existence",
        "light": "glow",
        "like": "fancy",
        "limit": "bound",
        "listen": "attend",
        "little": "petty",
        "live": "dwell",
        "look": "gaze",
        "lord": "liege",
        "lose": "forfeit",
        "love": "adore",
        "loyal": "faithful",
        "luck": "fortune",
        "mad": "lunatic",
        "maid": "damsel",
        "make": "fashion",
        "man": "gentleman",
        "many": "manifold",
        "map": "chart",
        "march": "tread",
        "market": "bazaar",
        "marriage": "matrimony",
        "marry": "wed",
        "master": "lord",
        "match": "contest",
        "matter": "import",
        "may": "might",
        "meal": "repast",
        "mean": "intend",
        "meddle": "interlope",
        "meet": "encounter",
        "melt": "dissolve",
        "member": "limb",
        "memory": "remembrance",
        "message": "missive",
        "midnight": "witching hour",
        "might": "strength",
        "milk": "lactate",
        "mind": "thought",
        "mine": "my own",
        "minute": "moment",
        "mirror": "glass",
        "miss": "lack",
        "mistake": "error",
        "mock": "deride",
        "money": "coin",
        "moon": "orb of night",
        "more": "greater",
        "morning": "morn",
        "mother": "dam",
        "mouth": "maw",
        "move": "stir",
        "much": "greatly",
        "murder": "slaughter",
        "music": "melody",
        "must": "needs must",
        "name": "appellation",
        "narrow": "slender",
        "nation": "realm",
        "nature": "humour",
        "near": "nigh",
        "need": "requirement",
        "neighbor": "neighbour",
        "neither": "nor",
        "never": "ne'er",
        "new": "novel",
        "news": "tidings",
        "next": "nighest",
        "night": "eve",
        "no": "nay",
        "noise": "clamour",
        "none": "naught",
        "normal": "usual",
        "not": "nay",
        "nothing": "naught",
        "now": "presently",
        "number": "score",
        "obey": "submit",
        "object": "thing",
        "observe": "mark",
        "obtain": "procure",
        "occasion": "juncture",
        "ocean": "main",
        "old": "aged",
        "once": "erewhile",
        "one": "a single",
        "only": "solely",
        "open": "unbar",
        "opinion": "reckoning",
        "opportunity": "hap",
        "order": "commandment",
        "other": "else",
        "outside": "without",
        "over": "o'er",
        "own": "possess",
        "pain": "anguish",
        "paper": "parchment",
        "part": "portion",
        "partner": "consort",
        "party": "gathering",
        "pass": "proceed",
        "past": "foregone",
        "path": "way",
        "patient": "enduring",
        "pay": "render",
        "peace": "truce",
        "people": "folk",
        "perfect": "flawless",
        "perhaps": "perchance",
        "person": "mortal",
        "picture": "likeness",
        "place": "locale",
        "plan": "scheme",
        "play": "sport",
        "please": "gladden",
        "pleasure": "delight",
        "poor": "humble",
        "power": "might",
        "pray": "entreat",
        "prepare": "make ready",
        "present": "gift",
        "pride": "vainglory",
        "prince": "royal son",
        "prison": "dungeon",
        "private": "secret",
        "problem": "plight",
        "promise": "vow",
        "proper": "fitting",
        "protect": "shield",
        "proud": "high-hearted",
        "public": "common",
        "punish": "chastise",
        "purpose": "intent",
        "push": "thrust",
        "put": "place",
        "queen": "sovereign lady",
        "question": "query",
        "quick": "fleet",
        "quiet": "still",
        "rain": "downpour",
        "raise": "hoist",
        "rare": "scarce",
        "reach": "attain",
        "read": "peruse",
        "ready": "readied",
        "real": "veritable",
        "reason": "cause",
        "receive": "take",
        "red": "crimson",
        "remember": "bethink",
        "reply": "respond",
        "rest": "repose",
        "return": "come back",
        "rich": "wealthy",
        "ride": "steed away",
        "right": "just",
        "ring": "band",
        "rise": "ascend",
        "road": "pathway",
        "rob": "plunder",
        "room": "chamber",
        "run": "flee",
        "sad": "melancholy",
        "safe": "secure",
        "say": "speak",
        "scare": "fright",
        "school": "academy",
        "sea": "brine",
        "search": "seek",
        "seat": "stool",
        "see": "behold",
        "seem": "appear",
        "self": "oneself",
        "sell": "vend",
        "send": "dispatch",
        "sense": "wit",
        "serious": "grave",
        "serve": "attend",
        "set": "place",
        "several": "diverse",
        "shake": "quiver",
        "share": "portion",
        "sharp": "keen",
        "shout": "cry out",
        "show": "display",
        "shut": "bar",
        "sick": "ill",
        "side": "flank",
        "sign": "token",
        "simple": "plain",
        "since": "sith",
        "sing": "chant",
        "sister": "kinswoman",
        "sit": "perch",
        "skill": "craft",
        "sky": "firmament",
        "sleep": "slumber",
        "slow": "sluggish",
        "small": "petty",
        "smile": "grin",
        "snow": "frost",
        "soft": "gentle",
        "soldier": "man-at-arms",
        "some": "a few",
        "son": "heir",
        "song": "ballad",
        "soon": "anon",
        "sorry": "woeful",
        "speak": "utter",
        "special": "rare",
        "speed": "haste",
        "spend": "expend",
        "spirit": "phantom",
        "stand": "abide",
        "start": "commence",
        "stay": "tarry",
        "step": "stride",
        "still": "yet",
        "stop": "cease",
        "story": "tale",
        "strange": "queer",
        "street": "lane",
        "strong": "stout",
        "student": "pupil",
        "study": "peruse",
        "stupid": "dull-witted",
        "subject": "topic",
        "success": "triumph",
        "such": "so",
        "sudden": "abrupt",
        "suffer": "endure",
        "suit": "garb",
        "summer": "midsummer",
        "sun": "orb",
        "supper": "evening feast",
        "support": "uphold",
        "sure": "certain",
        "surprise": "startlement",
        "sweet": "dulcet",
        "sword": "blade",
        "take": "seize",
        "talk": "parley",
        "tall": "lofty",
        "teach": "instruct",
        "tear": "rend",
        "tell": "relate",
        "ten": "a score less ten",
        "thank": "give thanks",
        "that": "yon",
        "the": "ye",
        "their": "their own",
        "them": "those",
        "then": "thence",
        "there": "thither",
        "these": "those",
        "they": "those folk",
        "thing": "matter",
        "think": "ponder",
        "this": "this here",
        "those": "yon folk",
        "though": "albeit",
        "thought": "notion",
        "thousand": "a thousandfold",
        "three": "thrice",
        "through": "thorough",
        "throw": "cast",
        "thus": "so",
        "time": "hour",
        "tired": "weary",
        "to": "unto",
        "today": "this day",
        "together": "all as one",
        "told": "hath said",
        "tomorrow": "the morrow",
        "tonight": "this night",
        "too": "likewise",
        "took": "did seize",
        "town": "hamlet",
        "travel": "journey",
        "tree": "timber",
        "true": "veritable",
        "trust": "faith",
        "try": "endeavour",
        "turn": "spin",
        "twelve": "a dozen",
        "twice": "twofold",
        "two": "twain",
        "ugly": "foul",
        "under": "beneath",
        "understand": "comprehend",
        "unhappy": "woeful",
        "unite": "join",
        "until": "till",
        "up": "aloft",
        "upon": "on",
        "use": "employ",
        "usual": "customary",
        "valley": "vale",
        "value": "worth",
        "very": "most",
        "village": "shire",
        "virtue": "merit",
        "voice": "utterance",
        "walk": "amble",
        "wall": "barrier",
        "want": "desire",
        "war": "battle",
        "warm": "heated",
        "wash": "cleanse",
        "watch": "keep vigil",
        "water": "aqua",
        "way": "path",
        "we": "we folk",
        "weak": "feeble",
        "wealth": "riches",
        "wear": "don",
        "weather": "clime",
        "week": "sennight",
        "weep": "lament",
        "well": "well met",
        "west": "occident",
        "wet": "damp",
        "what": "what ho",
        "when": "whenas",
        "where": "whither",
        "which": "whichsoever",
        "while": "whilst",
        "white": "pale",
        "who": "whoever",
        "whole": "entire",
        "why": "wherefore",
        "wife": "lady wife",
        "wild": "untamed",
        "will": "wilt",
        "win": "triumph",
        "wind": "gale",
        "window": "casement",
        "wine": "mead",
        "winter": "frost-tide",
        "wise": "sage",
        "wish": "desirest",
        "with": "withal",
        "woman": "wench",
        "wonder": "marvel",
        "wood": "copse",
        "word": "utterance",
        "work": "toil",
        "world": "mortal coil",
        "worry": "vex",
        "worse": "more foul",
        "worth": "value",
        "would": "wouldst",
        "write": "scribe",
        "wrong": "ill",
        "year": "yr",
        "yes": "aye",
        "yesterday": "ereyesterday",
        "yet": "still",
        "you": "thou",
        "young": "youthful",
        "your": "thy",
        "yourself": "thineself",
        "zest": "gusto"
    }

    function walkAndReplace(rootNode) {
        const walker = document.createTreeWalker(rootNode, NodeFilter.SHOW_TEXT, null, false);
        let node;
        while (node = walker.nextNode()) {
            if (node.parentNode && !/^(SCRIPT|STYLE|TEXTAREA|INPUT)$/i.test(node.parentNode.nodeName)) {
                node.nodeValue = replaceText(node.nodeValue);
            }
        }
    }

    function replaceText(text) {
        for (let [key, value] of Object.entries(phraseDict)) {
            const regex = new RegExp(`\\b${key}\\b`, 'gi');
            text = text.replace(regex, (match) => matchCase(match, value));
        }
        for (let [key, value] of Object.entries(wordDict)) {
            const regex = new RegExp(`\\b${key}\\b`, 'gi');
            text = text.replace(regex, (match) => matchCase(match, value));
        }
        return text;
    }

    function matchCase(source, target) {
        if (source === source.toUpperCase()) return target.toUpperCase();
        if (source[0] === source[0].toUpperCase()) return target[0].toUpperCase() + target.slice(1);
        return target;
    }

    function escapeRegExp(string) {
        return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
    }   

    function observeAndReplace() {
        const observer = new MutationObserver(mutations => {
            for (const mutation of mutations) {
                for (const node of mutation.addedNodes) {
                    if (node.nodeType === 1) {
                        walkAndReplace(node);
                    } else if (node.nodeType === 3) {
                        node.nodeValue = replaceText(node.nodeValue);
                    }
                }
            }
        });

        observer.observe(document.body, {
            childList: true,
            subtree: true
        });

        // initial run
        walkAndReplace(document.body);
    }

    // waiting for DOM to load fully to over-ride text on dynamic websites
    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', observeAndReplace);
    } else {
        observeAndReplace();
    }
})();