How to target & replace the name of a property from a different document in JavaScript?

Im wanting to replace/translate text on a webpage. This is for some online software where I only have access to a custom code section.

Ive managed to translate some words, but my script doesn’t have an affect on some others which are populated from a different file called storeSettings.js.

How can I edit my current translation script to translate the words I need in storeSettings.js ?

This is my current translation code to replace the word ‘State’ with ‘County’:

window.onload = function() {const replaceOnDocument = (pattern, string, {target = document.body} = {}) => {
  [
    target,
    ...target.querySelectorAll("*:not(script):not(noscript):not(style)")
  ].forEach(({childNodes: [...nodes]}) => nodes
    .filter(({nodeType}) => nodeType === document.TEXT_NODE)
    .forEach((textNode) => textNode.textContent = textNode.textContent.replace(pattern, string)));
};

replaceOnDocument(/State/g, "County");
                        };

And this is the contents of storeSettings.js



 var fillGeneralSettings = function () {
      mergeUnique(settings.general, {
        state: '',
      }, true);

{
          property: 'state',
          field: self.container.find('[name="state"]')
        }

Say I want to replace ‘State’ with ‘County’ (cosmetically). Instead of target = document.body in my translation script what should I replace it with to access the content of storeSettings.js?

Thank you! 🙂