Skip to content

Instantly share code, notes, and snippets.

@kahunacohen
Created October 29, 2018 09:23
Show Gist options
  • Save kahunacohen/a623d4597f2d60a7ce905d7cc506b93d to your computer and use it in GitHub Desktop.
Save kahunacohen/a623d4597f2d60a7ce905d7cc506b93d to your computer and use it in GitHub Desktop.
NCBI-written gatherer for ncbi_app meta
"use strict";
const Gatherer = require("lighthouse").Gatherer;
/**
* @fileoverview Extracts `window.myLoadMetrics` from the test page.
*/
class NCBIAppMeta extends Gatherer {
async afterPass(options) {
const driver = options.driver;
const expression = `(function() {
var meta = document.querySelector("meta[name=ncbi_app]");
ret = {name: false, content: false};
var content;
if (meta) {
content = meta.getAttribute("content");
ret.name = true;
ret.content = content && content.length > 3;
}
return ret;
})()`;
return await driver.evaluateAsync(expression);
}
}
module.exports = NCBIAppMeta;
@kahunacohen
Copy link
Author

OK I kind of figured. Thanks for taking a look!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment