aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/style
diff options
context:
space:
mode:
authorNunoSempere <nuno.sempere@protonmail.com>2023-03-28 11:18:54 -0600
committerNunoSempere <nuno.sempere@protonmail.com>2023-03-28 11:18:54 -0600
commitca59138a2aef96960381f986b8c683634e4d8e63 (patch)
tree16c62f8a2b3bfe7ad55053294095f70a85d19613 /src/plugins/style
parentcc959fda4fac18f1c429158d1ffea24692276310 (diff)
tweak: move things around
Diffstat (limited to 'src/plugins/style')
-rw-r--r--src/plugins/style/README.md5
-rwxr-xr-xsrc/plugins/style/recompute_STYLE_N.sh8
-rw-r--r--src/plugins/style/style.c30
-rw-r--r--src/plugins/style/style.h8
-rw-r--r--src/plugins/style/style.js49
5 files changed, 100 insertions, 0 deletions
diff --git a/src/plugins/style/README.md b/src/plugins/style/README.md
new file mode 100644
index 0000000..e0aad62
--- /dev/null
+++ b/src/plugins/style/README.md
@@ -0,0 +1,5 @@
+## Customize css style for individual websites.
+
+- Replicates: <https://addons.mozilla.org/en-GB/firefox/addon/styl-us/>.
+- The template is similar to the readability folder.
+- You will also want to customize the `style.c` file.
diff --git a/src/plugins/style/recompute_STYLE_N.sh b/src/plugins/style/recompute_STYLE_N.sh
new file mode 100755
index 0000000..906aad8
--- /dev/null
+++ b/src/plugins/style/recompute_STYLE_N.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+function sedr(){
+ find ./ -type f -exec sed -i -e "$1" {} \;
+} ## e.g., sedr "s/target/replacement/g"
+
+STYLE_N=$(wc -c style.js | cut -d " " -f 1)
+sedr "s/^#define STYLE_N .*/#define STYLE_N $STYLE_N + 1/g"
+
diff --git a/src/plugins/style/style.c b/src/plugins/style/style.c
new file mode 100644
index 0000000..1010506
--- /dev/null
+++ b/src/plugins/style/style.c
@@ -0,0 +1,30 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#define STYLE_N 1393 + 1
+
+void read_style_js(char* string)
+{
+ FILE* fp = fopen("/home/loki/Documents/core/software/fresh/C/rose-browser/rosenrot/plugins/style/style.js", "r");
+ if (!fp) { // fp is NULL, fopen failed
+ fprintf(stderr, "Failed to open file\n");
+ string = NULL;
+ return;
+ }
+ int i = 0;
+ int c;
+ while ((c = fgetc(fp)) != EOF) {
+ string[i++] = c;
+ }
+ string[i] = '\0';
+ fclose(fp);
+}
+
+/*
+int main(){
+ char* readability_js = malloc(STYLE_N+1);
+ read_readability_js(readability_js);
+ printf("%s", readability_js);
+ free(readability_js);
+}
+*/
diff --git a/src/plugins/style/style.h b/src/plugins/style/style.h
new file mode 100644
index 0000000..5e5d76b
--- /dev/null
+++ b/src/plugins/style/style.h
@@ -0,0 +1,8 @@
+#ifndef STYLE
+#define STYLE
+
+#define STYLE_N 1393 + 1
+
+void read_style_js(char* string);
+
+#endif
diff --git a/src/plugins/style/style.js b/src/plugins/style/style.js
new file mode 100644
index 0000000..bc0540e
--- /dev/null
+++ b/src/plugins/style/style.js
@@ -0,0 +1,49 @@
+// Replicates the Stylus app: <https://addons.mozilla.org/en-GB/firefox/addon/styl-us/>
+
+var styles = null;
+
+if (document.domain == "forum.effectivealtruism.org"){
+ styles = `
+ .Layout-main {
+ margin-left: 100px;
+ }
+ .SingleColumnSection-root {
+ width: 1000px !important;
+ max-width: 1400px !important;
+ padding-left: 100px !important;
+ }
+ .NavigationStandalone-sidebar {
+ display: none;
+ }
+ .intercom-lightweight-app{
+ display: none;
+ }
+ `
+ var styleSheet = document.createElement('style')
+ styleSheet.innerText = styles
+ document.head.appendChild(styleSheet)
+ console.log('Style changed')
+}
+
+if (document.domain == "mail.proton.me" ){
+ styles = `
+ .item-container-row.read, .item-container.read {
+ background-color: white;
+ }
+ .item-container-row.unread, .item-container.unread {
+ background-color: #E8E8E8;
+ }
+ .selection .item-container-row.item-is-selected, .item-container.item-is-selected {
+ background-color: var(--selection-background-color) !important;
+ }
+ `
+}
+
+if(styles != null){
+ var styleSheet = document.createElement('style')
+ styleSheet.innerText = styles
+ document.head.appendChild(styleSheet)
+ console.log('Style changed')
+}
+
+document.body.style.visibility = "visible"