feat: add plugin to customize css for individual websites...
and how to enable it. Also tweak README.mds
This commit is contained in:
parent
be043958f0
commit
353d0ffad7
|
@ -18,10 +18,3 @@ Rose is released under own license, which grants the following permissions:
|
||||||
- Distribution
|
- Distribution
|
||||||
- Modification
|
- Modification
|
||||||
- Private use
|
- Private use
|
||||||
|
|
||||||
### To do
|
|
||||||
|
|
||||||
- [x] Add open in new tab functionality
|
|
||||||
- [x] Test open in new tab functionality
|
|
||||||
- [x] Add styles tab
|
|
||||||
- [ ] Isolate plugins so that they aren't active by default
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ To enable it:
|
||||||
|
|
||||||
## In build.sh
|
## In build.sh
|
||||||
|
|
||||||
Uncomment this line:
|
In `build.sh`, uncomment this line:
|
||||||
|
|
||||||
```
|
```
|
||||||
REQS= #./plugins/*/*.c
|
REQS= #./plugins/*/*.c
|
||||||
|
@ -52,4 +52,4 @@ void redirect_if_annoying(WebKitWebView *view, const char *uri){
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
|
@ -5,7 +5,13 @@ Taken from <https://raw.githubusercontent.com/ushnisha/readability-reader-webext
|
||||||
|
|
||||||
## To enable it
|
## To enable it
|
||||||
|
|
||||||
In rose.c uncomment:
|
In `build.sh`, uncomment this line:
|
||||||
|
|
||||||
|
```
|
||||||
|
REQS= #./plugins/*/*.c
|
||||||
|
```
|
||||||
|
|
||||||
|
In `rose.c` uncomment:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -59,4 +65,4 @@ typedef enum {
|
||||||
// { CTRL, KEY(p), prettify },
|
// { CTRL, KEY(p), prettify },
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
34
plugins/style/README.md
Normal file
34
plugins/style/README.md
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
## 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.
|
||||||
|
|
||||||
|
## To enable it
|
||||||
|
|
||||||
|
In `build.sh`, uncomment this line:
|
||||||
|
|
||||||
|
```
|
||||||
|
REQS= #./plugins/*/*.c
|
||||||
|
```
|
||||||
|
|
||||||
|
In `rose.c`, uncomment:
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
// #include "plugins/style/style.h"
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
// Add custom style
|
||||||
|
/*
|
||||||
|
char* style_js = malloc(STYLE_N+1);
|
||||||
|
read_style_js(style_js);
|
||||||
|
webkit_web_view_run_javascript(notebook_get_webview(notebook),
|
||||||
|
style_js,
|
||||||
|
NULL, NULL, NULL);
|
||||||
|
free(style_js);
|
||||||
|
*/
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
You will also want to customize the `style.c` file.
|
8
plugins/style/recompute_STYLE_N.sh
Executable file
8
plugins/style/recompute_STYLE_N.sh
Executable file
|
@ -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"
|
||||||
|
|
29
plugins/style/style.c
Normal file
29
plugins/style/style.c
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#define STYLE_N 794 + 1
|
||||||
|
|
||||||
|
void read_style_js(char* string){
|
||||||
|
FILE *fp=fopen("/home/loki/Documents/core/software/fresh/C/rose-browser/rose-bud-personal/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);
|
||||||
|
}
|
||||||
|
*/
|
8
plugins/style/style.h
Normal file
8
plugins/style/style.h
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#ifndef STYLE
|
||||||
|
#define STYLE
|
||||||
|
|
||||||
|
#define STYLE_N 794 + 1
|
||||||
|
|
||||||
|
void read_style_js(char* string);
|
||||||
|
|
||||||
|
#endif
|
26
plugins/style/style.js
Normal file
26
plugins/style/style.js
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
// Replicates the Stylus app: <https://addons.mozilla.org/en-GB/firefox/addon/styl-us/>
|
||||||
|
|
||||||
|
if (document.domain == "forum.effectivealtruism.org"){
|
||||||
|
var 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')
|
||||||
|
}
|
||||||
|
|
||||||
|
document.body.style.visibility = "visible"
|
10
rose.c
10
rose.c
|
@ -14,6 +14,7 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
// #include "plugins/libre_redirect/libre_redirect.h"
|
// #include "plugins/libre_redirect/libre_redirect.h"
|
||||||
// #include "plugins/readability/readability.h"
|
// #include "plugins/readability/readability.h"
|
||||||
|
// #include "plugins/style/style.h"
|
||||||
|
|
||||||
#define CACHE \
|
#define CACHE \
|
||||||
"base-cache-directory", CACHE_DIR, \
|
"base-cache-directory", CACHE_DIR, \
|
||||||
|
@ -106,6 +107,15 @@ void load_changed(WebKitWebView *self, WebKitLoadEvent load_event, GtkNotebook *
|
||||||
break;
|
break;
|
||||||
case WEBKIT_LOAD_COMMITTED:
|
case WEBKIT_LOAD_COMMITTED:
|
||||||
// redirect_if_annoying(self, webkit_web_view_get_uri(self));
|
// redirect_if_annoying(self, webkit_web_view_get_uri(self));
|
||||||
|
// Add custom style
|
||||||
|
/*
|
||||||
|
char* style_js = malloc(STYLE_N+1);
|
||||||
|
read_style_js(style_js);
|
||||||
|
webkit_web_view_run_javascript(notebook_get_webview(notebook),
|
||||||
|
style_js,
|
||||||
|
NULL, NULL, NULL);
|
||||||
|
free(style_js);
|
||||||
|
*/
|
||||||
break;
|
break;
|
||||||
case WEBKIT_LOAD_FINISHED:
|
case WEBKIT_LOAD_FINISHED:
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user