aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorNunoSempere <nuno.sempere@protonmail.com>2023-06-17 00:29:27 -0600
committerNunoSempere <nuno.sempere@protonmail.com>2023-06-17 00:29:27 -0600
commit98f6d5630f6be4f955e308a5c1a91749f8cf7300 (patch)
treef04a500810ec9190fc5cb095c46add839d4f06bf /plugins
parent1cf68bb1fe2ebabb470dc072f300fbf7d3f7d5fa (diff)
alerts v2, formatting
Diffstat (limited to 'plugins')
-rw-r--r--plugins/libre_redirect/libre_redirect.c4
-rw-r--r--plugins/libre_redirect/str_init.c1
-rw-r--r--plugins/shortcuts/shortcuts.c8
-rw-r--r--plugins/style/style.c2
-rw-r--r--plugins/style/style.h2
-rw-r--r--plugins/style/style.js102
6 files changed, 58 insertions, 61 deletions
diff --git a/plugins/libre_redirect/libre_redirect.c b/plugins/libre_redirect/libre_redirect.c
index 13831fd..8bafded 100644
--- a/plugins/libre_redirect/libre_redirect.c
+++ b/plugins/libre_redirect/libre_redirect.c
@@ -32,7 +32,7 @@ int libre_redirect(const char* uri, char* output)
char* annoying_sites[] = {
"https://www.reddit.com",
"https://www.youtube.com",
- "https://google.com"
+ "https://google.com"
"https://medium.com",
"https://translate.google.com",
"https://www.bloomberg.com",
@@ -43,7 +43,7 @@ int libre_redirect(const char* uri, char* output)
char* alternatives[] = {
"https://teddit.nunosempere.com",
"https://yt.artemislena.eu",
- "https://search.nunosempere.com"
+ "https://search.nunosempere.com"
"https://scribe.rip",
"https://translate.riverside.rocks/",
"https://archive.is/https://www.bloomberg.com",
diff --git a/plugins/libre_redirect/str_init.c b/plugins/libre_redirect/str_init.c
index edbe2ab..3fc548c 100644
--- a/plugins/libre_redirect/str_init.c
+++ b/plugins/libre_redirect/str_init.c
@@ -4,4 +4,3 @@ void str_init(char* str, int n)
str[i] = ' ';
str[n] = '\0';
} // could also use <https://manpages.ubuntu.com/manpages/impish/man3/strinit.3pub.html>
-
diff --git a/plugins/shortcuts/shortcuts.c b/plugins/shortcuts/shortcuts.c
index 1af4fda..7ee9e2e 100644
--- a/plugins/shortcuts/shortcuts.c
+++ b/plugins/shortcuts/shortcuts.c
@@ -2,8 +2,8 @@
#include <stdio.h>
#include <string.h>
-#include "../libre_redirect/str_replace_start.h"
#include "../libre_redirect/str_init.h"
+#include "../libre_redirect/str_replace_start.h"
#define SHORTCUT_N 41
@@ -33,8 +33,8 @@ int shortcut_expand(const char* uri, char* output)
char* shortcuts[] = {
"!fnf",
"!fnc",
- "!hn",
- "!hnb"
+ "!hn",
+ "!hnb"
};
char* expansions[] = {
@@ -45,7 +45,7 @@ int shortcut_expand(const char* uri, char* output)
};
// len = sizeof(shortcuts) / sizeof(shortcuts[0]);
- len = sizeof(shortcuts) / sizeof(char *);
+ len = sizeof(shortcuts) / sizeof(char*);
for (int i = 0; i < len; i++) {
int replace_check = str_replace_start(tmp_uri, shortcuts[i],
diff --git a/plugins/style/style.c b/plugins/style/style.c
index 34f7f35..7f0d3e4 100644
--- a/plugins/style/style.c
+++ b/plugins/style/style.c
@@ -1,7 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#define STYLE_N 3640 + 1
+#define STYLE_N 3858 + 1
void read_style_js(char* string)
{
diff --git a/plugins/style/style.h b/plugins/style/style.h
index 75dd3ee..3a2cdc9 100644
--- a/plugins/style/style.h
+++ b/plugins/style/style.h
@@ -1,7 +1,7 @@
#ifndef STYLE
#define STYLE
-#define STYLE_N 3640 + 1
+#define STYLE_N 3858 + 1
void read_style_js(char* string);
diff --git a/plugins/style/style.js b/plugins/style/style.js
index cc98fa9..4f917ad 100644
--- a/plugins/style/style.js
+++ b/plugins/style/style.js
@@ -73,63 +73,61 @@ if(styles != null){
// Replace default alert with new function
// whose style can be changed!
-window.alert = function(message) {
- // Check if the alert dialog already exists
- var alertDiv = document.getElementById('customAlert');
+window.alert = (message) => {
+ let alertDiv = document.getElementById('customAlert');
if (!alertDiv) {
- // Create the alert dialog
- alertDiv = document.createElement('div');
- alertDiv.id = 'customAlert';
- alertDiv.className = 'custom-alert hidden';
-
- var contentDiv = document.createElement('div');
- contentDiv.className = 'custom-alert-content';
-
- var alertMessage = document.createElement('p');
- alertMessage.id = 'alertMessage';
-
- var okButton = document.createElement('button');
- okButton.id = 'alertOkButton';
- okButton.textContent = 'OK';
- okButton.onclick = function() {
- alertDiv.classList.add('hidden');
+ const html = `
+ <div id="customAlert" class="custom-alert">
+ <div class="custom-alert-content">
+ <p id="alertMessage"></p>
+ <button id="alertOkButton">OK</button>
+ </div>
+ </div>
+ <style>
+ .custom-alert {
+ display: none;
+ position: fixed;
+ z-index: 999;
+ left: 0;
+ top: 0;
+ width: 100%;
+ height: 100%;
+ overflow: auto;
+ background-color: rgba(0,0,0,0.4);
+ }
+ .custom-alert-content {
+ background-color: #fefefe;
+ margin: 15% auto;
+ padding: 20px;
+ border: 1px solid #888;
+ width: 80%;
+ font-family: monospace; /* Use monospace font */
+ }
+ .visible {
+ display: block;
+ }
+ </style>
+ `;
+ document.body.insertAdjacentHTML('beforeend', html);
+ alertDiv = document.getElementById('customAlert');
+ document.getElementById('alertOkButton').onclick = () => {
+ alertDiv.classList.remove('visible');
+ document.removeEventListener('keydown', dismissAlert);
};
-
- contentDiv.appendChild(alertMessage);
- contentDiv.appendChild(okButton);
- alertDiv.appendChild(contentDiv);
- document.body.appendChild(alertDiv);
-
- // Inject CSS
- var style = document.createElement('style');
- style.innerHTML = `
- .custom-alert {
- position: fixed;
- z-index: 999;
- left: 0;
- top: 0;
- width: 100%;
- height: 100%;
- overflow: auto;
- background-color: rgba(0,0,0,0.4);
- }
- .custom-alert-content {
- background-color: #fefefe;
- margin: 15% auto;
- padding: 20px;
- border: 1px solid #888;
- width: 80%;
+ }
+
+ const dismissAlert = (event) => {
+ if (event.key === 'Enter' /*&& event.ctrlKey*/ && alertDiv.classList.contains('visible')) {
+ alertDiv.classList.remove('visible');
+ document.removeEventListener('keydown', dismissAlert);
}
- .hidden {
- display: none;
- }`;
- document.head.appendChild(style);
}
-
- // Show the alert dialog
+
+ document.addEventListener('keydown', dismissAlert);
document.getElementById('alertMessage').textContent = message;
- alertDiv.classList.remove('hidden');
-}
+ alertDiv.classList.add('visible');
+}
+
// alert("Hello world!")
document.body.style.visibility = "visible"