diff options
-rw-r--r-- | Base/res/html/misc/new-tab.html | 97 | ||||
-rw-r--r-- | Userland/Applications/Browser/main.cpp | 2 | ||||
-rw-r--r-- | Userland/Applications/BrowserSettings/BrowserSettingsWidget.cpp | 2 |
3 files changed, 99 insertions, 2 deletions
diff --git a/Base/res/html/misc/new-tab.html b/Base/res/html/misc/new-tab.html new file mode 100644 index 0000000000..44c183cf10 --- /dev/null +++ b/Base/res/html/misc/new-tab.html @@ -0,0 +1,97 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <title>New Tab</title> + <style> + body { + display: flex; + align-items: center; + justify-content: center; + } + + main { + text-align: center; + display: block; + width: 100%; + max-width: 400px; + } + + img { + image-rendering: pixelated; + } + + input[type=search] { + width: 100%; + padding: 5px; + } + + #search-buttons { + display: flex; + justify-content: space-between; + align-items: center; + } + + button:hover { + cursor: pointer; + } + </style> +</head> +<body> + <main> + <br> + <img src="/res/icons/32x32/app-browser.png" width="64" height="64"><br><br> + <form> + <input type="search" name="q" id="user_query"><br><br> + <div id="search-buttons"> + <button type="button" onclick="search('bing')">Bing</button> + <button type="button" onclick="search('duckduckgo')">DuckDuckGo</button> + <button type="button" onclick="search('frogfind')">FrogFind</button> + <button type="button" onclick="search('github')">GitHub</button> + <button type="button" onclick="search('google')">Google</button> + <button type="button" onclick="search('yandex')">Yandex</button> + </div> + </form> + <br><br> + <p>Your user agent is: <b><span id="ua"></span></b></p> + <p>This page loaded in <b><span id="loadtime"></span></b> ms</p> + </main> + + <script> + document.addEventListener("DOMContentLoaded", function () { + document.getElementById("ua").innerHTML = navigator.userAgent; + document.getElementById("loadtime").innerHTML = performance.now(); + }); + + function search(searchEngine) { + let query = document.getElementById("user_query").value; + + if (!query) { + return; + } + + let url; + if (searchEngine == "bing") { + url = new URL("https://www.bing.com/search"); + url.searchParams.set("q", query); + } else if (searchEngine == "duckduckgo") { + url = new URL("https://duckduckgo.com"); + url.searchParams.set("q", query); + } else if (searchEngine == "frogfind") { + url = new URL("https://frogfind.com"); + url.searchParams.set("q", query); + } else if (searchEngine == "github") { + url = new URL("https://github.com/search"); + url.searchParams.set("q", query); + } else if (searchEngine == "google") { + url = new URL("https://google.com/search"); + url.searchParams.set("q", query); + } else if (searchEngine == "yandex") { + url = new URL("https://yandex.com/search"); + url.searchParams.set("text", query); + } + window.location.href = url.toString(); + } + </script> +</body> +</html> diff --git a/Userland/Applications/Browser/main.cpp b/Userland/Applications/Browser/main.cpp index afcad266db..cd437eb5ab 100644 --- a/Userland/Applications/Browser/main.cpp +++ b/Userland/Applications/Browser/main.cpp @@ -95,7 +95,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) auto app_icon = GUI::Icon::default_icon("app-browser"); Browser::g_home_url = Config::read_string("Browser", "Preferences", "Home", "file:///res/html/misc/welcome.html"); - Browser::g_new_tab_url = Config::read_string("Browser", "Preferences", "NewTab", "file:///res/html/misc/welcome.html"); + Browser::g_new_tab_url = Config::read_string("Browser", "Preferences", "NewTab", "file:///res/html/misc/new-tab.html"); Browser::g_search_engine = Config::read_string("Browser", "Preferences", "SearchEngine", {}); Browser::g_content_filters_enabled = Config::read_bool("Browser", "Preferences", "EnableContentFilters", true); diff --git a/Userland/Applications/BrowserSettings/BrowserSettingsWidget.cpp b/Userland/Applications/BrowserSettings/BrowserSettingsWidget.cpp index fdffade119..fc739bb803 100644 --- a/Userland/Applications/BrowserSettings/BrowserSettingsWidget.cpp +++ b/Userland/Applications/BrowserSettings/BrowserSettingsWidget.cpp @@ -13,7 +13,7 @@ #include <LibGUI/Model.h> static String default_homepage_url = "file:///res/html/misc/welcome.html"; -static String default_new_tab_url = "file:///res/html/misc/welcome.html"; +static String default_new_tab_url = "file:///res/html/misc/new-tab.html"; static String default_search_engine = ""; static String default_color_scheme = "auto"; static bool default_show_bookmarks_bar = true; |