I was just thinking whether a chrome extension could do this use-case.
I have loaded a web-page. Which has some html code on it (I meant the web page itself is also displaying some html code)
Like this image.
This wikipedia contains some html. Which I could extract possibly from doing a regex of html to /html
I would like to build a chrome extension that could use this html code on the page (I know how I could extract it through regex) and display it inside a extension popup. It's like invoking a browser itself in the popup.
Some link's suggestions would be welcome from where I can start.
Could this be done.
Update:
re.js
chrome.tabs.query( {
active: true,
lastFocusedWindow: true
},
function getHTML(document){
var test = document_r.body;
var text = test.textContent;
var bodyStart="<BODY";
var bodyEnd="</BODY>"
var regex = bodyStart +"(.*?)"+ bodyEnd;
var regexg = new RegExp(regex, "g");
match = regexg.exec(text);
return match;
}
function(array_of_Tabs,document) {
var tab = array_of_Tabs[0];
//tab.url; - url of the active tab
getHTML(document);
chrome.tabs.executeScript(tab.id, {code: "chrome.runtime.sendMessage();"});
});
chrome.runtime.onMessage.addListener(function(request,document) {
document.getElementsByTagName('html')[0].innerHTML = request;
});
Ok So maybe i can call getHTML in function(array_of_tabs,document) I have the regexed string which contains the html code. Now how do i run that HMTL code in the popup.