Compare commits

..

No commits in common. "4d94d2d2e6aa43cb478748aa093c9054de67914a" and "799e4c4ab7d55d6ff70488b720b33cd4f955eddf" have entirely different histories.

11 changed files with 486 additions and 807 deletions

View File

@ -2,13 +2,10 @@
#include <stdbool.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 */
* #define WEBKIT \
*/ "enable-back-forward-navigation-gestures", true, "enable-developer-extras", true, \
#define WEBKIT_DEFAULT_SETTINGS \ "enable-smooth-scrolling", false
"enable-back-forward-navigation-gestures", true, "enable-developer-extras", true, \
"enable-smooth-scrolling", false, \
"default-charset", "utf-8"
#define GTK "gtk-application-prefer-dark-theme", false, "gtk-enable-animations", false #define GTK "gtk-application-prefer-dark-theme", false, "gtk-enable-animations", false
#define ROSE_HOMEPAGE false #define ROSE_HOMEPAGE false

View File

@ -96,4 +96,5 @@ clean:
rm $(CACHE_DIR) rm $(CACHE_DIR)
format: $(SRC) $(PLUGS) format: $(SRC) $(PLUGS)
$(FORMATTER) $(SRC) $(PLUGS) $(rose.h) $(FORMATTER) $(SRC) $(PLUGS)

View File

@ -37,8 +37,8 @@ int libre_redirect(const char* uri, char* output)
"https://translate.google.com", "https://translate.google.com",
"https://www.bloomberg.com", "https://www.bloomberg.com",
"https://www.royalroad.com", "https://www.royalroad.com",
"https://genius.com", "https://genius.com",
// "https://archive.org", // "https://archive.org",
// "https://twitter.com" // "https://twitter.com"
}; };
@ -48,10 +48,10 @@ int libre_redirect(const char* uri, char* output)
"https://search.nunosempere.com", "https://search.nunosempere.com",
"https://scribe.rip", "https://scribe.rip",
"https://translate.riverside.rocks/", "https://translate.riverside.rocks/",
"https://archive.today/https://www.bloomberg.com", "https://archive.is/https://www.bloomberg.com",
"https://royalread.nunosempere.com", "https://royalread.nunosempere.com",
"https://dumb.vern.cc", "https://dumb.vern.cc",
// "https://wayback.nunosempere.com", // "https://wayback.nunosempere.com",
// "https://nitter.net" // "https://nitter.net"
}; };

View File

@ -1,7 +1,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#define READABILITY_N 88023 + 1000 #define READABILITY_N 85314 + 1000
void read_readability_js(char* string) void read_readability_js(char* string)
{ {

View File

@ -1,7 +1,7 @@
#ifndef READABILITY #ifndef READABILITY
#define READABILITY #define READABILITY
#define READABILITY_N 88023 + 1000 #define READABILITY_N 85314 + 1000
void read_readability_js(char* string); void read_readability_js(char* string);

File diff suppressed because it is too large Load Diff

View File

@ -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 4709 + 100 #define STYLE_N 4748 + 100
void read_style_js(char* string) void read_style_js(char* string)
{ {

View File

@ -1,7 +1,7 @@
#ifndef STYLE #ifndef STYLE
#define STYLE #define STYLE
#define STYLE_N 4709 + 100 #define STYLE_N 4748 + 100
void read_style_js(char* string); void read_style_js(char* string);

View File

@ -2,8 +2,8 @@
var styles = null; var styles = null;
if (document.domain == "forum.effectivealtruism.org") { if (document.domain == "forum.effectivealtruism.org"){
styles = ` styles = `
.Layout-main { .Layout-main {
margin-left: 100px; margin-left: 100px;
} }
@ -18,15 +18,15 @@ if (document.domain == "forum.effectivealtruism.org") {
.intercom-lightweight-app{ .intercom-lightweight-app{
display: none; display: none;
} }
`; `
var styleSheet = document.createElement("style"); var styleSheet = document.createElement('style')
styleSheet.innerText = styles; styleSheet.innerText = styles
document.head.appendChild(styleSheet); document.head.appendChild(styleSheet)
console.log("Style changed"); console.log('Style changed')
} }
if (document.domain == "mail.proton.me") { if (document.domain == "mail.proton.me" ){
styles = ` styles = `
/* /*
.item-container-row.read, .item-container.read { .item-container-row.read, .item-container.read {
background-color: white; background-color: white;
@ -39,16 +39,16 @@ if (document.domain == "mail.proton.me") {
} }
zoom: 0.625 !important; zoom: 0.625 !important;
*/ */
`; `
} }
if (document.domain == "forum.nunosempere.com") { if (document.domain == "forum.nunosempere.com" ){
styles = ` styles = `
body { body {
zoom: 0.625 !important; zoom: 0.625 !important;
} }
`; `
} }
if (document.domain == "search.nunosempere.com") { if (document.domain == "search.nunosempere.com" ){
styles = ` styles = `
body { body {
/* zoom: 1.8; */ /* zoom: 1.8; */
@ -57,9 +57,9 @@ if (document.domain == "search.nunosempere.com") {
footer { footer {
display: none; display: none;
} }
`; `
} }
if (document.domain == "twitter.com") { if (document.domain == "twitter.com" ){
styles = ` styles = `
/* hide promoted tweets */ /* hide promoted tweets */
:has(meta[property="og:site_name"][content="Twitter"]) :has(meta[property="og:site_name"][content="Twitter"])
@ -78,11 +78,11 @@ if (document.domain == "twitter.com") {
[data-testid^="sidebarColumn"] { [data-testid^="sidebarColumn"] {
display: none; display: none;
} }
`; `
} }
if (document.domain == "reddit.com" || document.domain == "old.reddit.com") { if (document.domain == "reddit.com" || document.domain == "old.reddit.com"){
styles = ` styles = `
/* kill sidebar ads */ /* kill sidebar ads */
.native-ad-container, .native-ad-container,
.premium-banner-outer, .premium-banner-outer,
@ -97,22 +97,23 @@ if (document.domain == "reddit.com" || document.domain == "old.reddit.com") {
{ {
display: none !important; display: none !important;
} }
`; `
} }
if (styles != null) { if(styles != null){
var styleSheet = document.createElement("style"); var styleSheet = document.createElement('style')
styleSheet.innerText = styles; styleSheet.innerText = styles
document.head.appendChild(styleSheet); document.head.appendChild(styleSheet)
console.log("Style changed"); console.log('Style changed')
} }
// Replace default alert with new function // Replace default alert with new function
// whose style can be changed! // whose style can be changed!
window.alert = (message) => { window.alert = (message) => {
let alertDiv = document.getElementById("customAlert"); let alertDiv = document.getElementById('customAlert');
if (!alertDiv) { if (!alertDiv) {
const html = ` const html = `
<div id="customAlert" class="custom-alert"> <div id="customAlert" class="custom-alert">
<div class="custom-alert-content"> <div class="custom-alert-content">
<p id="alertMessage"></p> <p id="alertMessage"></p>
@ -144,29 +145,26 @@ window.alert = (message) => {
} }
</style> </style>
`; `;
document.body.insertAdjacentHTML("beforeend", html); document.body.insertAdjacentHTML('beforeend', html);
alertDiv = document.getElementById("customAlert"); alertDiv = document.getElementById('customAlert');
document.getElementById("alertOkButton").onclick = () => { document.getElementById('alertOkButton').onclick = () => {
alertDiv.classList.remove("visible"); alertDiv.classList.remove('visible');
document.removeEventListener("keydown", dismissAlert); document.removeEventListener('keydown', dismissAlert);
}; };
}
const dismissAlert = (event) => {
if (
event.key === "Enter" /*&& event.ctrlKey*/ &&
alertDiv.classList.contains("visible")
) {
alertDiv.classList.remove("visible");
document.removeEventListener("keydown", dismissAlert);
} }
};
document.addEventListener("keydown", dismissAlert); const dismissAlert = (event) => {
document.getElementById("alertMessage").textContent = message; if (event.key === 'Enter' /*&& event.ctrlKey*/ && alertDiv.classList.contains('visible')) {
alertDiv.classList.add("visible"); alertDiv.classList.remove('visible');
}; document.removeEventListener('keydown', dismissAlert);
}
}
document.addEventListener('keydown', dismissAlert);
document.getElementById('alertMessage').textContent = message;
alertDiv.classList.add('visible');
}
// ^ takes 0.014ms to run, so performance is not the concern here. // ^ takes 0.014ms to run, so performance is not the concern here.
// timed with console.time, console.timeEnd // timed with console.time, console.timeEnd
document.body.style.visibility = "visible"; document.body.style.visibility = "visible"

BIN
rose

Binary file not shown.

4
rose.c
View File

@ -55,7 +55,7 @@ WebKitWebView* webview_new()
WebKitCookieManager* cookiemanager; WebKitCookieManager* cookiemanager;
WebKitUserContentManager* contentmanager; WebKitUserContentManager* contentmanager;
settings = webkit_settings_new_with_settings(WEBKIT_DEFAULT_SETTINGS, NULL); settings = webkit_settings_new_with_settings(WEBKIT, NULL);
if (CUSTOM_USER_AGENT) { if (CUSTOM_USER_AGENT) {
webkit_settings_set_user_agent( webkit_settings_set_user_agent(
settings, settings,
@ -204,7 +204,7 @@ GtkWidget* handle_create_new_tab(WebKitWebView* self,
} else { } else {
webkit_web_view_run_javascript(notebook_get_webview(notebook), webkit_web_view_run_javascript(notebook_get_webview(notebook),
"alert('Too many tabs, not opening a new one')", NULL, NULL, NULL); "alert('Too many tabs, not opening a new one')", NULL, NULL, NULL);
return NULL; return NULL;
} }
/* WebKitGTK documentation recommends returning the new webview. /* WebKitGTK documentation recommends returning the new webview.
* I imagine that this might allow e.g., to go back in a new tab * I imagine that this might allow e.g., to go back in a new tab