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

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -