nemesarial / Spree QID identifiers

/*eslint semi: ["error", "always"]*/
// ==UserScript==
// @name         Spree QID identifiers
// @namespace    http://codeonfire.space/
// @version      1.1.3
// @description  Identifies elements with QID attribs
// @author       Mark Holtzhausen <nemesarial@gmail.com>
// @include      *
// @require      https://openuserjs.org/src/libs/nemesarial/DOMHelper.js
// @license      MIT
// @grant        none
// ==/UserScript==

// Reorder Subtasks
var checkQID = function () {
  DOM.queryAll('[data-qid]').map(elem => {
    if (elem.hasAttribute('data-qide')) return;
    elem.style.border = '1px solid red';
    elem.setAttribute('title', elem.getAttribute('data-qid'));
    elem.setAttribute('data-qide', true);
    elem.addEventListener('mousedown', function (e) {
      var qid = elem.getAttribute('data-qid');
      var selector = `[data-qid="${qid}"]`;
      var cnt = DOM.queryAll(selector).length;
      var varName = qid.split('-').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join('');
      varName = varName.charAt(0).toLowerCase() + varName.slice(1);
      if (e.altKey) {
        e.stopPropagation();
        e.preventDefault();
        alert(`VARIABLE ::   ${varName}\nDATA-QID ::   ${qid}\nCSS SELECTOR ::   ${selector}\nElement Count ::   ${cnt} ${cnt != 1 ? '  !!! Speak to your Dev !!!  ':''}\n\nSELENIUM ::\n--------------------\n\n ${varName} = driver.findElement(By.cssSelector('${selector}'));\n\n--------------------\n`);
        return false;
      }

    });
  });
};

setInterval(checkQID, 500);