Compare commits

..

No commits in common. "70849e74d6779bea05a236dd529145807fa637fd" and "a1a22bb282b18c555179c40345b3954bf18db471" have entirely different histories.

6 changed files with 26 additions and 27 deletions

View File

@ -17,7 +17,6 @@ CONFIG=config.h
# Plugins
include plugins/plugins.mk
# PLUGINS=./plugins/stand_in/stand_in.c
ADBLOCK='-L/usr/lib/wyebrowser/adblock.so' # optional adblocking; depends on https://github.com/jun7/wyebadblock
## Formatter
STYLE_BLUEPRINT="{BasedOnStyle: webkit, AllowShortIfStatementsOnASingleLine: true, IndentCaseLabels: true, AllowShortEnumsOnASingleLine: true}"

View File

@ -7,6 +7,8 @@ SHORTCUTS=./plugins/shortcuts/shortcuts.c
READABILITY=./plugins/readability/readability.c
LIBRE_REDIRECT=./plugins/libre_redirect/libre_redirect.c
ADBLOCK='-L/usr/lib/wyebrowser/adblock.so' # optional adblocking; depends on https://github.com/jun7/wyebadblock
STAND_IN=./plugins/stand_in/stand_in.c # gives function definitions for the above, which do nothing
PLUGINS=$(COMMON_CODE) $(CUSTOM_STYLES) $(SHORTCUTS) $(READABILITY) $(LIBRE_REDIRECT)

View File

@ -1,7 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define STYLE_N 7827 + 1000
#define STYLE_N 7624 + 1000
void read_style_js(char* string)
{

View File

@ -1,5 +1,5 @@
#pragma once
#define STYLE_N 7827 + 1000
#define STYLE_N 7624 + 1000
void read_style_js(char* string);

View File

@ -2,7 +2,6 @@
// Main part of the code: switch on the domain and select the corresponding style
var styles = null;
console.log(document.domain)
switch (document.domain) {
case "forum.effectivealtruism.org":
styles = `
@ -54,14 +53,6 @@ switch (document.domain) {
}
`;
break;
case "search.brave.com":
styles = `
.download-button,
a[href^="https://brave.com/download/"] {
display: none !important;
}
`;
break;
case "search.nunosempere.com":
styles = `
/*
@ -90,8 +81,6 @@ switch (document.domain) {
.native-ad-container,
.native-sidebar-ad,
.premium-banner-outer,
.promotedlink,
.promoted
{
display: none !important;
}
@ -163,6 +152,7 @@ switch (document.domain) {
/* No change of colors in hover */
*:hover {
/* background-color: white !important; */
background-color: !important;
transition: none !important;
}*/
/*
@ -293,4 +283,4 @@ if (document.domain == "twitter.com") {
hideVideoPlayerGrandparent();
}
// document.body.style.visibility = "visible";
document.body.style.visibility = "visible";

View File

@ -9,17 +9,16 @@
/* Global declarations */
static GtkNotebook* notebook;
static GtkWindow* window;
typedef enum { _SEARCH, _FIND, _HIDDEN } Bar_entry_mode;
static struct {
GtkHeaderBar* widget;
GtkEntry* line;
GtkEntryBuffer* line_text;
Bar_entry_mode entry_mode;
enum { _SEARCH, _FIND, _HIDDEN } entry_mode;
} bar;
static int num_tabs = 0;
// Forward declarations
void toggle_bar(GtkNotebook* notebook, Bar_entry_mode mode);
void toggle_bar(GtkNotebook* notebook);
void notebook_create_new_tab(GtkNotebook* notebook, const char* uri);
/* Utils */
@ -34,7 +33,8 @@ void load_uri(WebKitWebView* view, const char* uri)
{
if (strlen(uri) == 0) {
webkit_web_view_load_uri(view, "");
toggle_bar(notebook, _SEARCH);
bar.entry_mode = _SEARCH;
toggle_bar(notebook);
} else 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:")) {
webkit_web_view_load_uri(view, uri);
} else if (strstr(uri, ".com") || strstr(uri, ".org")) {
@ -192,9 +192,8 @@ void notebook_create_new_tab(GtkNotebook* notebook, const char* uri)
}
/* Top bar */
void toggle_bar(GtkNotebook* notebook, Bar_entry_mode mode)
void toggle_bar(GtkNotebook* notebook)
{
bar.entry_mode = mode;
switch (bar.entry_mode) {
case _SEARCH: {
const char* url = webkit_web_view_get_uri(notebook_get_webview(notebook));
@ -220,7 +219,6 @@ void toggle_bar(GtkNotebook* notebook, Bar_entry_mode mode)
gtk_widget_hide(GTK_WIDGET(bar.widget));
}
}
// Handle what happens when the user is on the bar and presses enter
void handle_signal_bar_press_enter(GtkEntry* self, GtkNotebook* notebook)
{
@ -314,10 +312,12 @@ int handle_shortcut(func id, GtkNotebook* notebook)
break;
case show_searchbar:
toggle_bar(notebook, _SEARCH);
bar.entry_mode = _SEARCH;
toggle_bar(notebook);
break;
case show_finder:
toggle_bar(notebook, _FIND);
bar.entry_mode = _FIND;
toggle_bar(notebook);
break;
case finder_next:
@ -330,11 +330,13 @@ int handle_shortcut(func id, GtkNotebook* notebook)
case new_tab:
notebook_create_new_tab(notebook, NULL);
gtk_notebook_set_show_tabs(notebook, true);
toggle_bar(notebook, _SEARCH);
bar.entry_mode = _SEARCH;
toggle_bar(notebook);
break;
case hide_bar:
toggle_bar(notebook, _HIDDEN);
bar.entry_mode = _HIDDEN;
toggle_bar(notebook);
break;
case prettify: {
@ -360,9 +362,15 @@ int handle_signal_keypress(void* self, GdkEvent* event, GtkNotebook* notebook)
GdkModifierType event_state = 0;
gdk_event_get_state(event, &event_state);
if (0) {
int debug_shortcuts = 0;
if (debug_shortcuts) {
printf("Keypress state: %d\n", event_state);
if (event_state & GDK_CONTROL_MASK) {
printf("Keypress state is: CONTROL\n");
}
printf("Keypress value: %d\n", event_keyval);
printf("PageUp: %d %d\n", KEY(Page_Up), GDK_KEY_KP_Page_Up);
printf("PageDown: %d %d\n", KEY(Page_Down), GDK_KEY_KP_Page_Down);
}
for (int i = 0; i < sizeof(shortcut) / sizeof(shortcut[0]); i++)