How to get website javascript variables inside of the scope for "execute javascript in chrome" action?

Hi,

I want to automate a javascript snippet in chrome:

var storyList = "TiddlerIWantToOpen"
$tw.wiki.addTiddler({title: "$:/StoryList", text: "", list: storyList},$tw.wiki.getModificationFields());

But the $tw variable is part of the website. If I run this as a snippet in the chrome browser it works fine, but if I run it from KM I get this output in Chrome:

Uncaught ReferenceError: $tw is not defined

Just doing some trial and error I tried adding “window” and “document” to the beginning of the values and that I did not work either.

I’m sure one workaround is to create an impromptu chrome extension and somehow integrate that with the KM macro, but is there an easier way?

Thanks,
Matt