So the idea is to make chrome extension that search for email address in web email client and then show info about customer from database.
What I managed to find was to get current tab html source with this:
Getting the source HTML of the current page from chrome extension
Then use split, regex or something to get an email and just call to some php script which would parse info. Everything would be great but we're using "Squirrel Mail" which uses iframes so obviously all I get is some headers and iframe links.
Could anyone point me to the right direction? Maybe it's possible to get tabs text rather than html source? Never had any experience with chrome extensions.. And any help to make it faster would be great. I obviously know certain location of the email that I want to get.
Casraf almost sorted it I'm just stuck with getting frame in this certain situation without since it doesn't have an id selector.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<meta name="robots" content="noindex,nofollow">
</head><frameset cols="150, *" id="fs1">
<frame src="left_main.php" name="left" frameborder="1">
<frame src="right_main.php" name="right" frameborder="1">
Let's say your iframe has a selector you can use.
var iframe = document.querySelector('#iframe'), doc = iframe.contentDocument || iframe.contentWindow.document;
Then you can use JS to find elements in the iframe's page and fetch content from there. For example, if in the iframe's HTML you have a
<span class="my-email-selector">firstname.lastname@example.org</span>, you could do something like this:
var email = doc.querySelector('.my-email-selector').innerText;
Which will now contain the email.
doc variable is a
document type so it should have all the regular document methods (
Edit: Since you have
frames and not
iframes, and they do have a
name attribute, it's really easy to access them:
var frame_left = window.frames['left'], frame_right = window.frames['right'];