Add a `inject css` rule
Change-Id: I5d3051590bf9c0d205bd6cf1266bc8d68b1a3c95
diff --git a/src/content_script.ts b/src/content_script.ts
index 3d5478f..a375e53 100644
--- a/src/content_script.ts
+++ b/src/content_script.ts
@@ -130,6 +130,13 @@
const el = document.createElement('div');
el.innerHTML = rule.destination;
document.body.appendChild(el);
+ } else if (rule.operator === Operator.INJECT_CSS) {
+ onGerritReady().then(() => {
+ const link = document.createElement('link');
+ link.setAttribute('rel', 'stylesheet');
+ link.setAttribute('href', rule.destination);
+ document.head.appendChild(link);
+ });
} else if (rule.operator === Operator.INJECT_JS_PLUGIN) {
onGerritReady().then(() => {
const link = document.createElement('script');
diff --git a/src/popup.ts b/src/popup.ts
index a61307d..2d737d0 100644
--- a/src/popup.ts
+++ b/src/popup.ts
@@ -313,6 +313,7 @@
operators = [
Operator.BLOCK,
Operator.REDIRECT,
+ Operator.INJECT_CSS,
Operator.INJECT_HTML_CODE,
Operator.INJECT_JS_PLUGIN,
Operator.INJECT_JS_MODULE_PLUGIN,
diff --git a/src/utils.ts b/src/utils.ts
index 50a6ffd..50d739f 100644
--- a/src/utils.ts
+++ b/src/utils.ts
@@ -20,6 +20,7 @@
export function isInjectRule(rule: Rule) {
return [
+ Operator.INJECT_CSS,
Operator.INJECT_JS_MODULE_PLUGIN,
Operator.INJECT_JS_PLUGIN,
Operator.INJECT_HTML_CODE,
@@ -131,6 +132,7 @@
export enum Operator {
BLOCK = 'block',
REDIRECT = 'redirect',
+ INJECT_CSS = 'injectCss',
INJECT_HTML_CODE = 'injectHtmlCode',
INJECT_JS_PLUGIN = 'injectJSPlugin',
INJECT_JS_MODULE_PLUGIN = 'injectJSModule',