I am trying to retrieve all the text on a document or webpage when a User loads the page,
I am trying to search all the text for certain words, defined by a [name value] array,
I am trying to replace each instance of the searched for words with the corresponding value.
example
I am using a chrome extension to inject My js upon page load...
<document>
<head>web page</head>
<body>
<p>paragraph of text. stack overflow is wonderful</p>
<p>another paragraph of text. stack overflow is great</p>
<p>third paragraph with nested list
<ol>
<li>stack overflow yay</li>
<li>stack overflow wow</li>
</ol>
<img alt"stack is fun"></img>
</p>
</body>
the word stack appears many times in many context and tags.
I would like search the entire document using the name value pair [stack : snack, wonderful : excellent],
and then replace the original word with the new value.
the page should refresh with the new words in place of the old, so
every instance of stack should now say snack,
every instance of wonderful should now say excellent.
question from:
https://stackoverflow.com/questions/65877034/get-all-text-from-all-elements-replace-certain-predetermined-words-javascript 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…