From ca5fdd0746f1b62533bd277f5a39d7cc78a38a0c Mon Sep 17 00:00:00 2001 From: "hnh.mtf" Date: Thu, 10 Mar 2022 11:18:07 +0100 Subject: [PATCH] improved settings --- README.md | 2 +- config.php | 17 +++-- engines/google/text.php | 3 +- engines/google/video.php | 3 +- search.php | 1 - settings.php | 131 ++++++++++++++++++++++++--------------- static/header.php | 2 +- static/styles.css | 16 +++-- 8 files changed, 106 insertions(+), 69 deletions(-) diff --git a/README.md b/README.md index c37ce94..51ea957 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Your request will be **rejected** if your instance: + has been heavily modified # Features -+ Ad / JavaScript / cookie free ++ Ad & JavaScript free + Torrent results from popular torrent sites + Special queries (e.g.: 1 btc to usd , what does xyz mean etc.) + Tracking snippets from URLs are removed diff --git a/config.php b/config.php index 5bebba7..e8b5d15 100755 --- a/config.php +++ b/config.php @@ -12,21 +12,20 @@ $config_bittorent_trackers = "&tr=http%3A%2F%2Fnyaa.tracker.wf%3A7777%2Fannounce&tr=udp%3A%2F%2Fopen.stealth.si%3A80%2Fannounce&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2Fexodus.desync.com%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.torrent.eu.org%3A451%2Fannounce"; /* - These are privacy friendly front-ends for popular sites + These are privacy friendly front-ends for popular sites, these settings can be managed by end users as well for their session via cookies. - Online invidious instances: https://docs.invidious.io/Invidious-Instances.md + Online invidious instances: https://docs.invidious.io/Invidious-Instances/ Online bibliogram instances: https://git.sr.ht/~cadence/bibliogram-docs/tree/master/docs/Instances.md Online nitter instances: https://github.com/zedeus/nitter/wiki/Instances Online libreddit instances: https://github.com/spikecodes/libreddit - If you don't want to replace YouTube for an example but you want to replace everything else: - $config_replace_youtube_with_invidious = isset($_REQUEST["invidious"]) ? $_REQUEST["invidious"] : null; + If you don't want to replace YouTube for an example: + $config_replace_youtube_with_invidious = isset($_COOKIE["invidious"]) ? $_COOKIE["invidious"] : null; */ - $config_disable_privacy_friendly_frontends = false; // setting this to true will disable all of them - $config_replace_youtube_with_invidious = isset($_REQUEST["invidious"]) ? $_REQUEST["invidious"] : "https://yewtu.be"; - $config_replace_instagram_with_bibliogram = isset($_REQUEST["bibliogram"]) ? $_REQUEST["bibliogram"] : "https://bibliogram.pussthecat.org"; - $config_replace_twitter_with_nitter = isset($_REQUEST["nitter"]) ? $_REQUEST["nitter"] : "https://nitter.namazso.eu"; - $config_replace_reddit_with_libreddit = isset($_REQUEST["libreddit"]) ? $_REQUEST["libreddit"] : "https://libreddit.dothq.co"; + $config_replace_youtube_with_invidious = isset($_COOKIE["invidious"]) ? $_COOKIE["invidious"] : "https://yewtu.be"; + $config_replace_instagram_with_bibliogram = isset($_COOKIE["bibliogram"]) ? $_COOKIE["bibliogram"] : "https://bibliogram.pussthecat.org"; + $config_replace_twitter_with_nitter = isset($_COOKIE["nitter"]) ? $_COOKIE["nitter"] : "https://nitter.namazso.eu"; + $config_replace_reddit_with_libreddit = isset($_COOKIE["libreddit"]) ? $_COOKIE["libreddit"] : "https://libreddit.dothq.co"; /* To send requests trough a proxy uncomment CURLOPT_PROXY and CURLOPT_PROXYTYPE: diff --git a/engines/google/text.php b/engines/google/text.php index 1513ea9..88ea500 100644 --- a/engines/google/text.php +++ b/engines/google/text.php @@ -108,8 +108,7 @@ $url = $url->textContent; - if (!$config_disable_privacy_friendly_frontends) - $url = check_for_privacy_friendly_alternative($url); + $url = check_for_privacy_friendly_alternative($url); $title = $xpath->evaluate(".//h3", $result)[0]; $description = $xpath->evaluate(".//div[contains(@class, 'VwiC3b')]", $result)[0]; diff --git a/engines/google/video.php b/engines/google/video.php index 3866b2a..cc6e351 100644 --- a/engines/google/video.php +++ b/engines/google/video.php @@ -22,8 +22,7 @@ continue; $url = $url->textContent; - if (!$config_disable_privacy_friendly_frontends) - $url = check_for_privacy_friendly_alternative($url); + $url = check_for_privacy_friendly_alternative($url); $title = $xpath->evaluate(".//h3", $result)[0]; diff --git a/search.php b/search.php index c2fc2bc..c394ef5 100644 --- a/search.php +++ b/search.php @@ -1,4 +1,3 @@ - <?php echo $_REQUEST["q"]; ?> - LibreX diff --git a/settings.php b/settings.php index 80b11e6..c5bf35a 100644 --- a/settings.php +++ b/settings.php @@ -1,66 +1,99 @@ - + LibreX - Settings - -

Since LibreX doesn't use any cookies for better user privacy, settings are passed trough query parameters.

+ +
+

Settings

+
+ + - - - - - - -

-

Privacy friendly frontends

-
- - + if (isset($_COOKIE["theme"])) + { + $cookie_theme = $_COOKIE["theme"]; + $themes = str_replace($cookie_theme . "\"", $cookie_theme . "\" selected", $themes); + } + echo $themes; + ?> +

- - +

Privacy friendly frontends

+

Replace popular sites with privacy friendly frontends

+
+ Invidious + + > -

- - +

+ Bibliogram + + > -

- - -
-
- - +

+ Nitter + + > + +

+ Libreddit + + > +
+
+ + + -

"; - echo $url; - echo "

"; - } - ?> + header("Location: /settings.php"); + die(); + } + else if (isset($_REQUEST["reset"])) + { + if (isset($_SERVER['HTTP_COOKIE'])) { + $cookies = explode(';', $_SERVER['HTTP_COOKIE']); + foreach($cookies as $cookie) { + $parts = explode('=', $cookie); + $name = trim($parts[0]); + setcookie($name, '', time()-1000); + setcookie($name, '', time()-1000, '/'); + } + + header("Location: /settings.php"); + die(); + } + } + ?> +
\ No newline at end of file diff --git a/static/header.php b/static/header.php index e6d64fb..52ef1b9 100644 --- a/static/header.php +++ b/static/header.php @@ -9,4 +9,4 @@ - "/> \ No newline at end of file + "/> \ No newline at end of file diff --git a/static/styles.css b/static/styles.css index 26372e1..aa8114e 100644 --- a/static/styles.css +++ b/static/styles.css @@ -88,7 +88,8 @@ a:hover, .text-result-wrapper h2:hover { margin-left: 150px; } -.search-button-wrapper button:hover { +.search-button-wrapper button:hover, +.settings-container button:hover { border: 1px solid #5f6368; cursor: pointer; } @@ -107,13 +108,20 @@ a:hover, .text-result-wrapper h2:hover { } .settings-container { - margin-top: 10%; text-align: center; - margin-left: 25%; - margin-right: 25%; word-wrap: break-word; } +.settings-container button { + margin-right:10px; + margin-left:10px; +} + +.settings-container a { + color:inherit; + text-decoration: underline; +} + .instances-container input { color: inherit; background-color: inherit;