I'm making chrome extension and i need to have xpath in it, it dose not work even when i add jquery in to the manifest.
ERROR:
Uncaught ReferenceError: $x is not defined
"permissions": [
"activeTab",
"*://www.znamky.zsunesco.cz/*"
],
"content_scripts": [
{
"matches": ["http://znamky.zsunesco.cz/*"],
"js": ["jquery-1.11.3.min.js", "Script.js"]
}
]
$x("//div[@class='nazevprdiv' and ./a[text()='"+name+"']]/../../td/table/tbody/tr[@class='detznamka']/td");
Like adelphus said, it's only a variable usd by Firebug as an xpath shortcut. You can implement it with this code:
function $x(path){
var xpath = document.evaluate(path, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
var temp = [];
for (var i = xpath.snapshotLength - 1; i >= 0; i--) {
temp.push(xpath.snapshotItem(i));
}
return temp;
}