function findJsScripts(document, exclude = {}) {
  /** @type {Node[]} */
  const allScripts = queryAll(document, predicates.hasTagName('script'));

  return allScripts
    .filter(script => {
      const inline = !hasAttribute(script, 'src');
      const type = getAttribute(script, 'type');

      // we don't handle scripts which import from a URL (ex. a CDN)
      if (!inline && isUri(getAttribute(script, 'src'))) {
        return false;
      }

      if (!type || ['application/javascript', 'text/javascript'].includes(type)) {
        return inline ? !exclude.inlineJsScripts : !exclude.jsScripts;
      }
      if (type === 'module') {
        return inline ? !exclude.inlineJsModules : !exclude.jsModules;
      }
      return false;
    })
    .sort(sortByLoadingPriority);
}
Finds all js scripts in a document, returns the scripts sorted by loading priority.
@param {Document} document
@param {{ jsScripts?: boolean, jsModules?: boolean, inlineJsScripts?: boolean, inlineJsModules?: boolean }} [exclude]
@returns {Node[]}