tweaks: readd adblock, refactor toggle_bar, simplify
This commit is contained in:
parent
a1a22bb282
commit
136ad04678
1
makefile
1
makefile
|
@ -17,6 +17,7 @@ CONFIG=config.h
|
||||||
# Plugins
|
# Plugins
|
||||||
include plugins/plugins.mk
|
include plugins/plugins.mk
|
||||||
# PLUGINS=./plugins/stand_in/stand_in.c
|
# PLUGINS=./plugins/stand_in/stand_in.c
|
||||||
|
ADBLOCK='-L/usr/lib/wyebrowser/adblock.so' # optional adblocking; depends on https://github.com/jun7/wyebadblock
|
||||||
|
|
||||||
## Formatter
|
## Formatter
|
||||||
STYLE_BLUEPRINT="{BasedOnStyle: webkit, AllowShortIfStatementsOnASingleLine: true, IndentCaseLabels: true, AllowShortEnumsOnASingleLine: true}"
|
STYLE_BLUEPRINT="{BasedOnStyle: webkit, AllowShortIfStatementsOnASingleLine: true, IndentCaseLabels: true, AllowShortEnumsOnASingleLine: true}"
|
||||||
|
|
|
@ -7,8 +7,6 @@ SHORTCUTS=./plugins/shortcuts/shortcuts.c
|
||||||
READABILITY=./plugins/readability/readability.c
|
READABILITY=./plugins/readability/readability.c
|
||||||
LIBRE_REDIRECT=./plugins/libre_redirect/libre_redirect.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
|
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)
|
PLUGINS=$(COMMON_CODE) $(CUSTOM_STYLES) $(SHORTCUTS) $(READABILITY) $(LIBRE_REDIRECT)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#define STYLE_N 7624 + 1000
|
#define STYLE_N 7653 + 1000
|
||||||
|
|
||||||
void read_style_js(char* string)
|
void read_style_js(char* string)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define STYLE_N 7624 + 1000
|
#define STYLE_N 7653 + 1000
|
||||||
|
|
||||||
void read_style_js(char* string);
|
void read_style_js(char* string);
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
// Main part of the code: switch on the domain and select the corresponding style
|
// Main part of the code: switch on the domain and select the corresponding style
|
||||||
var styles = null;
|
var styles = null;
|
||||||
|
console.log(document.domain)
|
||||||
switch (document.domain) {
|
switch (document.domain) {
|
||||||
case "forum.effectivealtruism.org":
|
case "forum.effectivealtruism.org":
|
||||||
styles = `
|
styles = `
|
||||||
|
@ -81,6 +82,8 @@ switch (document.domain) {
|
||||||
.native-ad-container,
|
.native-ad-container,
|
||||||
.native-sidebar-ad,
|
.native-sidebar-ad,
|
||||||
.premium-banner-outer,
|
.premium-banner-outer,
|
||||||
|
.promotedlink,
|
||||||
|
.promoted
|
||||||
{
|
{
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
|
@ -152,7 +155,6 @@ switch (document.domain) {
|
||||||
/* No change of colors in hover */
|
/* No change of colors in hover */
|
||||||
*:hover {
|
*:hover {
|
||||||
/* background-color: white !important; */
|
/* background-color: white !important; */
|
||||||
background-color: !important;
|
|
||||||
transition: none !important;
|
transition: none !important;
|
||||||
}*/
|
}*/
|
||||||
/*
|
/*
|
||||||
|
@ -283,4 +285,4 @@ if (document.domain == "twitter.com") {
|
||||||
hideVideoPlayerGrandparent();
|
hideVideoPlayerGrandparent();
|
||||||
}
|
}
|
||||||
|
|
||||||
document.body.style.visibility = "visible";
|
// document.body.style.visibility = "visible";
|
||||||
|
|
32
rosenrot.c
32
rosenrot.c
|
@ -9,16 +9,17 @@
|
||||||
/* Global declarations */
|
/* Global declarations */
|
||||||
static GtkNotebook* notebook;
|
static GtkNotebook* notebook;
|
||||||
static GtkWindow* window;
|
static GtkWindow* window;
|
||||||
|
typedef enum { _SEARCH, _FIND, _HIDDEN } Bar_entry_mode;
|
||||||
static struct {
|
static struct {
|
||||||
GtkHeaderBar* widget;
|
GtkHeaderBar* widget;
|
||||||
GtkEntry* line;
|
GtkEntry* line;
|
||||||
GtkEntryBuffer* line_text;
|
GtkEntryBuffer* line_text;
|
||||||
enum { _SEARCH, _FIND, _HIDDEN } entry_mode;
|
Bar_entry_mode entry_mode;
|
||||||
} bar;
|
} bar;
|
||||||
static int num_tabs = 0;
|
static int num_tabs = 0;
|
||||||
|
|
||||||
// Forward declarations
|
// Forward declarations
|
||||||
void toggle_bar(GtkNotebook* notebook);
|
void toggle_bar(GtkNotebook* notebook, Bar_entry_mode mode);
|
||||||
void notebook_create_new_tab(GtkNotebook* notebook, const char* uri);
|
void notebook_create_new_tab(GtkNotebook* notebook, const char* uri);
|
||||||
|
|
||||||
/* Utils */
|
/* Utils */
|
||||||
|
@ -33,8 +34,7 @@ void load_uri(WebKitWebView* view, const char* uri)
|
||||||
{
|
{
|
||||||
if (strlen(uri) == 0) {
|
if (strlen(uri) == 0) {
|
||||||
webkit_web_view_load_uri(view, "");
|
webkit_web_view_load_uri(view, "");
|
||||||
bar.entry_mode = _SEARCH;
|
toggle_bar(notebook, _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:")) {
|
} 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);
|
webkit_web_view_load_uri(view, uri);
|
||||||
} else if (strstr(uri, ".com") || strstr(uri, ".org")) {
|
} else if (strstr(uri, ".com") || strstr(uri, ".org")) {
|
||||||
|
@ -192,8 +192,9 @@ void notebook_create_new_tab(GtkNotebook* notebook, const char* uri)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Top bar */
|
/* Top bar */
|
||||||
void toggle_bar(GtkNotebook* notebook)
|
void toggle_bar(GtkNotebook* notebook, Bar_entry_mode mode)
|
||||||
{
|
{
|
||||||
|
bar.entry_mode = mode;
|
||||||
switch (bar.entry_mode) {
|
switch (bar.entry_mode) {
|
||||||
case _SEARCH: {
|
case _SEARCH: {
|
||||||
const char* url = webkit_web_view_get_uri(notebook_get_webview(notebook));
|
const char* url = webkit_web_view_get_uri(notebook_get_webview(notebook));
|
||||||
|
@ -219,6 +220,7 @@ void toggle_bar(GtkNotebook* notebook)
|
||||||
gtk_widget_hide(GTK_WIDGET(bar.widget));
|
gtk_widget_hide(GTK_WIDGET(bar.widget));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle what happens when the user is on the bar and presses enter
|
// Handle what happens when the user is on the bar and presses enter
|
||||||
void handle_signal_bar_press_enter(GtkEntry* self, GtkNotebook* notebook)
|
void handle_signal_bar_press_enter(GtkEntry* self, GtkNotebook* notebook)
|
||||||
{
|
{
|
||||||
|
@ -312,12 +314,10 @@ int handle_shortcut(func id, GtkNotebook* notebook)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case show_searchbar:
|
case show_searchbar:
|
||||||
bar.entry_mode = _SEARCH;
|
toggle_bar(notebook, _SEARCH);
|
||||||
toggle_bar(notebook);
|
|
||||||
break;
|
break;
|
||||||
case show_finder:
|
case show_finder:
|
||||||
bar.entry_mode = _FIND;
|
toggle_bar(notebook, _FIND);
|
||||||
toggle_bar(notebook);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case finder_next:
|
case finder_next:
|
||||||
|
@ -330,13 +330,11 @@ int handle_shortcut(func id, GtkNotebook* notebook)
|
||||||
case new_tab:
|
case new_tab:
|
||||||
notebook_create_new_tab(notebook, NULL);
|
notebook_create_new_tab(notebook, NULL);
|
||||||
gtk_notebook_set_show_tabs(notebook, true);
|
gtk_notebook_set_show_tabs(notebook, true);
|
||||||
bar.entry_mode = _SEARCH;
|
toggle_bar(notebook, _SEARCH);
|
||||||
toggle_bar(notebook);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case hide_bar:
|
case hide_bar:
|
||||||
bar.entry_mode = _HIDDEN;
|
toggle_bar(notebook, _HIDDEN);
|
||||||
toggle_bar(notebook);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case prettify: {
|
case prettify: {
|
||||||
|
@ -362,15 +360,9 @@ int handle_signal_keypress(void* self, GdkEvent* event, GtkNotebook* notebook)
|
||||||
GdkModifierType event_state = 0;
|
GdkModifierType event_state = 0;
|
||||||
gdk_event_get_state(event, &event_state);
|
gdk_event_get_state(event, &event_state);
|
||||||
|
|
||||||
int debug_shortcuts = 0;
|
if (0) {
|
||||||
if (debug_shortcuts) {
|
|
||||||
printf("Keypress state: %d\n", event_state);
|
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("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++)
|
for (int i = 0; i < sizeof(shortcut) / sizeof(shortcut[0]); i++)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user