diff --git a/config.php b/config.php
index 19e84a0..df5d744 100755
--- a/config.php
+++ b/config.php
@@ -8,6 +8,14 @@
// Results will be in this language
$config_google_language = "en";
+ /*
+ youtube.com results will be replaced with the given invidious instance
+ Get online invidious instances from here: https://docs.invidious.io/Invidious-Instances.md
+
+ Set as null if you don't want to replace YouTube results
+ */
+ $config_replace_yt_with_invidious = "yewtu.be";
+
/*
To send requests trough a proxy uncomment CURLOPT_PROXY and CURLOPT_PROXYTYPE:
diff --git a/google.php b/google.php
index 0f8153f..aa4cd90 100644
--- a/google.php
+++ b/google.php
@@ -1,15 +1,18 @@
\ No newline at end of file
diff --git a/index.xhtml b/index.xhtml
index e1b7034..bdc04e8 100644
--- a/index.xhtml
+++ b/index.xhtml
@@ -14,6 +14,7 @@
LibreX
+
Search with LibreX
diff --git a/results/text.php b/results/text.php
index afd1896..dd0e019 100644
--- a/results/text.php
+++ b/results/text.php
@@ -3,6 +3,7 @@
function text_results($xpath)
{
require_once "tools.php";
+ require "config.php";
$results = array();
@@ -17,14 +18,20 @@
if (end($results)["url"] == $url->textContent)
continue;
+ $url = $url->textContent;
+ if ($config_replace_yt_with_invidious != null)
+ {
+ $url = str_replace("youtube.com", $config_replace_yt_with_invidious, $url);
+ }
+
$title = $xpath->evaluate(".//h3", $result)[0];
$description = $xpath->evaluate(".//div[contains(@class, 'VwiC3b')]", $result)[0];
array_push($results,
array (
"title" => $title->textContent,
- "url" => $url->textContent,
- "base_url" => get_base_url($url->textContent),
+ "url" => $url,
+ "base_url" => get_base_url($url),
"description" => $description == null ? "No description was provided for this site." : $description->textContent
)
);
diff --git a/results/video.php b/results/video.php
new file mode 100644
index 0000000..231bb5a
--- /dev/null
+++ b/results/video.php
@@ -0,0 +1,39 @@
+query("//div[@id='search']//div[contains(@class, 'g')]") as $result)
+ {
+ $url = $xpath->evaluate(".//a/@href", $result)[0];
+
+ if ($url == null)
+ continue;
+
+ if (!empty($results)) // filter duplicate results
+ if (end($results)["url"] == $url->textContent)
+ continue;
+
+ $url = $url->textContent;
+ if ($config_replace_yt_with_invidious != null)
+ {
+ $url = str_replace("youtube.com", $config_replace_yt_with_invidious, $url);
+ }
+
+ $title = $xpath->evaluate(".//h3", $result)[0];
+
+ array_push($results,
+ array (
+ "title" => $title->textContent,
+ "url" => $url,
+ "base_url" => get_base_url($url)
+ )
+ );
+ }
+
+ return $results;
+ }
+?>
\ No newline at end of file
diff --git a/search.php b/search.php
index ea39dc0..5e89fe0 100644
--- a/search.php
+++ b/search.php
@@ -34,14 +34,19 @@
?>
-
Text results
-
Image results
+
Text
+
Images
+
Videos
";
@@ -53,6 +58,7 @@
require_once "google.php";
require_once "tools.php";
+ require_once "config.php";
$page = (int) htmlspecialchars($_REQUEST["p"]);
$type = (int) $_REQUEST["type"];
@@ -63,6 +69,7 @@
echo "
Fetched the results in $end_time seconds
";
+
if ($type == 0) // text search
{
check_for_special_search($query);
@@ -118,6 +125,33 @@
echo "";
}
+ echo "
";
+ }
+ else if ($type == 2) // video search
+ {
+ echo "";
+
+ if ($config_replace_yt_with_invidious != null)
+ {
+ echo "
";
+ echo "YouTube results got replaced with a privacy friendly Invidious instance.";
+ echo "
";
+ }
+
+ foreach($results as $result)
+ {
+ $title = $result["title"];
+ $url = $result["url"];
+ $base_url = $result["base_url"];
+
+ echo "
";
+ }
+
echo "
";
}
?>
diff --git a/static/image_result.png b/static/image_result.png
new file mode 100644
index 0000000..4342eed
Binary files /dev/null and b/static/image_result.png differ
diff --git a/static/styles.css b/static/styles.css
index 927aab4..6b61a54 100644
--- a/static/styles.css
+++ b/static/styles.css
@@ -5,7 +5,7 @@ html {
font-family: Arial, Helvetica, sans-serif;
font-size: 18px;
- overflow-x: hidden;
+ overflow-x: hidden;
}
hr {
@@ -198,6 +198,10 @@ img {
text-decoration: underline;
}
+ .results-wrapper {
+ height: 105vh;
+ }
+
/* .result-container END */
@@ -209,8 +213,6 @@ img {
margin-right:8%;
margin-bottom:30px;
-
- max-height: 100vh;
}
/* .image-result-container END */
@@ -262,7 +264,8 @@ img {
border:none;
- text-decoration: underline;
+ margin-right: 20px;
+
font-size: 18px;
}
@@ -270,6 +273,13 @@ img {
cursor: pointer;
}
+ .result-change #change-image {
+ width: 25px;
+ height: 25px;
+ vertical-align: middle;
+ border:none;
+ }
+
/* .result-change END */
@@ -302,6 +312,27 @@ img {
+.result-container ,
+#time ,
+#special-result {
+ margin-left: 10%;
+}
+
+#special-result {
+ padding: 10px;
+ border: 1px solid #bdc1c6;
+ width: 500px;
+}
+
+#logo {
+ vertical-align: middle;
+ width: 80px;
+ height: 80px;
+ border: none;
+}
+
+
+
/* @media START */
@media only screen and (min-width:900px) {
@@ -381,7 +412,7 @@ img {
margin-left: auto;
margin-right: auto;
text-align: center;
- margin-top: -10px;
+ margin-top: 5px;
}
img {
@@ -392,28 +423,11 @@ img {
margin-bottom: 30px;
width: 50%;
+ }
+
+ #special-result {
+ width: 80%;
}
}
-/* @media END */
-
-
-
-.result-container ,
-#time ,
-#special-result {
- margin-left: 10%;
-}
-
-#special-result {
- padding: 10px;
- border: 1px solid #bdc1c6;
- width: 500px;
-}
-
-#logo {
- vertical-align: middle;
- width: 80px;
- height: 80px;
- border: none;
-}
\ No newline at end of file
+/* @media END */
\ No newline at end of file
diff --git a/static/text_result.png b/static/text_result.png
new file mode 100644
index 0000000..4974d01
Binary files /dev/null and b/static/text_result.png differ
diff --git a/static/video_result.png b/static/video_result.png
new file mode 100644
index 0000000..7ef397a
Binary files /dev/null and b/static/video_result.png differ