Get document hits using XPath


We have a page where the documents are viewed on page which on clicking the title of document, opens in another tab in powerpoint. The document element is anchor tag without any id, name or classname. It has href and text property only. We need to capture count of hits on these documents using browser custom script. Below methods i tried which dont work.

Any suggestions would help.

var xpath = “xpath”;
var matchingElement = document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;

        matchingElement.addEventListener('click',function (e) {

Second way tried:


Third way tried:

var x = document.querySelectorAll(“a[href=‘URL’]”);

 for(i=0;i<x.length; i++){
     x[i].addEventListener('click',function (e) {