You are loading jQuery into the main page, but not into your extension's content script.
getText() function is running in your content script, not in the page's script, so it's in an "isolated world": https://developer.chrome.com/extensions/content_scripts#execution-environment
Therefore it doesn't have access to the
window object of your page, so
$ (which is
window.$) is not accessible. See also Can the window object be modified from a Chrome extension?
So you'll need to also load jQuery in your extension. See How to use jQuery in chrome extension? and How to use jQuery in Chrome extensions contentscript without conflict and Load JQuery into a Chrome extension?