About

Duck.ai is one of the few online places to chat with AI privately. Self-hosting your own AI model is a better option, but not everybody has the hardware for it. DuckDuckGo has made deals with the model providers to keep your chats private, so it’s an easy option to recommend.

If you’re like me, you probably clear your cookies a lot (or always browse in incognito). This means that any time you visit Duck.ai, you have to set all your settings again. One solution is to set Duck.ai as an exception to your browser data deletion, but that makes me uneasy. After getting fed up setting my preferred settings each time, I wanted to see if I could automate the process.

The Bookmarklet

Bookmarklets are essentially bookmarks in your bookmarks bar that, when clicked, run your own JavaScript code on whichever page you’re visiting. This was a neat trick that some of my classmates used to edit pages when the Inspect Element was disabled on school computers.

I wrote a short bookmarklet that will automatically set my preferred settings in Duck.ai:

javascript:{
	const settings = {
		'aiChatPromptSuggestions': '{"hideSuggestions":true}',
		'aichatPromoDismissal': '{"promosDismissed":"9999-99-99"}',
		'duckaiCanUseApproxLocation': 'false',
		'duckaiSidebarCollapsed': 'true',
		'duckduckgo_settings': '{"description":"Each key is a setting documented in https://duckduckgo.com/duckduckgo-help-pages/settings/params/","kdcm":"6","kdcs":"0"}',
		'isRecentChatsOn': '"0"',
		'preferredDuckaiModel': '"6"',
	};
	
	let keys = Object.keys(settings);
	keys.forEach(key => {
		const value = settings[key];
		localStorage.setItem(key, value);
	});
	
	location.reload();
}

How To Use

(Steps may vary between browsers)

  1. Copy-paste the bookmarklet code above (including the part that says javascript:)
  2. Right click on the bookmarks bar in your browser
  3. Select “Add page…”
  4. In the field that says “URL”, paste the code you copied
  5. Name the bookmarklet whatever you want, for example: Debloat Duck.ai
  6. Click “Save”
  7. Visit Duck.ai (which redirects to https://duckduckgo.com/?q=DuckDuckGo+AI+Chat&ia=chat&duckai=1) You must visit this page before running the bookmarklet, because bookmarklets can only run code on the page you’re currently visiting.
  8. Click on the bookmarklet you just created. This will run the code.

You should now have a distraction free, private chat.

Explanation

Duck.ai stores its settings in the browser’s “local storage”. If you open the Inspect Element (either by right clicking on the page and clicking “Inspect” or by pressing F12) and navigate to Application > Local Storage > https://duckduckgo.com/ you will see a list of settings and their corresponding values.

By default, these settings are a tad too distracting for my taste. The bookmarklet I made does the following:

  1. Hides prompt suggestions
  2. Dismisses the promo by setting the shown date to something impossible in the future
  3. Disables using approximate location for responses
  4. Collapses the sidebar
  5. duckduckgo_settings doesn’t actually do much, and the values there are, in fact, not documented on this page
  6. Disables chat history
  7. Sets the preferred model to Mistral Small 3, which is open source and has low moderation.

You can set your preferred settings before running the bookmarklet and edit the bookmarklet code according to your own settings.

The code then iterates through these settings, and sets each one. Then, finally, reloads the page to apply the settings.

Updates

This project is far too small to make an entire repository for it, so I will try to just update this post with any new code. For example, duckaiCanUseApproxLocation is a new setting that was added in the last few days.

I hope everyone enjoys this as much as I did!

Here is a before and after:

  • BroBot9000@lemmy.world
    link
    fedilink
    English
    arrow-up
    8
    arrow-down
    1
    ·
    18 hours ago

    I absolutely hate having to disable the Ai every time I search because I don’t want to save their cookies or cache.

    Anyway thats this could be modified to disable their Ai permanently for someone that only browses in incognito mode?

    They absolutely need to make it opt in and disabled by default.

    • The 8232 Project@lemmy.mlOP
      link
      fedilink
      arrow-up
      7
      ·
      17 hours ago

      You can add &kbe=0 to the end of the URL when you search to disable it. If you know how to add custom search engines this is the easiest way.

      Otherwise, you can add "kbe":"0" as a value inside the duckduckgo_settings parameter in the bookmarklet, like this:

      		'duckduckgo_settings': '{"description":"Each key is a setting documented in https://duckduckgo.com/duckduckgo-help-pages/settings/params/","kdcm":"6","kdcs":"0","kbe":"0"}',
      

      Cheers!

    • rhythmisaprancer@piefed.social
      link
      fedilink
      English
      arrow-up
      4
      ·
      16 hours ago

      I used the block element feature of Ublock, but I don’t know if that works in incognito or if it blocks their cookies. I also grew tired of having to disable it but didn’t consider the ramifications of making it invisible to me 🤔