I have made a small Chrome extension which has a click event listener that captures the element and then it gives the xpath.
But this is not capturing anything on a view-source: page.
Is there any way by which I can capture the element from view-source: page in JavaScript?
I am trying with this code on my content page:
document.addEventListener('click', function xyz(e){
e.preventDefault();
//alert(e);
var target = e.target || event.srcElement;
var attributes = Array.prototype.slice.call(target.attributes).map(function(i) {
return [String(i.name)+": "+String(i.value)]
})
alert(attributes);
prompt("xpath1 :",getPathTo(target));
chrome.runtime.sendMessage({method:"captureElement",data:attributes});
},true)
There is nothing you can do, you can't interact with those pages.
Extensions cannot get access to view-source: protocol pages (it's not a supported scheme), so you can't inject a content script in them at all, even with "<all_urls>" filter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With