I want to create a chrome extension, to run HTML validator on a webpage.
chrome.browserAction.onClicked.addListener(function(tab){
chrome.tabs.executeScript(tab.id, {file: "inject.js"}, function(){
alert(results);
});});
Below id the code in inject.js
var js = document.createElement("script");
js.type = "text/javascript";
js.src = "https://cdnjs.cloudflare.com/ajax/libs/html-inspector/0.8.1/html-inspector.js";
document.body.appendChild(js);
HTMLInspector.inspect();
On the DOM, I see that the script tag is added above the body
tag. But the line HTMLInspector.inspect();
throws the error. What can I do to fix this?