forked from PurePro4561/PurePro4561.github.io-v2
-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathTC.js
More file actions
136 lines (124 loc) · 4 KB
/
TC.js
File metadata and controls
136 lines (124 loc) · 4 KB
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
function setTitle(title = "") {
if (title) {
document.title = title;
} else {
document.title = settingsDefaultTab.title;
}
// Update the saved tab data with the new title
var tab = localStorage.getItem("tab");
if (tab) {
// If there is saved data, try to parse it
try {
var tabData = JSON.parse(tab);
} catch {
// If there is an error in parsing, create an empty object
var tabData = {};
}
} else {
// If there is no saved data, create an empty object
var tabData = {};
}
if (title) {
// If there is a new title, update tabData
tabData.title = title;
} else {
// If the title is empty, delete the title field from tabData
delete tabData.title;
}
// Save the updated tab data to localStorage
localStorage.setItem("tab", JSON.stringify(tabData));
}
// Function to set the favicon
function setFavicon(icon) {
if (icon) {
document.querySelector("link[rel='icon']").href = icon;
} else {
document.querySelector("link[rel='icon']").href = settingsDefaultTab.icon;
}
// Update the saved tab data with the new icon
var tab = localStorage.getItem("tab");
if (tab) {
// If there is saved data, try to parse it
try {
var tabData = JSON.parse(tab);
} catch {
// If there is an error in parsing, create an empty object
var tabData = {};
}
} else {
// If there is no saved data, create an empty object
var tabData = {};
}
if (icon) {
// If there is a new icon, update tabData
tabData.icon = icon;
} else {
// If the icon is empty, delete the icon field from tabData
delete tabData.icon;
}
// Save the updated tab data to localStorage
localStorage.setItem("tab", JSON.stringify(tabData));
}
function setCloak() { // applies only to premade cloaks
var cloak = document.getElementById("premadecloaks").value; // cloak seems kind of weird when you spell it out
switch (cloak) {
case "search": // Google Search
setTitle("Google");
setFavicon("./images/cloaks/Google Search.ico");
location.reload();
break;
case "drive": // Google Drive
setTitle("My Drive - Google Drive");
setFavicon("./images/cloaks/Google Drive.ico");
location.reload();
break;
case "youtube": // YouTube
setTitle("YouTube");
setFavicon("./images/cloaks/Youtube.ico");
location.reload();
break;
case "gmail": // Gmail
setTitle("Gmail");
setFavicon("./images/cloaks/Gmail.ico");
location.reload();
break;
case "calendar": // Google Calendar
setTitle("Google Calendar");
setFavicon("./images/cloaks/Calendar.ico");
location.reload();
break;
case "meets": // Google Meet
setTitle("Google Meet");
setFavicon("./images/cloaks/Meet.ico");
location.reload();
break;
case "classroom": // Google Classroom
setTitle("Classes");
setFavicon("./images/cloaks/Classroom.png");
location.reload();
break;
case "canvas": // Canvas
setTitle("Canvas");
setFavicon("./images/cloaks/Canvas.ico");
location.reload();
break;
case "zoom": // Zoom
setTitle("Zoom");
setFavicon("./images/cloaks/Zoom.ico");
location.reload();
break;
case "khan": // Khan Academy
setTitle("Dashboard | Khan Academy");
setFavicon("./images/cloaks/Khan Academy.ico");
location.reload();
break;
}
}
// Function to reset the tab settings to default
function resetTab() {
document.title = settingsDefaultTab.title;
document.querySelector("link[rel='icon']").href = settingsDefaultTab.icon;
document.getElementById("title").value = "";
document.getElementById("icon").value = "";
localStorage.setItem("tab", JSON.stringify({}));
}