From a6835ab2ae80e7c41d09096314f1e4346f53785c Mon Sep 17 00:00:00 2001 From: NunoSempere Date: Tue, 13 Dec 2022 22:10:34 +0000 Subject: [PATCH] tweak: cleanup after adding "plugin" --- config.def.h | 1 + config.h | 2 ++ plugins/libre_redirect/libre_redirect.c | 6 ++--- plugins/libre_redirect/str_replace_start.c | 2 +- rose.c | 30 +++++++--------------- 5 files changed, 15 insertions(+), 26 deletions(-) diff --git a/config.def.h b/config.def.h index 9cf2720..c2daff4 100644 --- a/config.def.h +++ b/config.def.h @@ -29,6 +29,7 @@ #define BG_COLOR "#1E1E2E" /* or "#FEFEFE" if you are not using the dark theme. */ #define WIDTH 500 #define HEIGHT 400 +#define DEBUG false typedef enum { goback, diff --git a/config.h b/config.h index a660076..d6ff1ad 100644 --- a/config.h +++ b/config.h @@ -10,6 +10,7 @@ */ #include +#include /* See more: * https://webkitgtk.org/reference/webkit2gtk/stable/class.Settings.html */ @@ -29,6 +30,7 @@ #define ZOOM 1.4 /* Starting zoom level.*/ #define ZOOM_VAL .1 /* Zooming value in zoomin/zoomout functions */ #define BG_COLOR "#FEFEFE" /*"#1E1E2E" */ +#define DEBUG false typedef enum { goback, diff --git a/plugins/libre_redirect/libre_redirect.c b/plugins/libre_redirect/libre_redirect.c index 03ab830..97def55 100644 --- a/plugins/libre_redirect/libre_redirect.c +++ b/plugins/libre_redirect/libre_redirect.c @@ -3,7 +3,7 @@ #include #include #define LIBRE_N 12 -#define DEBUG true +#define DEBUG false /* Inspired by https://libredirect.github.io/, but in C. */ @@ -28,8 +28,7 @@ int libre_redirect(const char* uri, char* output){ strcpy(tmp_output, output); char* sites[] = { - "https://youtube.com", - "https://reddit.com", + "https://www.youtube.com", "https://www.reddit.com", "https://medium.com", "https://translate.google.com" @@ -37,7 +36,6 @@ int libre_redirect(const char* uri, char* output){ char* alternatives[] = { "https://yt.artemislena.eu", "https://teddit.nunosempere.com", - "https://teddit.nunosempere.com", "https://scribe.rip", "https://simplytranslate.org/" }; diff --git a/plugins/libre_redirect/str_replace_start.c b/plugins/libre_redirect/str_replace_start.c index 0d96f91..b8bf050 100755 --- a/plugins/libre_redirect/str_replace_start.c +++ b/plugins/libre_redirect/str_replace_start.c @@ -1,7 +1,7 @@ #include #include #include -#define DEBUG true +#define DEBUG false /* See also: diff --git a/rose.c b/rose.c index 307d757..6e630e9 100644 --- a/rose.c +++ b/rose.c @@ -9,11 +9,12 @@ * */ +#include +#include +#include #include "config.h" #include "plugins/libre_redirect/libre_redirect.h" -#include -#include #define CACHE \ "base-cache-directory", CACHE_DIR, \ @@ -26,7 +27,6 @@ "local-storage-directory", CACHE_DIR, \ "offline-application-cache-directory", CACHE_DIR, \ "service-worker-registrations-directory", CACHE_DIR -#define DEBUG false enum { _SEARCH, _FIND }; @@ -86,15 +86,14 @@ void redirect_if_annoying(WebKitWebView *view, const char *uri){ char uri_filtered[l]; str_init(uri_filtered, l); - printf("Uri: %s\n", uri); + 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); } - printf("uri_filtered: %s\n", uri_filtered); - printf("check: %d\n", check); - + 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) @@ -102,27 +101,16 @@ void load_changed(WebKitWebView *self, WebKitLoadEvent load_event, GtkNotebook * switch (load_event) { /* see */ case WEBKIT_LOAD_STARTED: - /* New load, we have now a provisional URI */ - //const char* provisional_uri = webkit_web_view_get_uri(self); - // printf("%s", provisional_uri); redirect_if_annoying(self, webkit_web_view_get_uri(self)); - printf("Load started with uri: %s\n", webkit_web_view_get_uri (self)); - //provisional_uri); - /* Here we could start a spinner or update the - * location bar with the provisional URI */ + 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)); - printf("Load redirected to uri: %s\n", 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: - /* The load is being performed. Current URI is - * the final one and it won't change unless a new - * load is requested or a navigation within the - * same page is performed */ redirect_if_annoying(self, webkit_web_view_get_uri(self)); - printf("Load committed with: %s\n", webkit_web_view_get_uri (self)); - //printf("%s", uri); + if(DEBUG) printf("Load committed with: %s\n", webkit_web_view_get_uri (self)); break; case WEBKIT_LOAD_FINISHED: gtk_notebook_set_tab_label_text(notebook, GTK_WIDGET(self),