Add incognito mode support #33

Open
opened 2024-08-20 16:20:14 +00:00 by Bagget · 1 comment

As all settings are stored in cookies, loading them back requires firstly opening the URL "Bookmark me!" (copied from the settings page).

..which means that if you set 4get as your default search engine, trying to search something in incognito will keep giving you trash from DuckDuckGo (basically Bing) until you click your bookmark with the settings.

SearXNG provides a solution to this in the form of a URL: https://<your searxng instance>/?preferences=<a long string with your encoded prefs>&q=%s. A similar approach is possible here if we edit a few lines in settings.php:

// ...
/*
	Set cookies
*/
if($_POST){

	$loop = &$_POST;
}elseif(count($_GET) !== 0){

	// redirect user to front page
	$loop = &$_GET;
	header("Location: /");

}elseif(isset($_GET["s"])){

	// search using the passed query
	$loop = &$_GET;
	header("Location: /web?s=" . $_GET["s"]);

}else{
	// refresh cookie dates
	$loop = &$_COOKIE;
}
// ...

After this change, <URL from "Bookmark me!">&s=%s should (hopefully) work

As all settings are stored in cookies, loading them back requires firstly opening the URL "Bookmark me!" (copied from the settings page). ..which means that if you set 4get as your default search engine, trying to search something in incognito will keep giving you trash from DuckDuckGo (basically Bing) until you click your bookmark with the settings. SearXNG provides a solution to this in the form of a URL: `https://<your searxng instance>/?preferences=<a long string with your encoded prefs>&q=%s`. A similar approach is possible here if we edit a few lines in `settings.php`: ```php // ... /* Set cookies */ if($_POST){ $loop = &$_POST; }elseif(count($_GET) !== 0){ // redirect user to front page $loop = &$_GET; header("Location: /"); }elseif(isset($_GET["s"])){ // search using the passed query $loop = &$_GET; header("Location: /web?s=" . $_GET["s"]); }else{ // refresh cookie dates $loop = &$_COOKIE; } // ... ``` After this change, `<URL from "Bookmark me!">&s=%s` should (hopefully) work
Owner

I've thought about this, but this will not allow you to set custom search filters through this endpoint because of name collisions... I will keep this in mind during the frontend rewrite that's coming up and make something that works for you

I've thought about this, but this will not allow you to set custom search filters through this endpoint because of name collisions... I will keep this in mind during the frontend rewrite that's coming up and make something that works for you
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: lolcat/4get#33
No description provided.