michaelmcgurk michaelmcgurk - 1 year ago 77
jQuery Question

Read HTML page element value into Chrome Extension

I have a page called

held at http://intranet/ with the contents:

<div id="username">my.username</div>

I'd like to use jQuery to read this value into my Chrome Extension.

Currently I have hard coded text:
in my
of my Chrome Extension but I'd prefer to grab the value in the

Potentially useful:

I'm not great with Javascript but I did follow this tutorial a little: http://www.dynamicdrive.com/forums/showthread.php?67448-document-getElementById-from-another-page which recommends something like this code:

<script type="text/javascript">
$('#result').load('Page2.html #intro');

Their example works great but I'd like to build the above into a Chrome Extension.

Can anyone provide assistance for this issue?

Answer Source
    url: 'https://intranet/index.php',
    success: function(html) {
        var nodes = $.parseHTML(html);
        var username = $("<div>").append(nodes).find("#username").text();