-
Notifications
You must be signed in to change notification settings - Fork 7
/
preload.js
103 lines (93 loc) · 3.2 KB
/
preload.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
94
95
96
97
98
99
100
101
102
103
function adjust_style() {
// Body
const body = document.body;
if (body) {
body.style.cssText = 'width: 100%; max-width: 100%; overflow: hidden';
}
// Content
const content = document.getElementById('b_content');
if (content) {
// Welcome page
const previewBanner = document.getElementById('underside-sydneypro-module');
const previewCloseBtn = document.getElementById(
'underside-sydneypromotion-close'
);
const forYouContent = document.getElementById('uns_section_standard');
const discoverContent = document.getElementById('uns_section_fixedbottom');
if (previewBanner) {
previewBanner.style.cssText = 'margin-top: 60px';
}
if (previewCloseBtn) {
previewCloseBtn.style.cssText = 'display: none';
}
if (forYouContent) {
forYouContent.style.cssText = 'display: none';
}
if (discoverContent) {
discoverContent.style.cssText = 'display: none';
}
// Header of main page
const headerWrapper = document.getElementsByClassName('wrapper-unfixed')[0];
const tabWrapper = document.getElementsByClassName('uds-hdr-wrapper')[0];
const tabs = document.getElementsByClassName('uds_tab_hdr')[0];
const insightsTab = document.getElementById('insights');
if (headerWrapper) {
headerWrapper.style.cssText = 'height: 40px';
}
if (tabWrapper) {
tabWrapper.style.cssText =
'height: 40px; display: flex; justify-content: center; align-items: center;';
}
if (insightsTab) {
insightsTab.style.cssText = 'display: none';
}
// Error
if (!previewBanner && !tabs) {
const errorInfo = document.createElement('p');
errorInfo.textContent = 'Not Available';
errorInfo.style.cssText =
'padding: 64px 32px; text-align: center; font-size: 20px; font-weight: 600; line-height: 26px;';
content.insertBefore(errorInfo, content.firstChild);
}
}
const cibSerpMainInterval = setInterval(() => {
const cibSerpMainLoaded =
document.getElementsByClassName('cib-serp-main')[0];
if (cibSerpMainLoaded) {
clearInterval(cibSerpMainInterval);
const $conversationMain = cibSerpMainLoaded.shadowRoot.querySelector(
'#cib-conversation-main'
);
if ($conversationMain) {
$conversationMain.shadowRoot.querySelector(
'.container-control'
).style.display = 'block';
}
}
}, 500);
// Compose page
const composeWrapper = document.getElementsByClassName(
'uds_coauthor_wrapper'
)[0];
const composeMain = document.getElementsByClassName('main')[0];
const insertBtn = document.getElementById('insert_button');
const previewText = document.getElementById('preview_text');
const previewOptions = document.getElementsByClassName('preview-options')[0];
if (composeWrapper) {
composeWrapper.style.cssText = 'margin-top: -64px';
}
if (composeMain) {
composeMain.style.cssText =
'height: calc(100% - 64px); margin-top: 64px; padding: 20px 10px';
}
if (insertBtn) {
insertBtn.style.cssText = 'display: none';
}
if (previewText) {
previewText.style.cssText = 'height: 100%';
}
if (previewOptions) {
previewOptions.style.cssText = 'bottom: 1px';
}
}
adjust_style();