Get the selected text

const selectedText = window.getSelection().toString();

More

Previous
Get the position of an element relative to the document
Next
Go back to the previous page