Skip to content

Instantly share code, notes, and snippets.



Created Oct 12, 2018
What would you like to do?
var elementsInsideBody = [...document.body.getElementsByTagName('*')];
// This makes an array of everything inside the body tag
//a function that loops through every single item
function findAndReplace(){
elementsInsideBody.forEach(element =>{
element.childNodes.forEach(child =>{
if(child.nodeType === 3){
function replaceText (node) {
let value = node.nodeValue;
value = value.replace(/Brexit/gi, 'Breadsticks');
value = value.replace(/brexit/gi, 'breadsticks');
node.nodeValue = value;
window.onload = findAndReplace();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment