<commit_before>var browser = chrome || browser;

// define matches methode according to browser
var elementProto = Element.prototype;
var matchesFn = ['webkit', 'ms', 'moz', 'o'].reduce((func, prefix) => {
  var prefixedFuncName = `${prefix}MatchesSelector`;
  if (elementProto.hasOwnProperty(prefixedFuncName)) {
    return elementProto[prefixedFuncName];
  }

  return func;
}, elementProto.matches);

// find node in terms of selector
function passedThrough(evt, selector) {
  var currentNode = evt.target;
  var stopAt = evt.currentTarget;

  while (true) {
    if (matchesFn.call(currentNode, selector)) {
      return currentNode;
    } else if (currentNode !== stopAt && currentNode !== document.body) {
      currentNode = currentNode.parentNode;
    } else {
      return false;
    }
  }
}

function isRightButton(e) {
  var e = e || window.event;
  if (e.which == null) {
    return e.button >= 2 && e.button !== 4; // 4 is the middle button
  }

  return e.which > 2;
}

// sendMessage callback
var callback = function(url) {
  return function(resp) {
    if (resp) {
      console.log('Opened URL: ', url, ' in a new incognito window.');
    } else {
      console.error('Failed to open the URL: ', url);
    }
  }
}

document.addEventListener('click', (evt) => {
  if (!isRightButton(evt)) {
    var found = passedThrough(evt, 'a[target="linkognito"]');

    if (found) {
      evt.preventDefault();
      let url = found.getAttribute('href')
      if (!url.startsWith('http')) {
        if (url.startsWith('/')){
          url = `${window.location.origin}${url}`
        } else {
          url = `${window.location.href}/${url}`
        }
      }

      browser.runtime.sendMessage({ url: url }, callback(url));
    }
  }
});<commit_msg>Select link by classname instead of target<commit_after>var browser = chrome || browser;

// define matches methode according to browser
var elementProto = Element.prototype;
var matchesFn = ['webkit', 'ms', 'moz', 'o'].reduce((func, prefix) => {
  var prefixedFuncName = `${prefix}MatchesSelector`;
  if (elementProto.hasOwnProperty(prefixedFuncName)) {
    return elementProto[prefixedFuncName];
  }

  return func;
}, elementProto.matches);

// find node in terms of selector
function passedThrough(evt, selector) {
  var currentNode = evt.target;
  var stopAt = evt.currentTarget;

  while (true) {
    if (matchesFn.call(currentNode, selector)) {
      return currentNode;
    } else if (currentNode !== stopAt && currentNode !== document.body) {
      currentNode = currentNode.parentNode;
    } else {
      return false;
    }
  }
}

function isRightButton(e) {
  var e = e || window.event;
  if (e.which == null) {
    return e.button >= 2 && e.button !== 4; // 4 is the middle button
  }

  return e.which > 2;
}

// sendMessage callback
var callback = function(url) {
  return function(resp) {
    if (resp) {
      console.log('Opened URL: ', url, ' in a new incognito window.');
    } else {
      console.error('Failed to open the URL: ', url);
    }
  }
}

document.addEventListener('click', (evt) => {
  if (!isRightButton(evt)) {
    var found = passedThrough(evt, 'a.linkognito');

    if (found) {
      evt.preventDefault();
      let url = found.getAttribute('href')
      if (!url.startsWith('http')) {
        if (url.startsWith('/')){
          url = `${window.location.origin}${url}`
        } else {
          url = `${window.location.href}/${url}`
        }
      }

      browser.runtime.sendMessage({ url: url }, callback(url));
    }
  }
});
{'fraction_non_alphanumeric': 0.1532784558614817, 'fraction_numerical': 0.0022707919386886176, 'mean_word_length': 2.99546485260771, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3171585', 'n_tokens_mistral': 1101, 'n_tokens_neox': 1112, 'n_words': 278}