-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsyringe.js
33 lines (29 loc) · 919 Bytes
/
syringe.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
let chatOpened = false
const clickChat = async () => {
// Select menu item
const chatBtn = document.getElementById('b-scopeListItem-conv')
if (
window.location.search.includes('&first') &&
(!window.location.search.includes('&first=1&') ||
(window.location.search.includes('&first=1') &&
window.location.search.substring(window.location.search.length - 1) ===
'1'))
) {
console.log('Not on first page, not running')
return
}
if (!chatBtn || chatOpened === true) {
console.log('Chat button not found or already opened')
return
}
// Click item and wait
chatBtn.firstChild.click()
await new Promise(resolve => setTimeout(resolve, 50))
// See if chat is open
const sydneyChat = document.getElementsByTagName('cib-serp')
if (sydneyChat.length > 0) {
chatOpened = true
}
return
}
document.addEventListener('transitionrun', clickChat, true)