object oriented programing function call js

I have a problem because calling the function works in DevTools, but not in Tampermonkey

In DevTools this works, it returns a string

g.worldConfig.getWorldName()

but in Tampermonkey I get an error:

TypeError: Cannot read properties of null (reading 'worldname')
const worldName = g.worldConfig.getWorldName()
console.log(worldName);

I checked and when I add proto, the function is displayed but I can’t call it anyway

const worldName = g.worldConfig.__proto__.getWorldName
getWorldName() {
  return _classPrivateFieldGet(this, _config).worldname;
}