smitt04 / slack-dark-theme

Dark Theme for Slack
46 stars 6 forks source link

Custom css-file #12

Open KaffeMyers opened 5 years ago

KaffeMyers commented 5 years ago

Hi, I wanted another slack style, so sloppily amended the script as such:

  case "$1" in
    --revert)
      REVERT=true
      shift
      ;;
    *) CSSstyle="$1"
      shift
      ;;
  esac
done

[[ -z $CSSstyle ]] && CSSstyle=https://cdn.rawgit.com/laCour/slack-night-mode/master/css/raw/black.css

JS_START="// First make sure the wrapper app is loaded"

JS="
${JS_START}
document.addEventListener('DOMContentLoaded', function() {
  // Fetch our CSS in parallel ahead of time
  const cssPath = '$CSSstyle';
  let cssPromise = fetch(cssPath).then((response) => response.text());

Maybe something similar can be added to the "official version" to support other custom css styles.

l10nelw commented 5 years ago

Is there a reason why the css can't be in a local file? Trying to understand.

I tried the following in the script, didn't work:

CSS=$(<my-custom.css)
JS="
document.addEventListener('DOMContentLoaded', function() {
  // Insert a style tag into the wrapper view
  let s = document.createElement('style');
  s.type = 'text/css';
  s.innerHTML = `${CSS}`;
  document.head.appendChild(s);
});"