Skip to content

Commit c184ba5

Browse files
committed
feat(ext): Add more suboptions
1 parent 99d82e0 commit c184ba5

File tree

6 files changed

+220
-47
lines changed

6 files changed

+220
-47
lines changed

src/_locales/en/messages.json

Lines changed: 79 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,6 @@
194194
"disclaimer_settings_reload": {
195195
"message": "Some settings may require a page reload to take effect. <b><a href=''>[Reload]</a></b>"
196196
},
197-
"appearanceSettingsTitle": {
198-
"message": "Appearance Settings"
199-
},
200-
"extendingFunctionalityTitle": {
201-
"message": "Extending Functionality"
202-
},
203197
"Miscellaneous": {
204198
"message": "Miscellaneous"
205199
},
@@ -261,7 +255,7 @@
261255
"message": "In-app Extension Settings"
262256
},
263257
"inAppExtSettings_description": {
264-
"message": "Add extension settings inside profile"
258+
"message": "Add extension settings inside the profile page"
265259
},
266260
"moveLogOutButton": {
267261
"message": "Move Logout Button"
@@ -331,5 +325,83 @@
331325
},
332326
"monRoundedAverages_description": {
333327
"message": "Show rounded averages instead of precise ones"
328+
},
329+
"subSettingsSectionMain": {
330+
"message": "Main Settings Section"
331+
},
332+
"subSettingsSectionMain_description": {
333+
"message": "Show the main settings section separator in the settings page"
334+
},
335+
"subSettingsSectionQol": {
336+
"message": "QoL Settings Section"
337+
},
338+
"subSettingsSectionQol_description": {
339+
"message": "Show the QoL settings section separator in the settings page"
340+
},
341+
"subSettingsSectionExperimental": {
342+
"message": "Experimental Settings Section"
343+
},
344+
"subSettingsSectionExperimental_description": {
345+
"message": "Show the Experimental settings section separator in the settings page"
346+
},
347+
"subSettingsSectionMon": {
348+
"message": "MON Settings Section"
349+
},
350+
"subSettingsSectionMon_description": {
351+
"message": "Show the MON settings section separator in the settings page"
352+
},
353+
"subSettingsSectionDev": {
354+
"message": "Developer Settings Section"
355+
},
356+
"subSettingsSectionDev_description": {
357+
"message": "Show the Developer settings section separator in the settings page"
358+
},
359+
"removeStatisticsButton": {
360+
"message": "Remove Statistics Button"
361+
},
362+
"removeStatisticsButton_description": {
363+
"message": "Removes the 'Remove Statistics' button from the dashboard"
364+
},
365+
"removeRankDisclaimer": {
366+
"message": "Remove Rank Disclaimer"
367+
},
368+
"removeRankDisclaimer_description": {
369+
"message": "Removes the rank disclaimer from the ranks widget on the dashboard"
370+
},
371+
"removeMobileAppBadges": {
372+
"message": "Remove Mobile App Badges"
373+
},
374+
"removeMobileAppBadges_description": {
375+
"message": "Removes the mobile app download badges from the dashboard"
376+
},
377+
"removeHelpLink": {
378+
"message": "Remove Help Link"
379+
},
380+
"removeHelpLink_description": {
381+
"message": "Removes the help link from the sidebar menu"
382+
},
383+
"showDateLogins": {
384+
"message": "Enable in Logins"
385+
},
386+
"showDateLogins_description": {
387+
"message": "Show Detailed Dates in Logins"
388+
},
389+
"showDataProfilePicture": {
390+
"message": "Enable in Profile Picture"
391+
},
392+
"showDataProfilePicture_description": {
393+
"message": "Show Detailed Dates in Profile Pictures page"
394+
},
395+
"schedule_teacher_name": {
396+
"message": "Show teacher's name"
397+
},
398+
"schedule_teacher_name_description": {
399+
"message": "Display the teacher's name in the schedule widget"
400+
},
401+
"schedule_room_number": {
402+
"message": "Show room number"
403+
},
404+
"schedule_room_number_description": {
405+
"message": "Display the room number in the schedule widget"
334406
}
335407
}

src/js/QoL.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ function QoL() {
22
this.initialize = function () {
33
// load feature flags from sync storage with defaults
44
chrome.storage.sync.get(null, (result) => {
5-
if (result.load_qol_css) this.loadQoLCss();
5+
window.syncedSettings = result;
6+
7+
if (result.load_qol_css) loadCssFile("/css/shkolo/QoL.css");
68
if (result.remove_ads) this.removeAds();
79
if (result.email_and_tel) this.emailAndTel();
810
if (result.messages_background_fix) this.messagesBackgroundFix();
@@ -25,17 +27,14 @@ function QoL() {
2527
});
2628
}
2729

28-
this.loadQoLCss = function () {
29-
loadCssFile("/css/shkolo/QoL.css");
30-
}
31-
3230
this.removeAds = function () {
3331
try {
34-
removeElements($(".btn.btn-lg.btn-e2e.red.huge"));
35-
removeElements($(".rank-descr"));
36-
removeElements($(".mobile-app-badges"));
37-
removeElements($(".mobile-app-link"));
38-
$("#help-link-in-menu").remove();
32+
let settings = window.syncedSettings || {};
33+
if (settings.sub_remove_statistics_button) removeElements($(".btn.btn-lg.btn-e2e.red.huge"));
34+
if (settings.sub_remove_rank_disclaimer) removeElements($(".rank-descr"));
35+
if (settings.sub_remove_mobile_app_badges) removeElements($(".mobile-app-badges"));
36+
if (settings.sub_remove_mobile_app_badges) removeElements($(".mobile-app-link"));
37+
if (settings.sub_remove_help_link) $("#help-link-in-menu").remove();
3938
} catch (error) {
4039
console.error(`[${manifest.name} v${version}][QoL]: Failed to remove ads. ERROR: ${error}`);
4140
}
@@ -90,30 +89,30 @@ function QoL() {
9089
const dotRegex = /\./g
9190
const dashRegex = /\-/g
9291

93-
if (pageurl.includes("/profile/logins")) {
92+
if (pageurl.includes("/profile/logins") && window.syncedSettings.sub_show_date_logins) {
9493
try {
9594
const table = $("#tab_logins > div:nth-child(2) > table > tbody > tr")
9695
for (let i = 0; i < table.length; i++) {
97-
this.detailsDate_element(table, i, 0, dotRegex);
96+
detailsDate_element(table, i, 0, dotRegex);
9897
}
9998
} catch (error) {
10099
console.error(`[${manifest.name} v${version}][QoL]: Failed to fix details date. ERROR: ${error}`)
101100
}
102101
}
103102

104-
if (pageurl.includes("/profile/pendingprofilepic")) {
103+
if (pageurl.includes("/profile/pendingprofilepic") && window.syncedSettings.sub_show_data_profile_picture) {
105104
try {
106105
const table = $("body > div.page-container > div.page-content-wrapper > div > div > div > div.profile-content > div > div.portlet-body > div:nth-child(2) > div > table > tbody > tr")
107106
for (let i = 0; i < table.length; i++) {
108-
this.detailsDate_element(table, i, 1, dashRegex, false);
107+
detailsDate_element(table, i, 1, dashRegex, false);
109108
}
110109
} catch (error) {
111110
console.error(`[${manifest.name} v${version}][QoL]: Failed to fix pending profile picture date. ERROR: ${error}`)
112111
}
113112
}
114113
}
115114

116-
this.detailsDate_element = function (table, i, columnIndex, char_to_replace, hasIcon = true) {
115+
function detailsDate_element(table, i, columnIndex, char_to_replace, hasIcon = true) {
117116
const dateElement = table[i].children[columnIndex].cloneNode(true)
118117
if (hasIcon) dateElement.children[0].remove()
119118
let dateElementText = dateElement.innerHTML.trim().replace(/^\s+|\s+$/g, '').replace(/\s{2,}/g, ' ')
@@ -200,10 +199,11 @@ function QoL() {
200199

201200
// Group settings by section
202201
const sections = {
203-
main_settings_options: { title: chrome.i18n.getMessage("appearanceSettingsTitle") || "Appearance Settings", items: [] },
204-
qol_settings_options: { title: chrome.i18n.getMessage("extendingFunctionalityTitle") || "Extending Functionality", items: [] },
205-
experimental_settings_options: { title: chrome.i18n.getMessage("beta_features_title") || "Experimental Features", items: [] },
206-
dev_settings_options: { title: chrome.i18n.getMessage("developer_settings") || "Developer Settings", items: [] }
202+
main_settings_options: { title: chrome.i18n.getMessage("shkolo_settings") || "Shkolo Settings", items: [], visible: currentValues.sub_settings_section_main !== false },
203+
qol_settings_options: { title: chrome.i18n.getMessage("QoLSettings") || "QoL Settings", items: [], visible: currentValues.sub_settings_section_qol !== false },
204+
experimental_settings_options: { title: chrome.i18n.getMessage("beta_features_title") || "Experimental Features", items: [], visible: currentValues.sub_settings_section_experimental !== false },
205+
mon_settings_options: { title: chrome.i18n.getMessage("mon_settings") || "MON Settings", items: [], visible: currentValues.sub_settings_section_mon !== false },
206+
dev_settings_options: { title: chrome.i18n.getMessage("developer_settings") || "Developer Settings", items: [], visible: currentValues.sub_settings_section_dev !== false }
207207
};
208208

209209
// Organize items by section
@@ -216,7 +216,7 @@ function QoL() {
216216
// Render each section
217217
Object.keys(sections).forEach(sectionKey => {
218218
const section = sections[sectionKey];
219-
if (section.items.length > 0) {
219+
if (section.visible && section.items.length > 0) {
220220
const heading = document.createElement("h3");
221221
heading.textContent = section.title;
222222
settingsContainerPortletBody.appendChild(heading);

src/js/widgets/schedule.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,23 +75,27 @@ function sc_DisplayDay(day, data) {
7575
}
7676
classInfo.appendChild(classTitle)
7777

78-
// Class Teacher (Ex. "Mrs. Raicheva", etc.)
79-
let classTeacher = document.createElement("span")
80-
classTeacher.innerHTML = " | " + dayData[i][1]
81-
classTeacher.classList.add("scheduleSecondary", "secondaryFirst")
82-
classInfo.appendChild(classTeacher)
78+
if (window.syncedSettings.sub_schedule_teacher_name) {
79+
// Class Teacher (Ex. "Mrs. Raicheva", etc.)
80+
let classTeacher = document.createElement("span")
81+
classTeacher.innerHTML = " | " + dayData[i][1]
82+
classTeacher.classList.add("scheduleSecondary", "secondaryFirst")
83+
classInfo.appendChild(classTeacher)
84+
}
8385

8486
classNode.appendChild(classInfo)
8587

8688
let rightInfo = document.createElement("span")
8789
rightInfo.classList.add("pull-right")
8890

89-
// Class Room (Ex. "Room 103", "Room 404", etc.)
90-
let classRoom = document.createElement("span");
91-
classRoom.innerHTML = dayData[i][2];
92-
classRoom.style.paddingRight = "12px";
93-
classRoom.classList.add("scheduleSecondary");
94-
rightInfo.appendChild(classRoom);
91+
if (window.syncedSettings.sub_schedule_room_number) {
92+
// Class Room (Ex. "Room 103", "Room 404", etc.)
93+
let classRoom = document.createElement("span");
94+
classRoom.innerHTML = dayData[i][2];
95+
classRoom.style.paddingRight = "12px";
96+
classRoom.classList.add("scheduleSecondary");
97+
rightInfo.appendChild(classRoom);
98+
}
9599

96100
// Class Time (Ex. "08:00 - 09:00", "09:00 - 10:00", etc.)
97101
if (dayData[i][3] !== undefined) {

src/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"name": "ShkoloTweaks",
44
"short_name": "ShTw",
55
"description": "__MSG_extDescription__",
6-
"version": "0.11.14",
7-
"version_name": "0.11.14 beta (G)",
6+
"version": "0.11.15",
7+
"version_name": "0.11.15 beta",
88
"author": "ITPG Web Studios",
99
"default_locale": "en",
1010
"homepage_url": "https://pishkisoriz.com/",

0 commit comments

Comments
 (0)