-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbigquery.user.js
93 lines (77 loc) · 2.51 KB
/
bigquery.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// ==UserScript==
// @match https://bigquery.cloud.google.com/*
// ==/UserScript==
/**
* @fileoverview Custom tweaks to Google's BigQuery web UI to clean up
* some things. Very KA-specific.
*/
var $ = function(s, node) {
return (node || document).querySelector(s);
};
var $$ = function(s, node) {
return (node || document).querySelectorAll(s);
};
var whiteList = [
'benkomalo',
'learning_gain',
'latest',
'latest_content',
'latest_derived',
'latest_transformed',
'logs',
'derived',
'bigbingo',
'bigbingo_archive',
'bigbingo_funnels',
'bigbingo_history',
'bingo'
];
function applyChanges() {
Array.prototype.forEach.call($$('.tables-dataset-row'), function(node) {
// We're looking for rows that look like '124072386181:2014_01_27.Pa'
var parts = (node.id || '').split(':');
if (parts.length != 2) {
return;
}
parts = parts[1].split('.');
var tableName = parts[0];
if (/^\d\d\d\d_\d\d_\d\d(_transformed)?/.test(tableName)) {
// This is a historical data dump of our entity set. Hide any
// really old ones that we're unlikely to care about.
parts = tableName.split('_');
var y = parseInt(parts[0], 10);
var m = parseInt(parts[1], 10);
var d = parseInt(parts[2], 10);
var TWO_WEEKS = 1000 * 60 * 60 * 24 * 14
if (new Date(y, m - 1, d) < Date.now() - TWO_WEEKS) {
node.parentNode.className += ' non-essential';
}
} else if (whiteList.indexOf(tableName) == -1) {
node.parentNode.className += ' non-essential';
}
});
var style = document.createElement('style');
style.innerText = '.non-essential {display: none;}' +
'\n.non-essential.show {display: block;}';
$('head').appendChild(style);
var showLink = document.createElement('span');
showLink.innerText = ' [Show all hidden]';
showLink.style.cursor = 'pointer';
showLink.addEventListener('click', function(e) {
Array.prototype.forEach.call($$('.non-essential'), function(node) {
node.className += ' show';
});
});
$('.tables-header > .project-name').appendChild(showLink);
}
function check() {
var ready = !!$('.tables-dataset-row') &&
(noRow = $('.no-datasets-text')) &&
noRow.style.display == 'none';
if (ready) {
applyChanges();
} else {
setTimeout(check, 500);
}
}
setTimeout(check, 500);