-
Notifications
You must be signed in to change notification settings - Fork 0
/
content.js
41 lines (35 loc) · 1.31 KB
/
content.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
window.addEventListener("load", function(){
console.log("content: window loaded");
// open calendar sidebar
chrome.storage.sync.get(["calendarSidebar"], function(result){
if (result.calendarSidebar) {
setTimeout(openCalendarSidebar, 1000);
}
});
// toggle request response
chrome.storage.sync.get(["requestResponse"], function(result){
// using bind to pass args to the function. See link for more info.
// https://stackoverflow.com/questions/1190642/how-can-i-pass-a-parameter-to-a-settimeout-callback
setTimeout(toggleRequestResponse.bind(null, result.requestResponse), 3000);
});
});
function openCalendarSidebar(){
var sidebar = document.getElementById("Time");
if (sidebar != null ){
sidebar.click();
}
}
function toggleRequestResponse(toggle) {
if (toggle) {
var responseOptionsEl = document.getElementsByName("Response options");
if (responseOptionsEl != null) {
if (responseOptionsEl.length > 0) {
responseOptionsEl[0].click();
}
var requestResponseEl = document.getElementsByName("Request responses");
if (requestResponseEl != null && requestResponseEl.length > 0) {
requestResponseEl[0].click();
}
}
}
}