Get selection from Google Docs

Is there a way around the fact that window.getSelection() does not seem to work in Google Docs? I want to capture text from a highlighted selection from Google Docs. My implementation is with …