javascript - Chrome Extension Paste into input element -
lets imagine have simple page. following content.
<form> <input type="text" id="starttext"> </form>
i have chrome extension script triggers on page loading. have configured relevant permission in chrome (i.e. clipboardread). script triggers on page load called action.js. has single line of code:
document.getelementbyid("starttext").value = "text";
i know can use "execcommand('paste')" function paste within chrome extension. can't figure out how modify above code, pastes contents of user's clipboard input element.
i try like:
document.getelementbyid("starttext").value.execcommand('paste')
but that, unsurprisingly, not work.
the clipboard can accessed via background pages, due security reasons. problem background pages cannot interact dom, content scripts can. check out this gist, solves problem messages passing between background page , content script.
Comments
Post a Comment