Skip to content

Instantly share code, notes, and snippets.

@zpbx
Created March 16, 2017 09:40
Show Gist options
  • Save zpbx/ac462e2a286420a18daec82f1a02b5bd to your computer and use it in GitHub Desktop.
Save zpbx/ac462e2a286420a18daec82f1a02b5bd to your computer and use it in GitHub Desktop.
把性能看板中的历史数据输出到控制台
document.body.onclick = function () {
const wrapper = document.querySelector('.grafana-tooltip')
if (!wrapper) {
console.error('no data!')
return
}
const date = wrapper.querySelector('.graph-tooltip-time').innerHTML.split(' ')[0]
const valueElements = Array.from(wrapper.querySelectorAll('.graph-tooltip-value'))
const values = valueElements.map((item) => {
const val = item.innerHTML || ''
let [qty, unit] = val.split(' ')
if (unit === 's') {
qty = qty * 1000
}
return Math.round(qty)
})
const output = [date, ...values].join(' | ')
console.log(output)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment