@@ -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 ) ;
0 commit comments