Compare commits
56 Commits
Author | SHA1 | Date | |
---|---|---|---|
1e45fb881b | |||
00113a38f4 | |||
707b84492c | |||
14cae1987c | |||
b3a0f14b2f | |||
4958d9eeaa | |||
4da5aad23e | |||
dfa4b299a4 | |||
f8ed7f9ef7 | |||
c27525cc32 | |||
8790adb0fc | |||
350e6022df | |||
ca5438c626 | |||
cd6b158e3e | |||
31be29c7cb | |||
7fa7698265 | |||
0a7ab47224 | |||
38c5c0fb47 | |||
f27979ab6f | |||
4e153dd592 | |||
246128e0c9 | |||
6ca97ba42f | |||
fdb4ad7ced | |||
254b0ed658 | |||
5366c5d636 | |||
54fffb3b66 | |||
a5394e8a88 | |||
d3caecab58 | |||
a6835ab2ae | |||
21e5800bbe | |||
d25a6e7e79 | |||
618262d2a2 | |||
7c155525fd | |||
76ab73e38c | |||
304b4b274c | |||
9ca14fb3d4 | |||
892b3d3d41 | |||
29c07b9cbb | |||
b2b3acf140 | |||
109d641017 | |||
4b2b46149c | |||
4dffbbae14 | |||
747499de2e | |||
0cbb1d97a9 | |||
c9a81029da | |||
a08755d8c9 | |||
0d9b05b7ec | |||
c88b56d6c7 | |||
f89ef9951f | |||
fbf45c5c80 | |||
2f447f0b7b | |||
235e535008 | |||
19d8b63387 | |||
efb0491d1b | |||
bc3bb429bd | |||
bebfbeb71c |
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,3 +1,3 @@
|
||||||
rose
|
rose
|
||||||
config.h
|
# config.h
|
||||||
.clang-format
|
.clang-format
|
||||||
|
|
50
README.md
50
README.md
|
@ -1,21 +1,37 @@
|
||||||
<h3 align=center> Rose Browser</h1>
|
## Rosebud
|
||||||
<h4 align=center>Minimal browser based on webkit2gtk</h4>
|
|
||||||
|
Personal tweaks for [rose](https://github.com/mini-rose/rose), a minimal browser based on webkit2gtk
|
||||||
|
|
||||||
#### Features
|
#### Features
|
||||||
- tabs, cookies, caching
|
|
||||||
- minimal ui, autohiding elements
|
|
||||||
- ~400L code base
|
|
||||||
- custom gtk and websites css
|
|
||||||
- hackable without any knowledge
|
|
||||||
- builtin rose-mklink script for in-shell static links
|
|
||||||
|
|
||||||
#
|
- tabs, cookies, caching
|
||||||
### 👐 Contribute
|
- minimal ui, autohiding elements
|
||||||
See [contributing.md](https://github.com/mini-rose/rose/.github/contributing.md).
|
- ~400L code base (edit: no longer)
|
||||||
|
- custom gtk and websites css
|
||||||
|
- hackable without any knowledge
|
||||||
|
- builtin rose-mklink script for in-shell static links
|
||||||
|
- A few quality of life improvements.
|
||||||
|
|
||||||
### 📜 License
|
### 👐 Contribute
|
||||||
Rose is released under own license, which grants the following permissions:
|
This is my personal version. Contribute upstream to [github.com/mini-rose/rose](https://github.com/mini-rose/) instead.
|
||||||
- Commercial use
|
|
||||||
- Distribution
|
### To do
|
||||||
- Modification
|
|
||||||
- Private use
|
- [ ] Find out what each of the css elements refers to.
|
||||||
|
- [ ] Use something other than Whatsapp as an example syslink.
|
||||||
|
|
||||||
|
Done:
|
||||||
|
- [x] String substitution on uri in order to redirect to better frontends.
|
||||||
|
- [x] Present "standard" browser keybindings as an alternative.
|
||||||
|
- [x] Fix zoom in new tab
|
||||||
|
- [x] Reader mode
|
||||||
|
- [x] Add reader mode to config.def.
|
||||||
|
- [x] Make tab bar slightly prettier.
|
||||||
|
- [x] Add "open in new window" functionality.
|
||||||
|
- Useful for opening links in new tab when clicking on them and selecting that option
|
||||||
|
- And for actually opening links with the href newtab option.
|
||||||
|
- Links: <https://docs.gtk.org/gobject/func.signal_connect.html>, <https://webkitgtk.org/reference/webkit2gtk/2.37.90/signal.AutomationSession.create-web-view.html>, <https://webkitgtk.org/reference/webkit2gtk/2.26.0/WebKitWebView.html#WebKitWebView-create> <https://stackoverflow.com/questions/40180757/webkit2gtk-get-new-window-link>
|
||||||
|
|
||||||
|
### Known bugs
|
||||||
|
|
||||||
|
- [ ] Doesn't work with when Spanish is selected as the language, for some reason.
|
||||||
|
|
7
build.sh
7
build.sh
|
@ -1,6 +1,10 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
CC=clang
|
CC=clang
|
||||||
SRC=rose.c
|
SRC=rose.c
|
||||||
|
REQS=./plugins/*/*.c
|
||||||
DEPS=('webkit2gtk-4.0')
|
DEPS=('webkit2gtk-4.0')
|
||||||
|
DEBUG="" # set to "-g" for debug mode.
|
||||||
|
|
||||||
INCS=`pkg-config --cflags ${DEPS[@]}`
|
INCS=`pkg-config --cflags ${DEPS[@]}`
|
||||||
LIBS=`pkg-config --libs ${DEPS[@]}`
|
LIBS=`pkg-config --libs ${DEPS[@]}`
|
||||||
|
@ -8,4 +12,5 @@ LIBS=`pkg-config --libs ${DEPS[@]}`
|
||||||
# Optional adblocking depends on https://github.com/jun7/wyebadblock
|
# Optional adblocking depends on https://github.com/jun7/wyebadblock
|
||||||
WYEBAB='-L/usr/lib/wyebrowser/adblock.so'
|
WYEBAB='-L/usr/lib/wyebrowser/adblock.so'
|
||||||
|
|
||||||
$CC $INCS $LIBS $SRC $WYEBAB -o rose
|
# echo $CC $INCS $LIBS $SRC $REQS $WYEBAB -o rose
|
||||||
|
$CC $DEBUG $INCS $LIBS $SRC $REQS $WYEBAB -o rose
|
||||||
|
|
55
config.def.h
55
config.def.h
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2022 mini-rose
|
* Copyright (c) 2022 Nuño Sempere.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person
|
* Permission is hereby granted, free of charge, to any person
|
||||||
* obtaining a copy of this software and any associated documentation
|
* obtaining a copy of this software and any associated documentation
|
||||||
|
@ -7,10 +7,10 @@
|
||||||
* sublicense copies of this sotware for their own use.
|
* sublicense copies of this sotware for their own use.
|
||||||
* This code does not come with any warranty.
|
* This code does not come with any warranty.
|
||||||
*
|
*
|
||||||
* Author: fenze <contact@fenze.dev>
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <gdk/gdkkeysyms.h>
|
#include <gdk/gdkkeysyms.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
/* See more:
|
/* See more:
|
||||||
* https://webkitgtk.org/reference/webkit2gtk/stable/class.Settings.html */
|
* https://webkitgtk.org/reference/webkit2gtk/stable/class.Settings.html */
|
||||||
|
@ -18,16 +18,19 @@
|
||||||
"enable-back-forward-navigation-gestures", true, "enable-developer-extras", true, \
|
"enable-back-forward-navigation-gestures", true, "enable-developer-extras", true, \
|
||||||
"enable-smooth-scrolling", false
|
"enable-smooth-scrolling", false
|
||||||
|
|
||||||
#define GTK "gtk-application-prefer-dark-theme", true, "gtk-enable-animations", false
|
#define GTK "gtk-application-prefer-dark-theme", false, "gtk-enable-animations", false
|
||||||
|
#define ROSE_HOMEPAGE true
|
||||||
#define HOME "https://duckduckgo.com"
|
#define HOME ROSE_HOMEPAGE ? "file:///home/loki/Documents/core/software/fresh/C/rose-browser/rose-bud-personal/user-scripts/ubuntu-20.04/rose-images/rose-homepage.png" : "https://lite.duckduckgo.com/html"
|
||||||
#define SEARCH "https://duckduckgo.com/?q=%s"
|
#define SEARCH "https://lite.duckduckgo.com/html/?q=%s"
|
||||||
#define CACHE_DIR "/home/fenze/.cache/rose"
|
#define CACHE_DIR "/home/your_username/.cache/rose"
|
||||||
|
|
||||||
|
#define WIDTH 1920
|
||||||
|
#define HEIGHT 1080
|
||||||
#define KEY(x) GDK_KEY_##x
|
#define KEY(x) GDK_KEY_##x
|
||||||
#define ZOOM 1 /* Starting zoom level */
|
#define ZOOM 1.4 /* Starting zoom level.*/
|
||||||
#define ZOOM_VAL .1 /* Zooming value in zoomin/zoomout functions */
|
#define ZOOM_VAL .1 /* Zooming value in zoomin/zoomout functions */
|
||||||
#define BG_COLOR "#1E1E2E"
|
#define BG_COLOR "#FEFEFE" /* "#1E1E2E" */
|
||||||
|
#define DEBUG false
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
goback,
|
goback,
|
||||||
|
@ -43,9 +46,11 @@ typedef enum {
|
||||||
prev_tab,
|
prev_tab,
|
||||||
close_tab,
|
close_tab,
|
||||||
show_searchbar,
|
show_searchbar,
|
||||||
|
hide_searchbar,
|
||||||
show_finder,
|
show_finder,
|
||||||
finder_next,
|
finder_next,
|
||||||
finder_prev
|
finder_prev,
|
||||||
|
prettify
|
||||||
} func;
|
} func;
|
||||||
|
|
||||||
#define SFT 1 << 0
|
#define SFT 1 << 0
|
||||||
|
@ -57,6 +62,31 @@ static struct {
|
||||||
unsigned key;
|
unsigned key;
|
||||||
func id;
|
func id;
|
||||||
} keys[] = {
|
} keys[] = {
|
||||||
|
{ CTRL, KEY(h), goback },
|
||||||
|
{ CTRL, KEY(j), goforward },
|
||||||
|
{ CTRL, KEY(r), refresh },
|
||||||
|
{ CTRL | SFT, KEY(R), refresh_force },
|
||||||
|
{ CTRL | SFT, KEY(H), back_to_home },
|
||||||
|
{ CTRL, KEY(equal), zoomin },
|
||||||
|
{ CTRL, KEY(minus), zoomout },
|
||||||
|
{ CTRL, KEY(0), zoom_reset },
|
||||||
|
{ CTRL, KEY(Page_Down), prev_tab },
|
||||||
|
{ CTRL, KEY(Page_Up), next_tab },
|
||||||
|
{ CTRL, KEY(t), next_tab },
|
||||||
|
{ CTRL, KEY(w), close_tab },
|
||||||
|
{ 0x0, KEY(F11), toggle_fullscreen },
|
||||||
|
{ CTRL, KEY(l), show_searchbar },
|
||||||
|
{ CTRL, KEY(k), hide_searchbar },
|
||||||
|
{ CTRL, KEY(f), show_finder },
|
||||||
|
{ CTRL, KEY(n), finder_next },
|
||||||
|
{ CTRL | SFT, KEY(N), finder_prev },
|
||||||
|
{ CTRL, KEY(p), prettify }
|
||||||
|
};
|
||||||
|
/* ^ The controls above try to be similar to those in normal browsers */
|
||||||
|
/* Reference for the key shorthand:
|
||||||
|
* <https://gitlab.gnome.org/GNOME/gtk/-/blob/main/gdk/gdkkeysyms.h> */
|
||||||
|
|
||||||
|
/* Alternative controls: {
|
||||||
{ CTRL, KEY(h), goback },
|
{ CTRL, KEY(h), goback },
|
||||||
{ CTRL, KEY(l), goforward },
|
{ CTRL, KEY(l), goforward },
|
||||||
{ CTRL, KEY(r), refresh },
|
{ CTRL, KEY(r), refresh },
|
||||||
|
@ -66,11 +96,14 @@ static struct {
|
||||||
{ CTRL, KEY(minus), zoomout },
|
{ CTRL, KEY(minus), zoomout },
|
||||||
{ CTRL, KEY(0), zoom_reset },
|
{ CTRL, KEY(0), zoom_reset },
|
||||||
{ ALT, KEY(h), prev_tab },
|
{ ALT, KEY(h), prev_tab },
|
||||||
|
{ CTRL, KEY(k), hide_searchbar },
|
||||||
{ ALT, KEY(l), next_tab },
|
{ ALT, KEY(l), next_tab },
|
||||||
{ CTRL, KEY(w), close_tab },
|
{ CTRL, KEY(w), close_tab },
|
||||||
{ 0x0, KEY(F11), toggle_fullscreen },
|
{ 0x0, KEY(F11), toggle_fullscreen },
|
||||||
{ CTRL, KEY(e), show_searchbar },
|
{ CTRL, KEY(e), show_searchbar },
|
||||||
{ CTRL, KEY(f), show_finder },
|
{ CTRL, KEY(f), show_finder },
|
||||||
{ CTRL, KEY(n), finder_next },
|
{ CTRL, KEY(n), finder_next },
|
||||||
{ CTRL | SFT, KEY(N), finder_prev }
|
{ CTRL | SFT, KEY(N), finder_prev },
|
||||||
|
{ CTRL, KEY(p), prettify }
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
|
109
config.h
Normal file
109
config.h
Normal file
|
@ -0,0 +1,109 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 Nuño Sempere.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person
|
||||||
|
* obtaining a copy of this software and any associated documentation
|
||||||
|
* files to modify, copy, merge, publish, distribute and/or
|
||||||
|
* sublicense copies of this sotware for their own use.
|
||||||
|
* This code does not come with any warranty.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <gdk/gdkkeysyms.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
/* See more:
|
||||||
|
* https://webkitgtk.org/reference/webkit2gtk/stable/class.Settings.html */
|
||||||
|
#define WEBKIT \
|
||||||
|
"enable-back-forward-navigation-gestures", true, "enable-developer-extras", true, \
|
||||||
|
"enable-smooth-scrolling", false
|
||||||
|
|
||||||
|
#define GTK "gtk-application-prefer-dark-theme", false, "gtk-enable-animations", false
|
||||||
|
#define ROSE_HOMEPAGE true
|
||||||
|
#define HOME ROSE_HOMEPAGE ? "file:///home/loki/Documents/core/software/fresh/C/rose-browser/rose-bud-personal/user-scripts/ubuntu-20.04/rose-images/rose-homepage.png" : "https://lite.duckduckgo.com/html"
|
||||||
|
#define SEARCH "https://lite.duckduckgo.com/html/?q=%s"
|
||||||
|
#define CACHE_DIR "/home/loki/.cache/rose"
|
||||||
|
|
||||||
|
#define WIDTH 1920
|
||||||
|
#define HEIGHT 1080
|
||||||
|
#define KEY(x) GDK_KEY_##x
|
||||||
|
#define ZOOM 1.4 /* Starting zoom level.*/
|
||||||
|
#define ZOOM_VAL .1 /* Zooming value in zoomin/zoomout functions */
|
||||||
|
#define BG_COLOR "#FEFEFE" /* "FEFEFE", "#1E1E2E" */
|
||||||
|
#define DEBUG false
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
goback,
|
||||||
|
goforward,
|
||||||
|
refresh,
|
||||||
|
refresh_force,
|
||||||
|
back_to_home,
|
||||||
|
toggle_fullscreen,
|
||||||
|
zoomin,
|
||||||
|
zoomout,
|
||||||
|
zoom_reset,
|
||||||
|
next_tab,
|
||||||
|
prev_tab,
|
||||||
|
close_tab,
|
||||||
|
show_searchbar,
|
||||||
|
hide_searchbar,
|
||||||
|
show_finder,
|
||||||
|
finder_next,
|
||||||
|
finder_prev,
|
||||||
|
prettify
|
||||||
|
} func;
|
||||||
|
|
||||||
|
#define SFT 1 << 0
|
||||||
|
#define CTRL 1 << 2
|
||||||
|
#define ALT 1 << 3
|
||||||
|
|
||||||
|
static struct {
|
||||||
|
unsigned mod;
|
||||||
|
unsigned key;
|
||||||
|
func id;
|
||||||
|
} keys[] = {
|
||||||
|
{ CTRL, KEY(h), goback },
|
||||||
|
{ CTRL, KEY(j), goforward },
|
||||||
|
{ CTRL, KEY(r), refresh },
|
||||||
|
{ CTRL | SFT, KEY(R), refresh_force },
|
||||||
|
{ CTRL | SFT, KEY(H), back_to_home },
|
||||||
|
{ CTRL, KEY(equal), zoomin },
|
||||||
|
{ CTRL, KEY(minus), zoomout },
|
||||||
|
{ CTRL, KEY(0), zoom_reset },
|
||||||
|
{ CTRL, KEY(Page_Down), prev_tab },
|
||||||
|
{ CTRL, KEY(Page_Up), next_tab },
|
||||||
|
{ CTRL, KEY(t), next_tab },
|
||||||
|
{ CTRL, KEY(w), close_tab },
|
||||||
|
{ 0x0, KEY(F11), toggle_fullscreen },
|
||||||
|
{ CTRL, KEY(l), show_searchbar },
|
||||||
|
{ CTRL, KEY(k), hide_searchbar },
|
||||||
|
{ CTRL, KEY(f), show_finder },
|
||||||
|
{ CTRL, KEY(n), finder_next },
|
||||||
|
{ CTRL | SFT, KEY(N), finder_prev },
|
||||||
|
{ CTRL, KEY(p), prettify }
|
||||||
|
};
|
||||||
|
/* ^ For controls more akin to normal browsers */
|
||||||
|
/* Reference for the key shorthand:
|
||||||
|
* <https://gitlab.gnome.org/GNOME/gtk/-/blob/main/gdk/gdkkeysyms.h> */
|
||||||
|
|
||||||
|
/* Old controls: {
|
||||||
|
{ CTRL, KEY(h), goback },
|
||||||
|
{ CTRL, KEY(l), goforward },
|
||||||
|
{ CTRL, KEY(r), refresh },
|
||||||
|
{ CTRL | SFT, KEY(R), refresh_force },
|
||||||
|
{ CTRL | SFT, KEY(H), back_to_home },
|
||||||
|
{ CTRL, KEY(equal), zoomin },
|
||||||
|
{ CTRL, KEY(minus), zoomout },
|
||||||
|
{ CTRL, KEY(0), zoom_reset },
|
||||||
|
{ ALT, KEY(h), prev_tab },
|
||||||
|
{ CTRL, KEY(k), hide_searchbar },
|
||||||
|
{ ALT, KEY(l), next_tab },
|
||||||
|
{ CTRL, KEY(w), close_tab },
|
||||||
|
{ 0x0, KEY(F11), toggle_fullscreen },
|
||||||
|
{ CTRL, KEY(e), show_searchbar },
|
||||||
|
{ CTRL, KEY(f), show_finder },
|
||||||
|
{ CTRL, KEY(n), finder_next },
|
||||||
|
{ CTRL | SFT, KEY(N), finder_prev },
|
||||||
|
{ CTRL, KEY(p), prettify }
|
||||||
|
};
|
||||||
|
*/
|
|
@ -1,3 +1,5 @@
|
||||||
|
./plugins/*/*.sh
|
||||||
|
|
||||||
./build.sh && {
|
./build.sh && {
|
||||||
cp -f rose /usr/bin
|
cp -f rose /usr/bin
|
||||||
mkdir -p /usr/share/themes/rose
|
mkdir -p /usr/share/themes/rose
|
||||||
|
|
3
plugins/.old/tranquility/README.md
Normal file
3
plugins/.old/tranquility/README.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
Taken from <https://raw.githubusercontent.com/ushnisha/tranquility-reader-webextensions/master/content_scripts/tranquilize.js>
|
||||||
|
|
||||||
|
The file has 46193 characters. Or 46194 including the line terminator.
|
50
plugins/.old/tranquility/snippet.js
Normal file
50
plugins/.old/tranquility/snippet.js
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
(() => {
|
||||||
|
'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);
|
||||||
|
})();
|
BIN
plugins/.old/tranquility/tranquility
Executable file
BIN
plugins/.old/tranquility/tranquility
Executable file
Binary file not shown.
30
plugins/.old/tranquility/tranquility.c
Normal file
30
plugins/.old/tranquility/tranquility.c
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
#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);
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
8
plugins/.old/tranquility/tranquility.h
Normal file
8
plugins/.old/tranquility/tranquility.h
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#ifndef TRANQUILITY
|
||||||
|
#define TRANQUILITY
|
||||||
|
|
||||||
|
#define TRANQUILITY_N 46288
|
||||||
|
|
||||||
|
void read_tranquility_js(char* string);
|
||||||
|
|
||||||
|
#endif
|
1258
plugins/.old/tranquility/tranquilize.js
Normal file
1258
plugins/.old/tranquility/tranquilize.js
Normal file
File diff suppressed because it is too large
Load Diff
71
plugins/libre_redirect/libre_redirect.c
Normal file
71
plugins/libre_redirect/libre_redirect.c
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
#include "str_replace_start.h"
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#define LIBRE_N 19
|
||||||
|
#define DEBUG false
|
||||||
|
|
||||||
|
/* Inspired by https://libredirect.github.io/, but in C. */
|
||||||
|
|
||||||
|
void str_init(char* str, int n){
|
||||||
|
for(int i=0; i<n; i++){
|
||||||
|
str[i] = ' ';
|
||||||
|
}
|
||||||
|
str[n] = '\0';
|
||||||
|
} // could also use <https://manpages.ubuntu.com/manpages/impish/man3/strinit.3pub.html>
|
||||||
|
|
||||||
|
int libre_redirect(const char* uri, char* output){
|
||||||
|
int l1 = strlen(uri);
|
||||||
|
int l2 = strlen(output);
|
||||||
|
|
||||||
|
if((l2 - l1) < LIBRE_N){
|
||||||
|
if(DEBUG) printf("Not enough memory\n");
|
||||||
|
return 1; // not enough memory.
|
||||||
|
}else{
|
||||||
|
char tmp_uri[l2++];
|
||||||
|
char tmp_output[l2++];
|
||||||
|
strcpy(tmp_uri, uri); // strcpy also copies the terminating '\0'
|
||||||
|
strcpy(tmp_output, output);
|
||||||
|
|
||||||
|
char* annoying_sites[] = {
|
||||||
|
"https://www.youtube.com",
|
||||||
|
"https://www.reddit.com",
|
||||||
|
"https://medium.com",
|
||||||
|
"https://translate.google.com",
|
||||||
|
"https://forum.effectivealtruism.org",
|
||||||
|
"https://www.bloomberg.com",
|
||||||
|
"https://twitter.com",
|
||||||
|
"https://wikipedia.org"
|
||||||
|
};
|
||||||
|
char* alternatives[] = {
|
||||||
|
"https://invidious.flokinet.to", /* "https://yt.artemislena.eu", */
|
||||||
|
"https://teddit.nunosempere.com",
|
||||||
|
"https://scribe.rip",
|
||||||
|
"https://simplytranslate.org/",
|
||||||
|
"https://ea.greaterwrong.com",
|
||||||
|
"https://archive.is/https://www.bloomberg.com",
|
||||||
|
"https://nitter.net",
|
||||||
|
"https://wikiless.org"
|
||||||
|
};
|
||||||
|
int n = sizeof(annoying_sites)/sizeof(annoying_sites[0]);
|
||||||
|
for(int i=0; i<n ; i++){
|
||||||
|
int replace_check = str_replace_start(tmp_uri, annoying_sites[i], alternatives[i], output);
|
||||||
|
if(replace_check == 2){
|
||||||
|
if(DEBUG) printf("tmp_uri: %s\n", tmp_uri);
|
||||||
|
if(DEBUG) printf("output: %s\n", output);
|
||||||
|
// strcpy(output, tmp_uri);
|
||||||
|
// break;
|
||||||
|
return 2;
|
||||||
|
}else if(replace_check == 1){
|
||||||
|
if(DEBUG) printf("replace_check failed\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
strcpy(tmp_uri, output);
|
||||||
|
str_init(output, l2);
|
||||||
|
}
|
||||||
|
strcpy(output, tmp_uri);
|
||||||
|
}
|
||||||
|
if(DEBUG) printf("No match found\n\n");
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
}
|
9
plugins/libre_redirect/libre_redirect.h
Executable file
9
plugins/libre_redirect/libre_redirect.h
Executable file
|
@ -0,0 +1,9 @@
|
||||||
|
#ifndef LIBRE_REDIRECT
|
||||||
|
#define LIBRE_REDIRECT
|
||||||
|
|
||||||
|
#define LIBRE_N 19
|
||||||
|
|
||||||
|
int libre_redirect(const char* uri, char* uri_filtered);
|
||||||
|
void str_init(char* str, int n);
|
||||||
|
|
||||||
|
#endif
|
60
plugins/libre_redirect/str_replace_start.c
Executable file
60
plugins/libre_redirect/str_replace_start.c
Executable file
|
@ -0,0 +1,60 @@
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#define DEBUG false
|
||||||
|
|
||||||
|
/*
|
||||||
|
See also:
|
||||||
|
* <https://web.archive.org/web/20160201212501/coding.debuntu.org/c-implementing-str_replace-replace-all-occurrences-substring>
|
||||||
|
* https://github.com/irl/la-cucina/blob/master/str_replace.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
int str_replace_start(const char* string, const char* target, const char* replacement, char* output){
|
||||||
|
|
||||||
|
int l1 = strlen(string);
|
||||||
|
int l2 = strlen(target);
|
||||||
|
int l3 = strlen(replacement);
|
||||||
|
int l4 = strlen(output);
|
||||||
|
if(DEBUG) printf("%d,%d,%d,%d\n", l1, l2, l3, l4);
|
||||||
|
// if(DEBUG) printf("%s,%s,%s,%s\n", string, target, replacement, output);
|
||||||
|
|
||||||
|
if((l4 < (l1 - l2 + l3)) || l4 < l1 ){
|
||||||
|
// Not enough memory in output string.
|
||||||
|
if(DEBUG) printf("String not long enough.\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
/* else if(l1 < l2){
|
||||||
|
// Not even possible that there is a match.
|
||||||
|
if(DEBUG) printf("Target larger than string.\n");
|
||||||
|
strcpy(output, string);
|
||||||
|
} */
|
||||||
|
else {
|
||||||
|
if(DEBUG) printf("Looking for a match for %s in %s.\n", target, string);
|
||||||
|
int match = true;
|
||||||
|
for(int i=0; i<l2; i++){
|
||||||
|
if(string[i] != target[i]){
|
||||||
|
match = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(match){
|
||||||
|
if(DEBUG) printf("Found match.\n");
|
||||||
|
for(int i=0; i<l3; i++){
|
||||||
|
output[i] = replacement[i];
|
||||||
|
}
|
||||||
|
int counter = l3;
|
||||||
|
for(int i=l2; i<l1; i++){
|
||||||
|
output[counter] = string[i];
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
output[counter] = '\0';
|
||||||
|
return 2; // success
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(DEBUG) printf("Did not find match.\n");
|
||||||
|
strcpy(output, string);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
6
plugins/libre_redirect/str_replace_start.h
Executable file
6
plugins/libre_redirect/str_replace_start.h
Executable file
|
@ -0,0 +1,6 @@
|
||||||
|
#ifndef STR_REPLACE_H_
|
||||||
|
#define STR_REPLACE_H_
|
||||||
|
|
||||||
|
int str_replace_start(const char* string, const char* target, const char* replacement, char* output);
|
||||||
|
|
||||||
|
#endif
|
11
plugins/libre_redirect/str_replace_test/build-example.sh
Normal file
11
plugins/libre_redirect/str_replace_test/build-example.sh
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#!/bin/bash
|
||||||
|
CC=gcc
|
||||||
|
|
||||||
|
FLAGS="-std=c99 -Wall -lm"
|
||||||
|
|
||||||
|
SRC=example.c
|
||||||
|
REQS="../str_replace_start.c ../libre_redirect.c"
|
||||||
|
|
||||||
|
echo -e "\n\n\n"
|
||||||
|
$CC $FLAGS $SRC $REQS -o example
|
||||||
|
|
BIN
plugins/libre_redirect/str_replace_test/example
Executable file
BIN
plugins/libre_redirect/str_replace_test/example
Executable file
Binary file not shown.
20
plugins/libre_redirect/str_replace_test/example.c
Normal file
20
plugins/libre_redirect/str_replace_test/example.c
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
#include "../libre_redirect.h"
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
char uri[] = "https://reddit.com/r/blah";
|
||||||
|
|
||||||
|
int l = LIBRE_N + strlen(uri) + 1;
|
||||||
|
char uri_filtered[l];
|
||||||
|
str_init(uri_filtered, l);
|
||||||
|
|
||||||
|
if(!libre_redirect(uri, uri_filtered)){
|
||||||
|
printf("Filtered uri: %s\n", uri_filtered);
|
||||||
|
}else{
|
||||||
|
printf("Uri: %s\n", uri);
|
||||||
|
// failure; do something with the original uri.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
3
plugins/readability/README.md
Normal file
3
plugins/readability/README.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
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.
|
BIN
plugins/readability/readability
Executable file
BIN
plugins/readability/readability
Executable file
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 84251 + 1
|
||||||
|
|
||||||
|
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 84251 + 1
|
||||||
|
|
||||||
|
void read_readability_js(char* string);
|
||||||
|
|
||||||
|
#endif
|
2340
plugins/readability/readability.js
Normal file
2340
plugins/readability/readability.js
Normal file
File diff suppressed because it is too large
Load Diff
8
plugins/readability/recompute_READABILITY_N.sh
Executable file
8
plugins/readability/recompute_READABILITY_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"
|
||||||
|
|
||||||
|
READABILITY_N=$(wc -c ./plugins/*/readability.js | cut -d " " -f 1)
|
||||||
|
sedr "s/^#define READABILITY_N .*/#define READABILITY_N $READABILITY_N + 1/g"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
|
|
||||||
test "$1" = "--help" || test -z "$1" && {
|
test "$1" = "--help" || test -z "$1" && {
|
||||||
echo -e "usage: rose-mklink <alias> <url>\n"
|
echo -e "usage: rose-mklink <alias> <url>\n"
|
||||||
|
@ -12,6 +12,6 @@ test -z "$2" || {
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
echo -e "#!/bin/sh\n\nrose $2" > /usr/bin/$1
|
echo -e "#!/bin/sh\n\nrose $2 > /dev/null &1>2 &" > /usr/bin/$1
|
||||||
chmod +x /usr/bin/$1
|
chmod +x /usr/bin/$1
|
||||||
}
|
}
|
||||||
|
|
118
rose.c
118
rose.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2022 mini-rose
|
* Copyright (c) 2022 Nuño Sempere.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person
|
* Permission is hereby granted, free of charge, to any person
|
||||||
* obtaining a copy of this software and any associated documentation
|
* obtaining a copy of this software and any associated documentation
|
||||||
|
@ -7,13 +7,16 @@
|
||||||
* sublicense copies of this sotware for their own use.
|
* sublicense copies of this sotware for their own use.
|
||||||
* This code does not come with any warranty.
|
* This code does not come with any warranty.
|
||||||
*
|
*
|
||||||
* Author: fenze <contact@fenze.dev>
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include <string.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include <webkit2/webkit2.h>
|
#include <webkit2/webkit2.h>
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "plugins/libre_redirect/libre_redirect.h"
|
||||||
|
#include "plugins/readability/readability.h"
|
||||||
|
|
||||||
#define CACHE \
|
#define CACHE \
|
||||||
"base-cache-directory", CACHE_DIR, \
|
"base-cache-directory", CACHE_DIR, \
|
||||||
"base-data-directory", CACHE_DIR, \
|
"base-data-directory", CACHE_DIR, \
|
||||||
|
@ -72,21 +75,87 @@ void load_uri(WebKitWebView *view, const char *uri)
|
||||||
g_str_has_prefix(uri, "file://") || g_str_has_prefix(uri, "about:")) {
|
g_str_has_prefix(uri, "file://") || g_str_has_prefix(uri, "about:")) {
|
||||||
webkit_web_view_load_uri(view, uri);
|
webkit_web_view_load_uri(view, uri);
|
||||||
} else {
|
} else {
|
||||||
|
// webkit_web_view_load_uri(view, uri);
|
||||||
char tmp[strlen(uri) + strlen(SEARCH)];
|
char tmp[strlen(uri) + strlen(SEARCH)];
|
||||||
snprintf(tmp, sizeof(tmp), SEARCH, uri);
|
snprintf(tmp, sizeof(tmp), SEARCH, uri);
|
||||||
webkit_web_view_load_uri(view, tmp);
|
webkit_web_view_load_uri(view, tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void redirect_if_annoying(WebKitWebView *view, const char *uri){
|
||||||
|
int l = LIBRE_N + strlen(uri) + 1;
|
||||||
|
char uri_filtered[l];
|
||||||
|
str_init(uri_filtered, l);
|
||||||
|
|
||||||
|
if(DEBUG) printf("libre_redirect uri received : %s\n", uri);
|
||||||
|
int check = libre_redirect(uri, uri_filtered);
|
||||||
|
if(check == 2){
|
||||||
|
webkit_web_view_load_uri(view, uri_filtered);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(DEBUG) printf("libre_redirect uri_filtered: %s\n", uri_filtered);
|
||||||
|
if(DEBUG) printf("libre_redirect check: %d\n", check);
|
||||||
|
}
|
||||||
|
|
||||||
void load_changed(WebKitWebView *self, WebKitLoadEvent load_event, GtkNotebook *notebook)
|
void load_changed(WebKitWebView *self, WebKitLoadEvent load_event, GtkNotebook *notebook)
|
||||||
{
|
{
|
||||||
if (load_event == WEBKIT_LOAD_FINISHED) {
|
switch (load_event) {
|
||||||
gtk_notebook_set_tab_label_text(notebook, GTK_WIDGET(self),
|
/* see <https://webkitgtk.org/reference/webkit2gtk/2.5.1/WebKitWebView.html> */
|
||||||
webkit_web_view_get_title(self));
|
case WEBKIT_LOAD_STARTED:
|
||||||
gtk_widget_hide(GTK_WIDGET(bar));
|
redirect_if_annoying(self, webkit_web_view_get_uri(self));
|
||||||
|
if(DEBUG) printf("Load started with uri: %s\n", webkit_web_view_get_uri (self));
|
||||||
|
break;
|
||||||
|
case WEBKIT_LOAD_REDIRECTED:
|
||||||
|
redirect_if_annoying(self, webkit_web_view_get_uri(self));
|
||||||
|
if(DEBUG) printf("Load redirected to uri: %s\n", webkit_web_view_get_uri (self));
|
||||||
|
break;
|
||||||
|
case WEBKIT_LOAD_COMMITTED:
|
||||||
|
redirect_if_annoying(self, webkit_web_view_get_uri(self));
|
||||||
|
if(DEBUG) printf("Load committed with: %s\n", webkit_web_view_get_uri (self));
|
||||||
|
break;
|
||||||
|
case WEBKIT_LOAD_FINISHED:
|
||||||
|
{
|
||||||
|
const char* webpage_title = webkit_web_view_get_title(self);
|
||||||
|
const int max_length = 25;
|
||||||
|
char tab_title[max_length + 1];
|
||||||
|
if(webpage_title != NULL){
|
||||||
|
for(int i = 0; i<(max_length); i++){
|
||||||
|
tab_title[i] = webpage_title[i];
|
||||||
|
if(webpage_title[i] == '\0'){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tab_title[max_length] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_notebook_set_tab_label_text(notebook, GTK_WIDGET(self),
|
||||||
|
webpage_title == NULL ? "—" : tab_title );
|
||||||
|
// gtk_widget_hide(GTK_WIDGET(bar));
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void notebook_append(GtkNotebook *notebook, const char *uri);
|
||||||
|
/* notebook_append calls handle_create, but handle_create also calls notebook_append.
|
||||||
|
* Therefore we need to declare notebook_append, so that handle_create_new_tab knows its type.
|
||||||
|
*/
|
||||||
|
|
||||||
|
GtkWidget* handle_create_new_tab(WebKitWebView *self, WebKitNavigationAction *navigation_action, GtkNotebook *notebook){
|
||||||
|
WebKitURIRequest *uri_request = webkit_navigation_action_get_request(navigation_action);
|
||||||
|
const char *uri = webkit_uri_request_get_uri (uri_request);
|
||||||
|
printf("Creating new window: %s\n", uri);
|
||||||
|
notebook_append(notebook, uri);
|
||||||
|
gtk_notebook_set_show_tabs(notebook, true);
|
||||||
|
return NULL;
|
||||||
|
/* WebKitGTK documentation recommends returning the new webview.
|
||||||
|
* I imagine that this might allow e.g., to go back in a new tab
|
||||||
|
* or generally to keep track of history.
|
||||||
|
* However, this would require either modifying notebook_append
|
||||||
|
* or duplicating its contents, for unclear gain.
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
void notebook_append(GtkNotebook *notebook, const char *uri)
|
void notebook_append(GtkNotebook *notebook, const char *uri)
|
||||||
{
|
{
|
||||||
GdkScreen *screen = gtk_window_get_screen(GTK_WINDOW(window));
|
GdkScreen *screen = gtk_window_get_screen(GTK_WINDOW(window));
|
||||||
|
@ -99,6 +168,7 @@ void notebook_append(GtkNotebook *notebook, const char *uri)
|
||||||
|
|
||||||
gtk_widget_set_visual(GTK_WIDGET(window), rgba_visual);
|
gtk_widget_set_visual(GTK_WIDGET(window), rgba_visual);
|
||||||
g_signal_connect(view, "load_changed", G_CALLBACK(load_changed), notebook);
|
g_signal_connect(view, "load_changed", G_CALLBACK(load_changed), notebook);
|
||||||
|
g_signal_connect(view, "create", G_CALLBACK(handle_create_new_tab), notebook);
|
||||||
|
|
||||||
int n = gtk_notebook_append_page(notebook, GTK_WIDGET(view), NULL);
|
int n = gtk_notebook_append_page(notebook, GTK_WIDGET(view), NULL);
|
||||||
gtk_notebook_set_tab_reorderable(notebook, GTK_WIDGET(view), true);
|
gtk_notebook_set_tab_reorderable(notebook, GTK_WIDGET(view), true);
|
||||||
|
@ -107,6 +177,7 @@ void notebook_append(GtkNotebook *notebook, const char *uri)
|
||||||
webkit_web_view_set_background_color(view, &rgba);
|
webkit_web_view_set_background_color(view, &rgba);
|
||||||
load_uri(view, (uri) ? uri : HOME);
|
load_uri(view, (uri) ? uri : HOME);
|
||||||
gtk_notebook_set_current_page(notebook, n);
|
gtk_notebook_set_current_page(notebook, n);
|
||||||
|
gtk_notebook_set_tab_label_text(notebook, GTK_WIDGET(view), "-" );
|
||||||
}
|
}
|
||||||
|
|
||||||
WebKitWebView *notebook_get_webview(GtkNotebook *notebook)
|
WebKitWebView *notebook_get_webview(GtkNotebook *notebook)
|
||||||
|
@ -186,9 +257,12 @@ int handle_key(func id, GtkNotebook *notebook)
|
||||||
gtk_notebook_get_n_pages(notebook) - 1) {
|
gtk_notebook_get_n_pages(notebook) - 1) {
|
||||||
notebook_append(notebook, NULL);
|
notebook_append(notebook, NULL);
|
||||||
gtk_notebook_set_show_tabs(notebook, true);
|
gtk_notebook_set_show_tabs(notebook, true);
|
||||||
|
webkit_web_view_set_zoom_level(notebook_get_webview(notebook), zoom);
|
||||||
} else {
|
} else {
|
||||||
gtk_notebook_next_page(notebook);
|
gtk_notebook_next_page(notebook);
|
||||||
}
|
}
|
||||||
|
entry_mode = _SEARCH;
|
||||||
|
show_bar(notebook);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case close_tab:
|
case close_tab:
|
||||||
|
@ -218,6 +292,10 @@ int handle_key(func id, GtkNotebook *notebook)
|
||||||
entry_mode = _SEARCH;
|
entry_mode = _SEARCH;
|
||||||
show_bar(notebook);
|
show_bar(notebook);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case hide_searchbar:
|
||||||
|
gtk_widget_hide(GTK_WIDGET(bar));
|
||||||
|
break;
|
||||||
|
|
||||||
case show_finder:
|
case show_finder:
|
||||||
entry_mode = _FIND;
|
entry_mode = _FIND;
|
||||||
|
@ -233,6 +311,22 @@ int handle_key(func id, GtkNotebook *notebook)
|
||||||
webkit_find_controller_search_previous(
|
webkit_find_controller_search_previous(
|
||||||
webkit_web_view_get_find_controller(notebook_get_webview(notebook)));
|
webkit_web_view_get_find_controller(notebook_get_webview(notebook)));
|
||||||
break;
|
break;
|
||||||
|
case prettify:{
|
||||||
|
if(DEBUG){
|
||||||
|
printf("prettify\n");
|
||||||
|
webkit_web_view_run_javascript(notebook_get_webview(notebook),
|
||||||
|
"alert('Tranquilizing!')",
|
||||||
|
NULL, NULL, NULL);
|
||||||
|
}
|
||||||
|
char* readability_js = malloc(READABILITY_N+1);
|
||||||
|
read_readability_js(readability_js);
|
||||||
|
webkit_web_view_run_javascript(notebook_get_webview(notebook),
|
||||||
|
readability_js,
|
||||||
|
NULL, NULL, NULL);
|
||||||
|
free(readability_js);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -273,7 +367,7 @@ void window_init(GtkNotebook *notebook)
|
||||||
|
|
||||||
gtk_entry_buffer_new("", 0);
|
gtk_entry_buffer_new("", 0);
|
||||||
gtk_entry_set_alignment(search, 0.48);
|
gtk_entry_set_alignment(search, 0.48);
|
||||||
gtk_widget_set_size_request(GTK_WIDGET(search), 300, -1);
|
gtk_widget_set_size_request(GTK_WIDGET(search), 1200, -1);
|
||||||
gtk_header_bar_set_custom_title(bar, GTK_WIDGET(search));
|
gtk_header_bar_set_custom_title(bar, GTK_WIDGET(search));
|
||||||
gtk_window_set_titlebar(window, GTK_WIDGET(bar));
|
gtk_window_set_titlebar(window, GTK_WIDGET(bar));
|
||||||
|
|
||||||
|
@ -297,14 +391,18 @@ void setup(GtkNotebook *notebook, const char *uri)
|
||||||
search_buf = GTK_ENTRY_BUFFER(gtk_entry_buffer_new("", 0));
|
search_buf = GTK_ENTRY_BUFFER(gtk_entry_buffer_new("", 0));
|
||||||
search = GTK_ENTRY(gtk_entry_new_with_buffer(search_buf));
|
search = GTK_ENTRY(gtk_entry_new_with_buffer(search_buf));
|
||||||
|
|
||||||
|
// gtk_window_fullscreen(window);
|
||||||
|
gtk_window_set_default_size(window, WIDTH, HEIGHT);
|
||||||
|
// gtk_window_set_resizable (window, FALSE);
|
||||||
|
|
||||||
window_init(notebook);
|
window_init(notebook);
|
||||||
notebook_init(notebook, uri);
|
notebook_init(notebook, uri);
|
||||||
|
|
||||||
g_object_set(gtk_settings_get_default(), GTK, NULL);
|
g_object_set(gtk_settings_get_default(), GTK, NULL);
|
||||||
|
|
||||||
gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(notebook));
|
gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(notebook));
|
||||||
gtk_widget_show_all(GTK_WIDGET(window));
|
gtk_widget_show_all(GTK_WIDGET(window));
|
||||||
gtk_widget_hide(GTK_WIDGET(bar));
|
gtk_widget_hide(GTK_WIDGET(bar));
|
||||||
|
webkit_web_view_set_zoom_level(notebook_get_webview(notebook), ZOOM);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
|
|
19
style.css
19
style.css
|
@ -10,7 +10,10 @@
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
outline-color: @Lavender;
|
outline-color: @Lavender;
|
||||||
color: @Text;
|
color: @Text;
|
||||||
border-bottom-color: @Base;
|
border-color: white;
|
||||||
|
font-size: 16px;
|
||||||
|
/*@Base; */
|
||||||
|
/* border-bottom-color: @Base; */
|
||||||
}
|
}
|
||||||
|
|
||||||
window, notebook, headerbar {
|
window, notebook, headerbar {
|
||||||
|
@ -20,11 +23,21 @@ window, notebook, headerbar {
|
||||||
tabs {
|
tabs {
|
||||||
background-color: @Base;
|
background-color: @Base;
|
||||||
padding: 3px;
|
padding: 3px;
|
||||||
|
outline-color: white;
|
||||||
|
border-color: @Base;
|
||||||
}
|
}
|
||||||
|
|
||||||
tab {
|
tab {
|
||||||
background-color: @Base;
|
background-color: @Base;
|
||||||
|
margin: 2px 5px 2px 0px;
|
||||||
|
padding: 5px;
|
||||||
|
border-style: solid;
|
||||||
|
/*border-color: white;
|
||||||
|
border-bottom-color: white;
|
||||||
|
outline-color: white;
|
||||||
margin: 5px;
|
margin: 5px;
|
||||||
|
padding-left: 10px;
|
||||||
|
padding-right: 10px; */
|
||||||
}
|
}
|
||||||
|
|
||||||
entry {
|
entry {
|
||||||
|
@ -33,5 +46,7 @@ entry {
|
||||||
}
|
}
|
||||||
|
|
||||||
entry:focus {
|
entry:focus {
|
||||||
box-shadow: none;
|
background-color: @Surface0;
|
||||||
|
padding-left: 10px;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
23
user-scripts/ubuntu-20.04/install-with-dependencies.sh
Normal file
23
user-scripts/ubuntu-20.04/install-with-dependencies.sh
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
# Dependencies
|
||||||
|
sudo apt install libwebkit2gtk-4.0-dev
|
||||||
|
sudo apt install clang
|
||||||
|
# sudo apt instal sudo apt install gstreamer1.0-plugins-good gstreamer1.0-libav
|
||||||
|
|
||||||
|
# Adblock
|
||||||
|
git clone https://github.com/jun7/wyebadblock
|
||||||
|
cd wyebadblock
|
||||||
|
make
|
||||||
|
sudo make install
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
# Rose config
|
||||||
|
user=$(whoami)
|
||||||
|
mkdir -p /home/$user/.cache/rose
|
||||||
|
cp ../../config.def.h ../../config.h # you should also probably customize this yourself.
|
||||||
|
sed "s/fenze/$user/g" ../../config.h
|
||||||
|
|
||||||
|
sudo bash ../../install.sh
|
||||||
|
|
||||||
|
# Ubuntu desktop icon
|
||||||
|
chmod +x rose.desktop
|
||||||
|
sudo cp rose.desktop /usr/share/applications
|
13
user-scripts/ubuntu-20.04/notes-desktop.md
Normal file
13
user-scripts/ubuntu-20.04/notes-desktop.md
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
For some reason, the Ubuntu environment assigns a program to the rose desktop tab if it is called from within /usr/bin/rose, even if from the Whatsapp desktop file.
|
||||||
|
|
||||||
|
The solution is to make a syslink from rose to whatsapp:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ ln -s /usr/bin/rose /usr/bin/whatsapp
|
||||||
|
```
|
||||||
|
|
||||||
|
and then call whatsapp from:
|
||||||
|
|
||||||
|
```
|
||||||
|
/usr/bin/whatsapp https://web.whatsapp.com/
|
||||||
|
```
|
BIN
user-scripts/ubuntu-20.04/rose-images/rose-1.png
Normal file
BIN
user-scripts/ubuntu-20.04/rose-images/rose-1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 625 KiB |
BIN
user-scripts/ubuntu-20.04/rose-images/rose-2.png
Normal file
BIN
user-scripts/ubuntu-20.04/rose-images/rose-2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 474 KiB |
BIN
user-scripts/ubuntu-20.04/rose-images/rose-desktop-icon.png
Normal file
BIN
user-scripts/ubuntu-20.04/rose-images/rose-desktop-icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 739 KiB |
BIN
user-scripts/ubuntu-20.04/rose-images/rose-homepage.png
Normal file
BIN
user-scripts/ubuntu-20.04/rose-images/rose-homepage.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 474 KiB |
1
user-scripts/ubuntu-20.04/rose-images/rose-src.txt
Normal file
1
user-scripts/ubuntu-20.04/rose-images/rose-src.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<https://www.onlygfx.com/red-rose-png-image-transparent/>
|
9
user-scripts/ubuntu-20.04/rose.desktop
Executable file
9
user-scripts/ubuntu-20.04/rose.desktop
Executable file
|
@ -0,0 +1,9 @@
|
||||||
|
#!/usr/bin/env xdg-open
|
||||||
|
[Desktop Entry]
|
||||||
|
Version=1.0
|
||||||
|
Type=Application
|
||||||
|
Terminal=false
|
||||||
|
Exec= /usr/bin/rose %u
|
||||||
|
Name=Rose
|
||||||
|
Comment=Minimalistic browser
|
||||||
|
Icon=/home/loki/Documents/core/software/fresh/C/rose-browser/rose-bud-personal/user-scripts/ubuntu-20.04/rose-images/rose-desktop-icon.png
|
8
user-scripts/ubuntu-20.04/set-default-mime.sh
Normal file
8
user-scripts/ubuntu-20.04/set-default-mime.sh
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
# Requires:
|
||||||
|
# sudo cp rose.desktop /usr/share/applications
|
||||||
|
|
||||||
|
xdg-mime default rose.desktop x-scheme-handler/https
|
||||||
|
xdg-mime default rose.desktop x-scheme-handler/http
|
||||||
|
|
||||||
|
# This is useful e.g., for setting how to open
|
||||||
|
# links in vim when pressing gx.
|
10
user-scripts/ubuntu-20.04/whatsapp.desktop
Executable file
10
user-scripts/ubuntu-20.04/whatsapp.desktop
Executable file
|
@ -0,0 +1,10 @@
|
||||||
|
#!/usr/bin/env xdg-open
|
||||||
|
[Desktop Entry]
|
||||||
|
Version=1.0
|
||||||
|
Type=Application
|
||||||
|
Terminal=false
|
||||||
|
Exec= /usr/bin/whatsapp https://web.whatsapp.com
|
||||||
|
Name=Whatsapp
|
||||||
|
Comment=Whatsapp messaging service.
|
||||||
|
Icon=/home/loki/Pictures/fresh/misc/whatsapp_icon.svg
|
||||||
|
|
9
user-scripts/valgrind-notes.md
Normal file
9
user-scripts/valgrind-notes.md
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
In case you arrive at a segmentation fault when working on rose, you can use valgrind.
|
||||||
|
|
||||||
|
To do this, you can compile rose with the `DEBUG` value in `build.sh` set to `-g`
|
||||||
|
|
||||||
|
and then:
|
||||||
|
|
||||||
|
```
|
||||||
|
valgrind --track-origins=yes ./rose
|
||||||
|
```
|
Loading…
Reference in New Issue
Block a user