feat: save progress.
Now has a functional reader mode.
This commit is contained in:
parent
6ca97ba42f
commit
246128e0c9
|
@ -29,7 +29,7 @@
|
|||
#define BG_COLOR "#1E1E2E" /* or "#FEFEFE" if you are not using the dark theme. */
|
||||
#define WIDTH 500
|
||||
#define HEIGHT 400
|
||||
#define DEBUG false
|
||||
#define DEBUG true
|
||||
|
||||
typedef enum {
|
||||
goback,
|
||||
|
|
2
config.h
2
config.h
|
@ -30,7 +30,7 @@
|
|||
#define ZOOM 1.4 /* Starting zoom level.*/
|
||||
#define ZOOM_VAL .1 /* Zooming value in zoomin/zoomout functions */
|
||||
#define BG_COLOR "#FEFEFE" /*"#1E1E2E" */
|
||||
#define DEBUG false
|
||||
#define DEBUG true
|
||||
|
||||
typedef enum {
|
||||
goback,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#define LIBRE_N 19
|
||||
#define DEBUG false
|
||||
#define DEBUG true
|
||||
|
||||
/* Inspired by https://libredirect.github.io/, but in C. */
|
||||
|
||||
|
@ -33,7 +33,7 @@ int libre_redirect(const char* uri, char* output){
|
|||
"https://medium.com",
|
||||
"https://translate.google.com",
|
||||
"https://forum.effectivealtruism.org",
|
||||
// "https://www.bloomberg.com"
|
||||
"https://www.bloomberg.com"
|
||||
};
|
||||
char* alternatives[] = {
|
||||
"https://yt.artemislena.eu",
|
||||
|
@ -41,7 +41,7 @@ int libre_redirect(const char* uri, char* output){
|
|||
"https://scribe.rip",
|
||||
"https://simplytranslate.org/",
|
||||
"https://ea.greaterwrong.com",
|
||||
// "https://archive.is/https://www.bloomberg.com"
|
||||
"https://archive.is/https://www.bloomberg.com"
|
||||
};
|
||||
int n = sizeof(sites)/sizeof(sites[0]);
|
||||
for(int i=0; i<n ; i++){
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#define DEBUG false
|
||||
#define DEBUG true
|
||||
|
||||
/*
|
||||
See also:
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
Taken from <https://raw.githubusercontent.com/ushnisha/tranquility-reader-webextensions/master/content_scripts/tranquilize.js>
|
||||
Taken from <https://raw.githubusercontent.com/ushnisha/readability-reader-webextensions/master/content_scripts/tranquilize.js>
|
||||
|
||||
The file has 46193 characters. Or 46194 including the line terminator.
|
||||
|
|
Binary file not shown.
29
plugins/readability/readability.c
Normal file
29
plugins/readability/readability.c
Normal file
|
@ -0,0 +1,29 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define READABILITY_N 83750
|
||||
|
||||
void read_readability_js(char* string){
|
||||
FILE *fp=fopen("/home/loki/Documents/core/software/fresh/C/rose-browser/rose-bud-personal/plugins/readability/readability.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(READABILITY_N+1);
|
||||
read_readability_js(readability_js);
|
||||
printf("%s", readability_js);
|
||||
free(readability_js);
|
||||
}
|
||||
*/
|
8
plugins/readability/readability.h
Normal file
8
plugins/readability/readability.h
Normal file
|
@ -0,0 +1,8 @@
|
|||
#ifndef READABILITY
|
||||
#define READABILITY
|
||||
|
||||
#define READABILITY_N 83750
|
||||
|
||||
void read_readability_js(char* string);
|
||||
|
||||
#endif
|
2326
plugins/readability/readability.js
Normal file
2326
plugins/readability/readability.js
Normal file
File diff suppressed because it is too large
Load Diff
8
plugins/readability/recompute_READABILITY_N.sh
Normal file
8
plugins/readability/recompute_READABILITY_N.sh
Normal file
|
@ -0,0 +1,8 @@
|
|||
#!/bin/bash
|
||||
function sedr(){
|
||||
find ./ -type f -exec sed -i -e "$1" {} \;
|
||||
} ## e.g., sedr "s/target/replacement/g"
|
||||
|
||||
READABILITY_N=$(wc -c readability.js | cut -d " " -f 1)
|
||||
sedr "s/^#define READABILITY_N .*/#define READABILITY_N $READABILITY_N/g"
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
(() => {
|
||||
'use strict';
|
||||
|
||||
const addStyle = (() => {
|
||||
const parent = document.head || document.body || document.documentElement;
|
||||
|
||||
const style = document.createElement('style');
|
||||
style.type = 'text/css';
|
||||
parent.appendChild(style);
|
||||
|
||||
return (css) => {
|
||||
style.appendChild(document.createTextNode(css + '\n'));
|
||||
};
|
||||
})();
|
||||
|
||||
Array.from(document.styleSheets, (css) => css.disabled = true);
|
||||
|
||||
// like a Firefox Reader View
|
||||
const nightmode = `
|
||||
* {
|
||||
margin-top: initial !important;
|
||||
padding-top: initial !important;
|
||||
}
|
||||
body {
|
||||
margin-left: auto !important;
|
||||
margin-right: auto !important;
|
||||
max-width: 70% !important;
|
||||
font-size: 1.6em !important;
|
||||
line-height: 1.25em !important;
|
||||
background-color: #343A3A !important;
|
||||
color: #FDFDFD !important;
|
||||
white-space: pre-line !important;
|
||||
}
|
||||
h1 {
|
||||
line-height: 1em !important;
|
||||
}
|
||||
a {
|
||||
color: lightskyblue !important;
|
||||
background-color: initial !important;
|
||||
}
|
||||
img {
|
||||
max-width: 100% !important;
|
||||
}
|
||||
pre, code {
|
||||
white-space: pre-wrap !important;
|
||||
}
|
||||
`;
|
||||
|
||||
addStyle(nightmode);
|
||||
})();
|
|
@ -1,30 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define TRANQUILITY_N 46288
|
||||
|
||||
void read_tranquility_js(char* string){
|
||||
FILE *fp=fopen("/home/loki/Documents/core/software/fresh/C/rose-browser/rose-bud-personal/plugins/tranquility/snippet.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* tranquility_js = malloc(TRANQUILITY_N+1);
|
||||
read_tranquility_js(tranquility_js);
|
||||
printf("%s", tranquility_js);
|
||||
free(tranquility_js);
|
||||
|
||||
}
|
||||
*/
|
|
@ -1,8 +0,0 @@
|
|||
#ifndef TRANQUILITY
|
||||
#define TRANQUILITY
|
||||
|
||||
#define TRANQUILITY_N 46288
|
||||
|
||||
void read_tranquility_js(char* string);
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
18
rose.c
18
rose.c
|
@ -15,7 +15,7 @@
|
|||
|
||||
#include "config.h"
|
||||
#include "plugins/libre_redirect/libre_redirect.h"
|
||||
#include "plugins/tranquility/tranquility.h"
|
||||
#include "plugins/readability/readability.h"
|
||||
|
||||
#define CACHE \
|
||||
"base-cache-directory", CACHE_DIR, \
|
||||
|
@ -275,19 +275,21 @@ int handle_key(func id, GtkNotebook *notebook)
|
|||
webkit_web_view_get_find_controller(notebook_get_webview(notebook)));
|
||||
break;
|
||||
case prettify:{
|
||||
printf("prettify\n");
|
||||
webkit_web_view_run_javascript(notebook_get_webview(notebook),
|
||||
if(DEBUG){
|
||||
printf("prettify\n");
|
||||
webkit_web_view_run_javascript(notebook_get_webview(notebook),
|
||||
"alert('Tranquilizing!')",
|
||||
NULL, NULL, NULL);
|
||||
char* tranquility_js = malloc(TRANQUILITY_N+1);
|
||||
read_tranquility_js(tranquility_js);
|
||||
}
|
||||
char* readability_js = malloc(READABILITY_N+1);
|
||||
read_readability_js(readability_js);
|
||||
webkit_web_view_run_javascript(notebook_get_webview(notebook),
|
||||
tranquility_js,
|
||||
readability_js,
|
||||
NULL, NULL, NULL);
|
||||
free(tranquility_js);
|
||||
free(readability_js);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
|
Loading…
Reference in New Issue
Block a user