aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTeddy Wing2019-05-01 15:14:37 +0200
committerTeddy Wing2019-05-01 15:14:37 +0200
commit33f83a17badb4586c0eb0e3b78aef9c8debe371f (patch)
tree1c7cd2c9605301ff38df1842ac1e5fd51ad81fb4 /src
parent10fa99186f46435c179ec6cfdbe2407f5a04f7a4 (diff)
downloadmuttagen-33f83a17badb4586c0eb0e3b78aef9c8debe371f.tar.bz2
Move code to "style.ts"
* Create a separate module for the CSS style-related code. * Use `commonjs` module format instead of `amd` so that the resulting output file can be used (hopefully) without modification directly in the browser.
Diffstat (limited to 'src')
-rw-r--r--src/index.ts8
-rw-r--r--src/style.ts35
2 files changed, 43 insertions, 0 deletions
diff --git a/src/index.ts b/src/index.ts
new file mode 100644
index 0000000..e5c3103
--- /dev/null
+++ b/src/index.ts
@@ -0,0 +1,8 @@
+// ==UserScript==
+// @name Muttagen
+// @description Gmail user script providing Mutt features
+// @namespace com.teddywing
+// @match https://mail.google.com/*
+// ==/UserScript==
+
+import "./style.ts";
diff --git a/src/style.ts b/src/style.ts
new file mode 100644
index 0000000..93ce355
--- /dev/null
+++ b/src/style.ts
@@ -0,0 +1,35 @@
+type GmailCSSClass = string;
+
+const TOOLS_PANEL: GmailCSSClass = 'bAw';
+const SIDEBAR: GmailCSSClass = 'aeN';
+const MESSAGE_PAGER: GmailCSSClass = 'AO';
+
+
+type GmailCSSDefinitions = { [selector in GmailCSSClass]: string };
+
+var css: GmailCSSDefinitions = {};
+css[TOOLS_PANEL] = 'display: none;';
+css[MESSAGE_PAGER] = 'filter: invert(100%);';
+
+function construct_css(css: GmailCSSDefinitions): string {
+ var joined = '';
+
+ for (var selector in css) {
+ joined += `.${selector} { ${css[selector]} }`;
+ }
+
+ return joined;
+}
+
+function append_css(css: string): void {
+ var s = document.createElement('style');
+ var t = document.createTextNode(css);
+
+ s.appendChild(t);
+
+ document.head.appendChild(s);
+}
+
+append_css(
+ construct_css(css)
+);