class WebviewUtil {
  static const jsEnableDarkMode = '''
      try {
        for (let s = 0; s < window.document.styleSheets.length; s++) {
          for (let i = 0; i < window.document.styleSheets[s].cssRules.length; i++) {
            const rule = window.document.styleSheets[s].cssRules[i];

            if (rule?.media?.mediaText?.includes('prefers-color-scheme')) {
              rule.media.appendMedium('(prefers-color-scheme: light)');
              rule.media.appendMedium('(prefers-color-scheme: dark)');

              if (rule.media.mediaText.includes('original')) {
                rule.media.deleteMedium("original-prefers-color-scheme");
              }
            }
          }
        }
      } catch (err) {}
    ''';
}
