From ca59138a2aef96960381f986b8c683634e4d8e63 Mon Sep 17 00:00:00 2001 From: NunoSempere Date: Tue, 28 Mar 2023 11:18:54 -0600 Subject: tweak: move things around --- src/plugins/style/README.md | 5 ++++ src/plugins/style/recompute_STYLE_N.sh | 8 ++++++ src/plugins/style/style.c | 30 +++++++++++++++++++++ src/plugins/style/style.h | 8 ++++++ src/plugins/style/style.js | 49 ++++++++++++++++++++++++++++++++++ 5 files changed, 100 insertions(+) create mode 100644 src/plugins/style/README.md create mode 100755 src/plugins/style/recompute_STYLE_N.sh create mode 100644 src/plugins/style/style.c create mode 100644 src/plugins/style/style.h create mode 100644 src/plugins/style/style.js (limited to 'src/plugins/style') 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: . +- 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 +#include +#include +#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: + +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" -- cgit v1.2.3