Compare commits
66 Commits
2f447f0b7b
...
ce069bdd73
Author | SHA1 | Date | |
---|---|---|---|
ce069bdd73 | |||
0b9386f5fe | |||
20d0becba9 | |||
37e3e7bcae | |||
bbcf1dabd2 | |||
ca59138a2a | |||
cc959fda4f | |||
18f4e3e3cb | |||
1fca042b0b | |||
3483af0f0f | |||
ec97a8f3f3 | |||
527d88efa6 | |||
aeb196837e | |||
bb4ba366ee | |||
06a0d6d808 | |||
1eb9f98dc8 | |||
42c7565b7f | |||
7cecf5ae3a | |||
49df138b36 | |||
ff033646cc | |||
0f4866f520 | |||
53cc700748 | |||
bcaad22c17 | |||
25dedb09e1 | |||
a27b4357af | |||
6a330e9b09 | |||
86fef30c22 | |||
95829b06a2 | |||
4f43648a84 | |||
c10b7632eb | |||
2db650d7cc | |||
33e4d0cdd1 | |||
d1439d16f5 | |||
b50d30851b | |||
|
35f968f29b | ||
|
1ba5fd7ecd | ||
|
122437115d | ||
08c19abc1d | |||
|
4e0b961fcb | ||
|
5b958d5faf | ||
|
327344ee40 | ||
b48c504871 | |||
cbaa97a766 | |||
353d0ffad7 | |||
be043958f0 | |||
9a533b7e26 | |||
6b3c830c3b | |||
4fd1c83660 | |||
e928ee1c89 | |||
|
584a5d68a8 | ||
|
d97045bf47 | ||
|
3325e17195 | ||
|
b16665809c | ||
f5d1c0f93d | |||
98abdb39c4 | |||
6ff86dcc44 | |||
7ad3e023f8 | |||
|
62b1bd6785 | ||
|
055e50c9ef | ||
981c15bf93 | |||
5ab887db47 | |||
f6119ff7db | |||
5e403cad14 | |||
1bed196381 | |||
a69d72f42b | |||
374128fccc |
|
@ -1,37 +0,0 @@
|
||||||
# vim:ft=yaml
|
|
||||||
|
|
||||||
IndentWidth: 8
|
|
||||||
BreakBeforeBraces: Linux
|
|
||||||
UseTab: Always
|
|
||||||
AlignArrayOfStructures: Left
|
|
||||||
AllowShortFunctionsOnASingleLine: Empty
|
|
||||||
AllowShortIfStatementsOnASingleLine: WithoutElse
|
|
||||||
AllowShortLoopsOnASingleLine: True
|
|
||||||
AlwaysBreakBeforeMultilineStrings: True
|
|
||||||
BreakBeforeTernaryOperators: True
|
|
||||||
BreakStringLiterals: True
|
|
||||||
ColumnLimit: 100
|
|
||||||
IncludeBlocks: Regroup
|
|
||||||
KeepEmptyLinesAtTheStartOfBlocks: True
|
|
||||||
RemoveBracesLLVM: True
|
|
||||||
SortIncludes: CaseInsensitive
|
|
||||||
SortUsingDeclarations: True
|
|
||||||
SpaceAfterLogicalNot: True
|
|
||||||
SpaceAfterCStyleCast: True
|
|
||||||
SpaceAfterTemplateKeyword: False
|
|
||||||
PointerAlignment: Right
|
|
||||||
SpaceBeforeAssignmentOperators: True
|
|
||||||
SpaceBeforeCaseColon: False
|
|
||||||
SpaceBeforeCpp11BracedList: True
|
|
||||||
SpaceBeforeCtorInitializerColon: False
|
|
||||||
SpaceBeforeInheritanceColon: False
|
|
||||||
SpaceBeforeParens: Custom
|
|
||||||
SpaceBeforeParensOptions:
|
|
||||||
AfterControlStatements: True
|
|
||||||
AfterForeachMacros: True
|
|
||||||
AfterFunctionDeclarationName: False
|
|
||||||
AfterFunctionDefinitionName: False
|
|
||||||
AfterIfMacros: True
|
|
||||||
AfterOverloadedOperator: False
|
|
||||||
BeforeNonEmptyParentheses: False
|
|
||||||
SpaceBeforeRangeBasedForLoopColon: True
|
|
2
.gitignore
vendored
|
@ -1,3 +1 @@
|
||||||
rose
|
rose
|
||||||
config.h
|
|
||||||
.clang-format
|
|
||||||
|
|
78
README.md
|
@ -1,21 +1,73 @@
|
||||||
<h3 align=center> Rose Browser</h1>
|
## Rosenrot
|
||||||
<h4 align=center>Minimal browser based on webkit2gtk</h4>
|
|
||||||
|
A small browser forked from [rose](https://github.com/mini-rose/rose).
|
||||||
|
|
||||||
|
- Rose is a minimal browser based on webkit2gtk which aims to be a "basement for creating your own browser using [the] gtk and webkit libraries".
|
||||||
|
- Rosenrot is my fork from rose. It has accumulated cruft that I like, like a "readability" plugin that simplifies annoying websites like [Matt Levine's Money Stuff newsletter](https://www.bloomberg.com/opinion/articles/2022-10-18/matt-levine-s-money-stuff-credit-suisse-was-a-reverse-meme-stock).
|
||||||
|
- Rosenrot is also a song by the German hardcore rock band [Rammstein](https://www.youtube.com/watch?v=af59U2BRRAU).
|
||||||
|
|
||||||
|
You can see some screenshots in the [screenshots](./screenshots) folder.
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
#### Features
|
|
||||||
- tabs, cookies, caching
|
- tabs, cookies, caching
|
||||||
- minimal ui, autohiding elements
|
- minimal ui, autohiding elements
|
||||||
- ~400L code base
|
- ~467L core code (the rose.c file)
|
||||||
- custom gtk and websites css
|
- custom gtk and websites css
|
||||||
- hackable without any knowledge
|
|
||||||
- builtin rose-mklink script for in-shell static links
|
- builtin rose-mklink script for in-shell static links
|
||||||
|
- A few quality of life improvements.
|
||||||
|
- Optional adblocking through [wyebadblock](https://github.com/jun7/wyebadblock)
|
||||||
|
- Plugin system:
|
||||||
|
- Libre redirect: Redirect annoying websites to open source frontends
|
||||||
|
- Readability: Strip webpages of unnecessary elements for ease of reading with a custom shortcut
|
||||||
|
- Custom style: Override the css of predetermined websites
|
||||||
|
- Stand in plugin: Mimick function definitions which do nothing for the above plugins so that they can be quickly removed
|
||||||
|
|
||||||
|
### Installation
|
||||||
|
|
||||||
|
Install dependencies, then:
|
||||||
|
|
||||||
|
```
|
||||||
|
make build
|
||||||
|
make install # or sudo make install
|
||||||
|
```
|
||||||
|
|
||||||
|
You can also see more detailed instructions [here](./user-scripts/ubuntu-20.04/install-with-dependencies.sh), for Ubuntu 20.04 in particular—though they should generalize trivially.
|
||||||
|
|
||||||
#
|
|
||||||
### 👐 Contribute
|
### 👐 Contribute
|
||||||
See [contributing.md](https://github.com/mini-rose/rose/.github/contributing.md).
|
|
||||||
|
|
||||||
### 📜 License
|
- Contribute upstream to [github.com/mini-rose/rose](https://github.com/mini-rose/) for core functionality changes.
|
||||||
Rose is released under own license, which grants the following permissions:
|
- Contribute here by sending a pull request on Github.
|
||||||
- Commercial use
|
|
||||||
- Distribution
|
### To do
|
||||||
- Modification
|
|
||||||
- Private use
|
- [ ] Look at using relative rather than absolute paths
|
||||||
|
- [ ] Figure out if downloading files is doable.
|
||||||
|
- [ ] Figure out better way to have plugins
|
||||||
|
- [ ] Double check newtab/next-tab behavior
|
||||||
|
- [ ] Document stand_in.c better
|
||||||
|
- [ ] Find out what each of the css elements refers to.
|
||||||
|
- [ ] Use something other than Whatsapp as an example syslink.
|
||||||
|
- [ ] Set `webkit_web_context_set_sandbox_enabled` (<https://webkitgtk.org/reference/webkit2gtk/2.36.8/WebKitWebContext.html#webkit-web-context-set-sandbox-enabled>), as recommended here: <https://blogs.gnome.org/mcatanzaro/2022/11/04/stop-using-qtwebkit/>.
|
||||||
|
- [ ] Fix bug about distorted audio. Maybe related to <https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/1547>
|
||||||
|
|
||||||
|
Done:
|
||||||
|
|
||||||
|
- [x] Mask user agent
|
||||||
|
- [x] Use a makefile.
|
||||||
|
- [x] Launch with more than one tab from command line
|
||||||
|
- [x] Figure out merge with upstream
|
||||||
|
- [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 new_tab 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.
|
||||||
|
|
11
build.sh
|
@ -1,11 +0,0 @@
|
||||||
CC=clang
|
|
||||||
SRC=rose.c
|
|
||||||
DEPS=('webkit2gtk-4.0')
|
|
||||||
|
|
||||||
INCS=`pkg-config --cflags ${DEPS[@]}`
|
|
||||||
LIBS=`pkg-config --libs ${DEPS[@]}`
|
|
||||||
|
|
||||||
# Optional adblocking depends on https://github.com/jun7/wyebadblock
|
|
||||||
WYEBAB='-L/usr/lib/wyebrowser/adblock.so'
|
|
||||||
|
|
||||||
$CC $INCS $LIBS $SRC $WYEBAB -o rose
|
|
76
config.def.h
|
@ -1,76 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2022 mini-rose
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* Author: fenze <contact@fenze.dev>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <gdk/gdkkeysyms.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", true, "gtk-enable-animations", false
|
|
||||||
|
|
||||||
#define HOME "https://duckduckgo.com"
|
|
||||||
#define SEARCH "https://duckduckgo.com/?q=%s"
|
|
||||||
#define CACHE_DIR "/home/fenze/.cache/rose"
|
|
||||||
|
|
||||||
#define KEY(x) GDK_KEY_##x
|
|
||||||
#define ZOOM 1 /* Starting zoom level */
|
|
||||||
#define ZOOM_VAL .1 /* Zooming value in zoomin/zoomout functions */
|
|
||||||
#define BG_COLOR "#1E1E2E"
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
goback,
|
|
||||||
goforward,
|
|
||||||
refresh,
|
|
||||||
refresh_force,
|
|
||||||
back_to_home,
|
|
||||||
toggle_fullscreen,
|
|
||||||
zoomin,
|
|
||||||
zoomout,
|
|
||||||
zoom_reset,
|
|
||||||
next_tab,
|
|
||||||
prev_tab,
|
|
||||||
close_tab,
|
|
||||||
show_searchbar,
|
|
||||||
show_finder,
|
|
||||||
finder_next,
|
|
||||||
finder_prev
|
|
||||||
} 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(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 },
|
|
||||||
{ 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 }
|
|
||||||
};
|
|
99
config.h
Normal file
|
@ -0,0 +1,99 @@
|
||||||
|
#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/rosenrot/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,
|
||||||
|
show_finder,
|
||||||
|
finder_next,
|
||||||
|
finder_prev,
|
||||||
|
new_tab,
|
||||||
|
prettify,
|
||||||
|
hide_bar
|
||||||
|
} 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_Up), prev_tab },
|
||||||
|
{ CTRL, KEY(Page_Down), 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_bar },
|
||||||
|
{ 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,6 +0,0 @@
|
||||||
./build.sh && {
|
|
||||||
cp -f rose /usr/bin
|
|
||||||
mkdir -p /usr/share/themes/rose
|
|
||||||
cp style.css /usr/share/themes/rose/
|
|
||||||
cp rose-mklink /usr/bin
|
|
||||||
}
|
|
21
license
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2022-2023 Nuño Sempere
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
66
makefile
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
# make
|
||||||
|
# make build
|
||||||
|
# (sudo) make install
|
||||||
|
# make format
|
||||||
|
# make clean
|
||||||
|
# make uninstall
|
||||||
|
|
||||||
|
## C compiler
|
||||||
|
CC=clang
|
||||||
|
|
||||||
|
## Main file
|
||||||
|
SRC=rose.c
|
||||||
|
|
||||||
|
## Dependencies
|
||||||
|
DEPS='webkit2gtk-4.0'
|
||||||
|
DEBUG= #'-g'
|
||||||
|
|
||||||
|
INCS=`pkg-config --cflags ${DEPS}`
|
||||||
|
LIBS=`pkg-config --libs ${DEPS}`
|
||||||
|
|
||||||
|
## Optional adblocking
|
||||||
|
## depends on https://github.com/jun7/wyebadblock
|
||||||
|
ADBLOCK='-L/usr/lib/wyebrowser/adblock.so'
|
||||||
|
|
||||||
|
## Plugins
|
||||||
|
LIBRE_REDIRECT=./plugins/libre_redirect/libre_redirect.c ./plugins/libre_redirect/str_replace_start.c
|
||||||
|
READABILITY=./plugins/readability/readability.c
|
||||||
|
CUSTOM_STYLES=./plugins/style/style.c
|
||||||
|
|
||||||
|
STAND_IN=./plugins/stand_in/stand_in.c # gives function definitions for the above, which do nothing
|
||||||
|
|
||||||
|
PLUGS=$(LIBRE_REDIRECT) $(READABILITY) $(CUSTOM_STYLES)
|
||||||
|
# PLUGS=$(STAND_IN)
|
||||||
|
# Note that if you want some plugins but not others,
|
||||||
|
# You should edit the stand_in.c file
|
||||||
|
|
||||||
|
# CONFIG
|
||||||
|
CONFIG=config.h
|
||||||
|
# cp -f config.def.h config.h
|
||||||
|
|
||||||
|
## Formatter
|
||||||
|
STYLE_BLUEPRINT=webkit
|
||||||
|
FORMATTER=clang-format -i -style=$(STYLE_BLUEPRINT)
|
||||||
|
## Commands
|
||||||
|
|
||||||
|
build: $(SRC) $(PLUGS) $(CONFIG)
|
||||||
|
$(CC) $(DEBUG) $(INCS) $(PLUGS) $(SRC) -o rose $(LIBS) $(ADBLOCK)
|
||||||
|
|
||||||
|
install: rose
|
||||||
|
cp -f rose /usr/bin
|
||||||
|
mkdir -p /usr/share/themes/rose
|
||||||
|
cp style.css /usr/share/themes/rose/
|
||||||
|
cp rose-mklink /usr/bin
|
||||||
|
|
||||||
|
uninstall:
|
||||||
|
rm -r /usr/share/themes/rose
|
||||||
|
rm /usr/bin/rose
|
||||||
|
rm /usr/bin/rose-mklink
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm rose
|
||||||
|
|
||||||
|
format: $(SRC) $(PLUGS)
|
||||||
|
$(FORMATTER) $(SRC) $(PLUGS)
|
||||||
|
|
||||||
|
|
3
plugins/libre_redirect/README.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
## About
|
||||||
|
|
||||||
|
This code automatically redirects webpage to their open-source frontends. It is based on <https://libredirect.codeberg.page/>
|
84
plugins/libre_redirect/libre_redirect.c
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "str_replace_start.h"
|
||||||
|
|
||||||
|
#define LIBRE_N 19
|
||||||
|
|
||||||
|
/* Uncomment for debug */
|
||||||
|
/* #define DEBUG */
|
||||||
|
|
||||||
|
/* 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);
|
||||||
|
int len;
|
||||||
|
char tmp_uri[l2++];
|
||||||
|
char tmp_output[l2++];
|
||||||
|
|
||||||
|
if ((l2 - l1) < LIBRE_N) {
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("Not enough memory\n");
|
||||||
|
#endif
|
||||||
|
return 1; // not enough memory.
|
||||||
|
} else {
|
||||||
|
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"
|
||||||
|
};
|
||||||
|
|
||||||
|
char* alternatives[] = {
|
||||||
|
"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"
|
||||||
|
};
|
||||||
|
|
||||||
|
len = sizeof(annoying_sites) / sizeof(annoying_sites[0]);
|
||||||
|
|
||||||
|
for (int i = 0; i < len; i++) {
|
||||||
|
int replace_check = str_replace_start(tmp_uri, annoying_sites[i],
|
||||||
|
alternatives[i], output);
|
||||||
|
if (replace_check == 2) {
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("tmp_uri: %s\n", tmp_uri);
|
||||||
|
printf("output: %s\n", output);
|
||||||
|
#endif
|
||||||
|
return 2;
|
||||||
|
} else if (replace_check == 1) {
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("replace_check failed\n");
|
||||||
|
#endif
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
strcpy(tmp_uri, output);
|
||||||
|
str_init(output, l2);
|
||||||
|
}
|
||||||
|
strcpy(output, tmp_uri);
|
||||||
|
}
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("No match found\n\n");
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
6
plugins/libre_redirect/libre_redirect.h
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define LIBRE_N 19
|
||||||
|
|
||||||
|
int libre_redirect(const char* uri, char* uri_filtered);
|
||||||
|
void str_init(char* str, int n);
|
65
plugins/libre_redirect/str_replace_start.c
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.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;
|
||||||
|
}
|
4
plugins/libre_redirect/str_replace_start.h
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
int str_replace_start(const char* string, const char* target,
|
||||||
|
const char* replacement, char* output);
|
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
|
||||||
|
|
19
plugins/libre_redirect/str_replace_test/example.c
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
#include "../libre_redirect.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.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.
|
||||||
|
}
|
||||||
|
}
|
2
plugins/readability/README.md
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
This code reimplements firefox readability mode. Code taken from <https://raw.githubusercontent.com/ushnisha/readability-reader-webextensions/master/content_scripts/tranquilize.js>
|
||||||
|
|
BIN
plugins/readability/readability
Executable file
30
plugins/readability/readability.c
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#define READABILITY_N 85133 + 1000
|
||||||
|
|
||||||
|
void read_readability_js(char* string)
|
||||||
|
{
|
||||||
|
FILE* fp = fopen("/home/loki/Documents/core/software/fresh/C/rose-browser/rosenrot/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
|
@ -0,0 +1,8 @@
|
||||||
|
#ifndef READABILITY
|
||||||
|
#define READABILITY
|
||||||
|
|
||||||
|
#define READABILITY_N 85133 + 1000
|
||||||
|
|
||||||
|
void read_readability_js(char* string);
|
||||||
|
|
||||||
|
#endif
|
2401
plugins/readability/readability.js
Normal 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 readability.js | cut -d " " -f 1)
|
||||||
|
sedr "s/^#define READABILITY_N .*/#define READABILITY_N $READABILITY_N + 1000/g"
|
||||||
|
|
27
plugins/stand_in/stand_in.c
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
/* Why this file is needed:
|
||||||
|
* If the plugins are disabled,
|
||||||
|
* their conditionals will never resolve
|
||||||
|
* and their functionality never comes into play
|
||||||
|
* but the compiler still wants to know their type
|
||||||
|
*/
|
||||||
|
|
||||||
|
int libre_redirect(const char* uri, char* uri_filtered){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
void str_init(char* str, int n){
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
int str_replace_start(const char* string, const char* target,
|
||||||
|
const char* replacement, char* output){
|
||||||
|
return 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
void read_readability_js(char* string){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void read_style_js(char* string){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
23
plugins/stand_in/stand_in.h
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
/* Why this file is needed:
|
||||||
|
* If the plugins are disabled,
|
||||||
|
* their conditionals will never resolve
|
||||||
|
* and their functionality never comes into play
|
||||||
|
* but the compiler still wants to know their type
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define LIBRE_N 0
|
||||||
|
#define STYLE_N 0
|
||||||
|
#define READABILITY_N 84638 + 1
|
||||||
|
|
||||||
|
int libre_redirect(const char* uri, char* uri_filtered);
|
||||||
|
void str_init(char* str, int n);
|
||||||
|
|
||||||
|
int str_replace_start(const char* string, const char* target,
|
||||||
|
const char* replacement, char* output);
|
||||||
|
|
||||||
|
void read_readability_js(char* string);
|
||||||
|
|
||||||
|
void read_style_js(char* string);
|
||||||
|
|
5
plugins/style/README.md
Normal file
|
@ -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.
|
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"
|
||||||
|
|
30
plugins/style/style.c
Normal file
|
@ -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);
|
||||||
|
}
|
||||||
|
*/
|
8
plugins/style/style.h
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#ifndef STYLE
|
||||||
|
#define STYLE
|
||||||
|
|
||||||
|
#define STYLE_N 1393 + 1
|
||||||
|
|
||||||
|
void read_style_js(char* string);
|
||||||
|
|
||||||
|
#endif
|
49
plugins/style/style.js
Normal file
|
@ -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"
|
|
@ -1,17 +1,17 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
test "$1" = "--help" || test -z "$1" && {
|
test "$1" = "--help" || test -z "$1" && {
|
||||||
echo -e "usage: rose-mklink <alias> <url>\n"
|
printf "%s\n" "usage: rose-mklink <alias> <url>" \
|
||||||
echo "Create a /usr/bin link to a website."
|
"Create a /usr/bin link to a website."
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
test -z "$2" || {
|
test -z "$2" || {
|
||||||
[ -f "/usr/bin/$1" ] && {
|
test -f "/usr/bin/$1" && {
|
||||||
echo "/usr/bin/$1 already exists, remove it first"
|
echo "/usr/bin/$1 already exists, remove it first"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
echo -e "#!/bin/sh\n\nrose $2" > /usr/bin/$1
|
printf "#!/bin/sh\n\nrose %s" "$2" > /usr/bin/$1
|
||||||
chmod +x /usr/bin/$1
|
chmod +x /usr/bin/$1
|
||||||
}
|
}
|
||||||
|
|
267
rose.c
|
@ -1,32 +1,42 @@
|
||||||
/*
|
#include <stdbool.h>
|
||||||
* Copyright (c) 2022 mini-rose
|
#include <stdlib.h> // necessary for free, malloc.
|
||||||
*
|
#include <string.h>
|
||||||
* Permission is hereby granted, free of charge, to any person
|
#include <webkit2/webkit2.h>
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* Author: fenze <contact@fenze.dev>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <webkit2/webkit2.h>
|
#include "plugins/libre_redirect/libre_redirect.h"
|
||||||
|
#include "plugins/readability/readability.h"
|
||||||
|
#include "plugins/style/style.h"
|
||||||
|
|
||||||
|
// #include "plugins/stand_in/stand_in.h"
|
||||||
|
|
||||||
|
int LIBRE_REDIRECT_ENABLED = true;
|
||||||
|
int READABILITY_ENABLED = true;
|
||||||
|
int CUSTOM_STYLE_ENABLED = true;
|
||||||
|
int CUSTOM_USER_AGENT = true;
|
||||||
|
|
||||||
|
// to enable plugins,
|
||||||
|
// 1. Enable them:
|
||||||
|
// - uncomment their #include statement
|
||||||
|
// - set their variable to true
|
||||||
|
// - in build.sh, uncomment: REQS= #./plugins/*/*.c
|
||||||
|
// 2. Remove stand_in code;
|
||||||
|
// - Comment out #include "plugins/stand_in/stand_in.h" line, or edit it
|
||||||
|
// together with stand_in.c so as to not include the plugin functions.
|
||||||
|
// - In build.sh, comment out REQS=./plugins/stand_in/stand_in.c
|
||||||
|
|
||||||
#define CACHE \
|
#define CACHE \
|
||||||
"base-cache-directory", CACHE_DIR, \
|
"base-cache-directory", CACHE_DIR, "base-data-directory", CACHE_DIR, \
|
||||||
"base-data-directory", CACHE_DIR, \
|
"disk-cache-directory", CACHE_DIR, "dom-cache-directory", CACHE_DIR, \
|
||||||
"disk-cache-directory", CACHE_DIR, \
|
"hsts-cache-directory", CACHE_DIR, "indexeddb-directory", CACHE_DIR, \
|
||||||
"dom-cache-directory", CACHE_DIR, \
|
"itp-directory", CACHE_DIR, "local-storage-directory", CACHE_DIR, \
|
||||||
"hsts-cache-directory", CACHE_DIR, \
|
|
||||||
"indexeddb-directory", CACHE_DIR, \
|
|
||||||
"itp-directory", CACHE_DIR, \
|
|
||||||
"local-storage-directory", CACHE_DIR, \
|
|
||||||
"offline-application-cache-directory", CACHE_DIR, \
|
"offline-application-cache-directory", CACHE_DIR, \
|
||||||
"service-worker-registrations-directory", CACHE_DIR
|
"service-worker-registrations-directory", CACHE_DIR
|
||||||
|
|
||||||
enum { _SEARCH, _FIND };
|
enum { _SEARCH,
|
||||||
|
_FIND,
|
||||||
|
_HIDDEN };
|
||||||
|
|
||||||
static int entry_mode;
|
static int entry_mode;
|
||||||
static GtkWindow* window;
|
static GtkWindow* window;
|
||||||
|
@ -43,50 +53,149 @@ WebKitWebView *webview_new()
|
||||||
WebKitUserContentManager* contentmanager;
|
WebKitUserContentManager* contentmanager;
|
||||||
|
|
||||||
settings = webkit_settings_new_with_settings(WEBKIT, NULL);
|
settings = webkit_settings_new_with_settings(WEBKIT, NULL);
|
||||||
|
if (CUSTOM_USER_AGENT) {
|
||||||
|
webkit_settings_set_user_agent(
|
||||||
|
settings,
|
||||||
|
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, "
|
||||||
|
"like Gecko) Chrome/110.0.0.0 Safari/537.36");
|
||||||
|
// See: <https://www.useragents.me/> for some common user agents
|
||||||
|
}
|
||||||
web_context = webkit_web_context_new_with_website_data_manager(
|
web_context = webkit_web_context_new_with_website_data_manager(
|
||||||
webkit_website_data_manager_new(CACHE, NULL));
|
webkit_website_data_manager_new(CACHE, NULL));
|
||||||
contentmanager = webkit_user_content_manager_new();
|
contentmanager = webkit_user_content_manager_new();
|
||||||
cookiemanager = webkit_web_context_get_cookie_manager(web_context);
|
cookiemanager = webkit_web_context_get_cookie_manager(web_context);
|
||||||
|
|
||||||
webkit_cookie_manager_set_persistent_storage(cookiemanager, CACHE_DIR "/cookies.sqlite",
|
webkit_cookie_manager_set_persistent_storage(
|
||||||
|
cookiemanager, CACHE_DIR "/cookies.sqlite",
|
||||||
WEBKIT_COOKIE_PERSISTENT_STORAGE_SQLITE);
|
WEBKIT_COOKIE_PERSISTENT_STORAGE_SQLITE);
|
||||||
|
|
||||||
webkit_cookie_manager_set_accept_policy(cookiemanager, WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS);
|
webkit_cookie_manager_set_accept_policy(cookiemanager,
|
||||||
|
WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS);
|
||||||
|
|
||||||
webkit_web_context_set_process_model(web_context,
|
webkit_web_context_set_process_model(
|
||||||
WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES);
|
web_context, WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES);
|
||||||
|
|
||||||
if (g_file_get_contents("~/.config/rose/style.css", &style, NULL, NULL))
|
if (g_file_get_contents("~/.config/rose/style.css", &style, NULL, NULL))
|
||||||
webkit_user_content_manager_add_style_sheet(
|
webkit_user_content_manager_add_style_sheet(
|
||||||
contentmanager,
|
contentmanager, webkit_user_style_sheet_new(style, WEBKIT_USER_CONTENT_INJECT_ALL_FRAMES, WEBKIT_USER_STYLE_LEVEL_USER, NULL, NULL));
|
||||||
webkit_user_style_sheet_new(style, WEBKIT_USER_CONTENT_INJECT_ALL_FRAMES,
|
|
||||||
WEBKIT_USER_STYLE_LEVEL_USER, NULL, NULL));
|
|
||||||
|
|
||||||
return g_object_new(WEBKIT_TYPE_WEB_VIEW, "settings", settings, "web-context", web_context,
|
return g_object_new(WEBKIT_TYPE_WEB_VIEW, "settings", settings, "web-context",
|
||||||
"user-content-manager", contentmanager, NULL);
|
web_context, "user-content-manager", contentmanager,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
WebKitWebView* notebook_get_webview(GtkNotebook* notebook)
|
||||||
|
{
|
||||||
|
return WEBKIT_WEB_VIEW(gtk_notebook_get_nth_page(
|
||||||
|
notebook, gtk_notebook_get_current_page(notebook)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void load_uri(WebKitWebView* view, const char* uri)
|
void load_uri(WebKitWebView* view, const char* uri)
|
||||||
{
|
{
|
||||||
if (g_str_has_prefix(uri, "http://") || g_str_has_prefix(uri, "https://") ||
|
if (g_str_has_prefix(uri, "http://") || g_str_has_prefix(uri, "https://") || 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 load_changed(WebKitWebView *self, WebKitLoadEvent load_event, GtkNotebook *notebook)
|
void redirect_if_annoying(WebKitWebView* view, const char* uri)
|
||||||
{
|
{
|
||||||
if (load_event == WEBKIT_LOAD_FINISHED) {
|
int l = LIBRE_N + strlen(uri) + 1;
|
||||||
gtk_notebook_set_tab_label_text(notebook, GTK_WIDGET(self),
|
char uri_filtered[l];
|
||||||
webkit_web_view_get_title(self));
|
str_init(uri_filtered, l);
|
||||||
gtk_widget_hide(GTK_WIDGET(bar));
|
|
||||||
|
int check = libre_redirect(uri, uri_filtered);
|
||||||
|
|
||||||
|
if (check == 2) {
|
||||||
|
webkit_web_view_load_uri(view, uri_filtered);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void load_changed(WebKitWebView* self, WebKitLoadEvent load_event,
|
||||||
|
GtkNotebook* notebook)
|
||||||
|
{
|
||||||
|
switch (load_event) {
|
||||||
|
/* see <https://webkitgtk.org/reference/webkit2gtk/2.5.1/WebKitWebView.html>
|
||||||
|
*/
|
||||||
|
case WEBKIT_LOAD_STARTED:
|
||||||
|
if (CUSTOM_STYLE_ENABLED) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
if (LIBRE_REDIRECT_ENABLED) {
|
||||||
|
redirect_if_annoying(self, webkit_web_view_get_uri(self));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case WEBKIT_LOAD_REDIRECTED:
|
||||||
|
if (LIBRE_REDIRECT_ENABLED) {
|
||||||
|
redirect_if_annoying(self, webkit_web_view_get_uri(self));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case WEBKIT_LOAD_COMMITTED:
|
||||||
|
if (LIBRE_REDIRECT_ENABLED) {
|
||||||
|
redirect_if_annoying(self, webkit_web_view_get_uri(self));
|
||||||
|
}
|
||||||
|
if (CUSTOM_STYLE_ENABLED) {
|
||||||
|
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;
|
||||||
|
case WEBKIT_LOAD_FINISHED: {
|
||||||
|
/* Add gtk tab title */
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 +208,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,12 +217,8 @@ 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), "-");
|
||||||
|
webkit_web_view_set_zoom_level(view, ZOOM);
|
||||||
WebKitWebView *notebook_get_webview(GtkNotebook *notebook)
|
|
||||||
{
|
|
||||||
return WEBKIT_WEB_VIEW(
|
|
||||||
gtk_notebook_get_nth_page(notebook, gtk_notebook_get_current_page(notebook)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void show_bar(GtkNotebook* notebook)
|
void show_bar(GtkNotebook* notebook)
|
||||||
|
@ -123,12 +229,15 @@ void show_bar(GtkNotebook *notebook)
|
||||||
gtk_entry_buffer_set_text(search_buf, url, strlen(url));
|
gtk_entry_buffer_set_text(search_buf, url, strlen(url));
|
||||||
gtk_widget_show(GTK_WIDGET(bar));
|
gtk_widget_show(GTK_WIDGET(bar));
|
||||||
gtk_window_set_focus(window, GTK_WIDGET(search));
|
gtk_window_set_focus(window, GTK_WIDGET(search));
|
||||||
|
} else if (entry_mode == _HIDDEN) {
|
||||||
|
gtk_widget_hide(GTK_WIDGET(bar));
|
||||||
} else {
|
} else {
|
||||||
const char* search_text = webkit_find_controller_get_search_text(
|
const char* search_text = webkit_find_controller_get_search_text(
|
||||||
webkit_web_view_get_find_controller(notebook_get_webview(notebook)));
|
webkit_web_view_get_find_controller(notebook_get_webview(notebook)));
|
||||||
|
|
||||||
if (search_text != NULL)
|
if (search_text != NULL)
|
||||||
gtk_entry_buffer_set_text(search_buf, search_text, strlen(search_text));
|
gtk_entry_buffer_set_text(search_buf, search_text, strlen(search_text));
|
||||||
|
|
||||||
gtk_entry_set_placeholder_text(search, "Find");
|
gtk_entry_set_placeholder_text(search, "Find");
|
||||||
gtk_widget_show(GTK_WIDGET(bar));
|
gtk_widget_show(GTK_WIDGET(bar));
|
||||||
gtk_window_set_focus(window, GTK_WIDGET(search));
|
gtk_window_set_focus(window, GTK_WIDGET(search));
|
||||||
|
@ -160,15 +269,18 @@ int handle_key(func id, GtkNotebook *notebook)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case zoomin:
|
case zoomin:
|
||||||
webkit_web_view_set_zoom_level(notebook_get_webview(notebook), (zoom += ZOOM_VAL));
|
webkit_web_view_set_zoom_level(notebook_get_webview(notebook),
|
||||||
|
(zoom += ZOOM_VAL));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case zoomout:
|
case zoomout:
|
||||||
webkit_web_view_set_zoom_level(notebook_get_webview(notebook), (zoom -= ZOOM_VAL));
|
webkit_web_view_set_zoom_level(notebook_get_webview(notebook),
|
||||||
|
(zoom -= ZOOM_VAL));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case zoom_reset:
|
case zoom_reset:
|
||||||
webkit_web_view_set_zoom_level(notebook_get_webview(notebook), (zoom = ZOOM));
|
webkit_web_view_set_zoom_level(notebook_get_webview(notebook),
|
||||||
|
(zoom = ZOOM));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case prev_tab:
|
case prev_tab:
|
||||||
|
@ -182,10 +294,10 @@ int handle_key(func id, GtkNotebook *notebook)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case next_tab:
|
case next_tab:
|
||||||
if (gtk_notebook_get_current_page(notebook) ==
|
if (gtk_notebook_get_current_page(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);
|
||||||
}
|
}
|
||||||
|
@ -233,6 +345,29 @@ 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 new_tab:
|
||||||
|
notebook_append(notebook, NULL);
|
||||||
|
gtk_notebook_set_show_tabs(notebook, true);
|
||||||
|
entry_mode = _SEARCH;
|
||||||
|
show_bar(notebook);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case hide_bar:
|
||||||
|
entry_mode = _HIDDEN;
|
||||||
|
show_bar(notebook);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case prettify: {
|
||||||
|
if (READABILITY_ENABLED) {
|
||||||
|
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;
|
||||||
|
@ -252,7 +387,8 @@ int keypress(void *self, GdkEvent *e, GtkNotebook *notebook)
|
||||||
void search_activate(GtkEntry* self, GtkNotebook* notebook)
|
void search_activate(GtkEntry* self, GtkNotebook* notebook)
|
||||||
{
|
{
|
||||||
if (entry_mode == _SEARCH)
|
if (entry_mode == _SEARCH)
|
||||||
load_uri(notebook_get_webview(notebook), gtk_entry_buffer_get_text(search_buf));
|
load_uri(notebook_get_webview(notebook),
|
||||||
|
gtk_entry_buffer_get_text(search_buf));
|
||||||
else if (entry_mode == _FIND)
|
else if (entry_mode == _FIND)
|
||||||
webkit_find_controller_search(
|
webkit_find_controller_search(
|
||||||
webkit_web_view_get_find_controller(notebook_get_webview(notebook)),
|
webkit_web_view_get_find_controller(notebook_get_webview(notebook)),
|
||||||
|
@ -266,17 +402,15 @@ void search_activate(GtkEntry *self, GtkNotebook *notebook)
|
||||||
void window_init(GtkNotebook* notebook)
|
void window_init(GtkNotebook* notebook)
|
||||||
{
|
{
|
||||||
GtkCssProvider* css = gtk_css_provider_new();
|
GtkCssProvider* css = gtk_css_provider_new();
|
||||||
|
gtk_css_provider_load_from_path(css, "/usr/share/themes/rose/style.css",
|
||||||
gtk_css_provider_load_from_path(css, "/usr/share/themes/rose/style.css", NULL);
|
NULL);
|
||||||
gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), GTK_STYLE_PROVIDER(css),
|
gtk_style_context_add_provider_for_screen(gdk_screen_get_default(),
|
||||||
800);
|
GTK_STYLE_PROVIDER(css), 800);
|
||||||
|
|
||||||
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));
|
||||||
|
|
||||||
g_signal_connect(search, "activate", G_CALLBACK(search_activate), notebook);
|
g_signal_connect(search, "activate", G_CALLBACK(search_activate), notebook);
|
||||||
g_signal_connect(window, "key-press-event", G_CALLBACK(keypress), notebook);
|
g_signal_connect(window, "key-press-event", G_CALLBACK(keypress), notebook);
|
||||||
g_signal_connect(window, "destroy", G_CALLBACK(exit), notebook);
|
g_signal_connect(window, "destroy", G_CALLBACK(exit), notebook);
|
||||||
|
@ -289,28 +423,41 @@ void notebook_init(GtkNotebook *notebook, const char *uri)
|
||||||
notebook_append(notebook, uri);
|
notebook_append(notebook, uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup(GtkNotebook *notebook, const char *uri)
|
void setup(GtkNotebook* notebook, int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
// Define GTK entities
|
||||||
window = GTK_WINDOW(gtk_window_new(0));
|
window = GTK_WINDOW(gtk_window_new(0));
|
||||||
notebook = GTK_NOTEBOOK(gtk_notebook_new());
|
notebook = GTK_NOTEBOOK(gtk_notebook_new());
|
||||||
bar = GTK_HEADER_BAR(gtk_header_bar_new());
|
bar = GTK_HEADER_BAR(gtk_header_bar_new());
|
||||||
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_set_default_size(window, WIDTH, HEIGHT);
|
||||||
window_init(notebook);
|
window_init(notebook);
|
||||||
notebook_init(notebook, uri);
|
|
||||||
|
|
||||||
|
// Initialize with first uri
|
||||||
|
char* first_uri = argc > 1 ? argv[1] : NULL;
|
||||||
|
notebook_init(notebook, first_uri);
|
||||||
g_object_set(gtk_settings_get_default(), GTK, NULL);
|
g_object_set(gtk_settings_get_default(), GTK, NULL);
|
||||||
|
|
||||||
|
// More GTK stuff
|
||||||
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));
|
||||||
|
|
||||||
|
// Deal with more uris, if this is necessary.
|
||||||
|
if (argc > 2) {
|
||||||
|
gtk_notebook_set_show_tabs(notebook, true);
|
||||||
|
for (int i = 2; i < argc; i++) {
|
||||||
|
notebook_append(notebook, argv[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
GtkNotebook* notebook;
|
GtkNotebook* notebook;
|
||||||
gtk_init(NULL, NULL);
|
gtk_init(NULL, NULL);
|
||||||
setup(notebook, argc > 1 ? argv[1] : NULL);
|
setup(notebook, argc, argv);
|
||||||
gtk_main();
|
gtk_main();
|
||||||
|
// this point is never reached, since gtk_main(); never exits.
|
||||||
}
|
}
|
||||||
|
|
BIN
screenshots/1-startup.png
Normal file
After Width: | Height: | Size: 257 KiB |
BIN
screenshots/2-blog.png
Normal file
After Width: | Height: | Size: 534 KiB |
BIN
screenshots/3-multiple-tabs.png
Normal file
After Width: | Height: | Size: 172 KiB |
BIN
screenshots/4-money-stuff-raw.png
Normal file
After Width: | Height: | Size: 250 KiB |
BIN
screenshots/5-money-stuff-readability.png
Normal file
After Width: | Height: | Size: 198 KiB |
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;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
DEPS='webkit2gtk-4.0'
|
||||||
|
INCS=`pkg-config --cflags ${DEPS}`
|
||||||
|
LIBS=`pkg-config --libs ${DEPS}`
|
||||||
|
echo $INCS
|
||||||
|
echo $LIBS
|
BIN
user-scripts/styles/images/style-nuno.png
Normal file
After Width: | Height: | Size: 178 KiB |
BIN
user-scripts/styles/images/style-original.png
Normal file
After Width: | Height: | Size: 175 KiB |
52
user-scripts/styles/style-nuno.css
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
@define-color Surface0 #313244;
|
||||||
|
@define-color Surface1 #45475a;
|
||||||
|
@define-color Base #1e1e2e;
|
||||||
|
@define-color Mantle #181825;
|
||||||
|
@define-color Lavender #b4befe;
|
||||||
|
@define-color Text #cdd6f4;
|
||||||
|
|
||||||
|
* {
|
||||||
|
padding: 0px;
|
||||||
|
margin: 0px;
|
||||||
|
outline-color: @Lavender;
|
||||||
|
color: @Text;
|
||||||
|
border-color: white;
|
||||||
|
font-size: 16px;
|
||||||
|
/*@Base; */
|
||||||
|
/* border-bottom-color: @Base; */
|
||||||
|
}
|
||||||
|
|
||||||
|
window, notebook, headerbar {
|
||||||
|
background: @Base;
|
||||||
|
}
|
||||||
|
|
||||||
|
tabs {
|
||||||
|
background-color: @Base;
|
||||||
|
padding: 3px;
|
||||||
|
outline-color: white;
|
||||||
|
border-color: @Base;
|
||||||
|
}
|
||||||
|
|
||||||
|
tab {
|
||||||
|
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;
|
||||||
|
padding-left: 10px;
|
||||||
|
padding-right: 10px; */
|
||||||
|
}
|
||||||
|
|
||||||
|
entry {
|
||||||
|
background-color: @Surface0;
|
||||||
|
padding-left: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
entry:focus {
|
||||||
|
background-color: @Surface0;
|
||||||
|
padding-left: 10px;
|
||||||
|
|
||||||
|
}
|
37
user-scripts/styles/style-original.css
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
@define-color Surface0 #313244;
|
||||||
|
@define-color Surface1 #45475a;
|
||||||
|
@define-color Base #1e1e2e;
|
||||||
|
@define-color Mantle #181825;
|
||||||
|
@define-color Lavender #b4befe;
|
||||||
|
@define-color Text #cdd6f4;
|
||||||
|
|
||||||
|
* {
|
||||||
|
padding: 0px;
|
||||||
|
margin: 0px;
|
||||||
|
outline-color: @Lavender;
|
||||||
|
color: @Text;
|
||||||
|
border-bottom-color: @Base;
|
||||||
|
}
|
||||||
|
|
||||||
|
window, notebook, headerbar {
|
||||||
|
background: @Base;
|
||||||
|
}
|
||||||
|
|
||||||
|
tabs {
|
||||||
|
background-color: @Base;
|
||||||
|
padding: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
tab {
|
||||||
|
background-color: @Base;
|
||||||
|
margin: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
entry {
|
||||||
|
background-color: @Surface0;
|
||||||
|
padding-left: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
entry:focus {
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
31
user-scripts/ubuntu-20.04/install-with-dependencies.sh
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
# 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 ..
|
||||||
|
mkdir -p ~/.config/wyebadblock
|
||||||
|
cd ~/.config/wyebadblock
|
||||||
|
wget https://easylist.to/easylist/easylist.txt
|
||||||
|
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
|
||||||
|
cd ../..
|
||||||
|
make build # or just make
|
||||||
|
sudo make install
|
||||||
|
|
||||||
|
cd -
|
||||||
|
# Ubuntu desktop icon
|
||||||
|
chmod +x rose.desktop
|
||||||
|
sudo cp rose.desktop /usr/share/applications
|
BIN
user-scripts/ubuntu-20.04/rose-images/rose-1.png
Normal file
After Width: | Height: | Size: 625 KiB |
BIN
user-scripts/ubuntu-20.04/rose-images/rose-2.png
Normal file
After Width: | Height: | Size: 474 KiB |
BIN
user-scripts/ubuntu-20.04/rose-images/rose-desktop-icon.png
Normal file
After Width: | Height: | Size: 739 KiB |
BIN
user-scripts/ubuntu-20.04/rose-images/rose-homepage.png
Normal file
After Width: | Height: | Size: 474 KiB |
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
|
@ -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/rosenrot/user-scripts/ubuntu-20.04/rose-images/rose-desktop-icon.png
|
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
|
||||||
|
```
|