Update WEHAGO comparison data and tools
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import json
|
||||
import os
|
||||
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.chrome.options import Options
|
||||
|
||||
|
||||
options = Options()
|
||||
options.add_experimental_option("debuggerAddress", os.environ.get("WEHAGO_CHROME_DEBUGGER_ADDRESS", "127.0.0.1:9225"))
|
||||
driver = webdriver.Chrome(options=options)
|
||||
driver.set_script_timeout(10)
|
||||
|
||||
script = r"""
|
||||
const out = [];
|
||||
for (const body of document.querySelectorAll('.rg-body')) {
|
||||
const item = {view: String(body.$_view || ''), props: []};
|
||||
const keys = [];
|
||||
let node = body;
|
||||
while (node) {
|
||||
try { keys.push(...Object.getOwnPropertyNames(node)); } catch(e) {}
|
||||
node = Object.getPrototypeOf(node);
|
||||
if (!node || node === Object.prototype) break;
|
||||
}
|
||||
for (const key of Array.from(new Set(keys)).slice(0, 500)) {
|
||||
if (!/^\$_|grid|view|data|provider|handler|container|model|_/.test(key)) continue;
|
||||
try {
|
||||
const v = body[key];
|
||||
const rec = {key, type: typeof v, text: String(v).slice(0, 200)};
|
||||
if (v && typeof v === 'object') {
|
||||
let sub = [];
|
||||
try { sub = Object.getOwnPropertyNames(v).concat(Object.keys(v)); } catch(e) {}
|
||||
rec.keys = Array.from(new Set(sub)).slice(0, 80);
|
||||
rec.funcs = rec.keys.filter(k => { try { return typeof v[k] === 'function'; } catch(e) { return false; } }).slice(0, 40);
|
||||
}
|
||||
item.props.push(rec);
|
||||
} catch(e) {}
|
||||
}
|
||||
out.push(item);
|
||||
}
|
||||
return out;
|
||||
"""
|
||||
print(json.dumps(driver.execute_script(script), ensure_ascii=False, indent=2)[:80000])
|
||||
driver.quit()
|
||||
Reference in New Issue
Block a user