MCPcopy Create free account
hub / github.com/bugy/script-server / readUserVisibleText

Function readUserVisibleText

web-src/src/common/utils/common.js:562–571  ·  view source on GitHub ↗
(elem)

Source from the content-addressed store, hash-verified

560// Default innerText doesn't work (on Chrome/Firefox), because <br/> is treated as double new-line
561// So the idea is just select text and copy it
562function readUserVisibleText(elem) {
563 const selection = window.getSelection();
564 const range = document.createRange();
565 range.selectNodeContents(elem);
566 selection.removeAllRanges();
567 selection.addRange(range);
568 const selectionString = selection.toString();
569 selection.removeAllRanges();
570 return selectionString;
571}
572
573export function copyToClipboard(elem) {
574 // if new Clipboard API is available, just use it

Callers 1

copyToClipboardFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected