Skip to content

DuckDuckGo now makes POST requests for search#71

Open
spj2401Dev wants to merge 3 commits intoprem-k-r:mainfrom
spj2401Dev:main
Open

DuckDuckGo now makes POST requests for search#71
spj2401Dev wants to merge 3 commits intoprem-k-r:mainfrom
spj2401Dev:main

Conversation

@spj2401Dev
Copy link

@spj2401Dev spj2401Dev commented Oct 13, 2025

📌 Description

Using this the Search button will use a POST request to search for DuckDuckGo.
The issue like described cannot be implemented as is to my knowlage as Google, Bing, etc... does not support POST requests

🎨 Visual Changes (Screenshots / Videos)

No visual changes made

🔗 Related Issues

Related to #60
This will probably need some discussing

✅ Checklist

  • I have read and followed the Contributing Guidelines.
  • My code follows the project's coding style and conventions.
  • I have tested my changes thoroughly to ensure expected behavior.
  • I have verified compatibility across Chrome and Firefox (additional browsers if applicable).
  • I have attached relevant visual evidence (screenshots/videos) if applicable.
  • [X (at least I hope I did it correctly)] I have updated the CHANGELOG.md under the appropriate categories with all my changes in this PR.

Summary by CodeRabbit

  • Changed

    • DuckDuckGo search queries now submitted via POST requests instead of GET requests.
    • Other search engines continue to operate as before.
  • Documentation

    • Updated changelog to reflect DuckDuckGo search method modification.

✏️ Tip: You can customize this high-level summary in your review settings.

Copilot AI review requested due to automatic review settings October 13, 2025 08:25
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR modifies the search functionality to use POST requests specifically for DuckDuckGo searches instead of GET requests. This change addresses issue #60 by implementing a search method that DuckDuckGo supports, while maintaining GET requests for other search engines that don't support POST.

  • Added a dedicated configuration object for DuckDuckGo with URL and parameter mapping
  • Implemented a new submitPostSearch function that creates and submits a hidden form for POST requests
  • Modified the search logic to route DuckDuckGo searches through the POST method while keeping other engines unchanged

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
scripts/search.js Added DuckDuckGo POST request configuration and implementation with form submission logic
CHANGELOG.md Updated to document the change from GET to POST requests for DuckDuckGo searches

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@prem-k-r
Copy link
Owner

@coderabbitai review

@coderabbitai

This comment was marked as off-topic.

@coderabbitai
Copy link

coderabbitai bot commented Nov 26, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

This PR adds POST request support for DuckDuckGo searches, replacing the previous GET-based approach. A new configuration object and submitPostSearch helper function enable POST form submission. The performSearch function is updated to route DuckDuckGo searches through the new POST flow while maintaining GET for other engines.

Changes

Cohort / File(s) Summary
Documentation Update
CHANGELOG.md
Removed formatting whitespace and added entry documenting the shift from GET to POST requests for DuckDuckGo searches
Search Engine Integration
scripts/search.js
Added DuckDuckGo POST configuration object, introduced submitPostSearch helper function to build and submit hidden POST forms, and integrated conditional branching in performSearch to route engine2 (DuckDuckGo) through POST submission while preserving existing GET flow for other engines

Sequence Diagram

sequenceDiagram
    participant User
    participant performSearch
    participant submitPostSearch
    participant Browser

    User->>performSearch: Initiate search with engine2 (DuckDuckGo)
    alt DuckDuckGo (engine2)
        performSearch->>submitPostSearch: Call with search term
        submitPostSearch->>Browser: Create hidden form
        Browser->>Browser: Set form action, method=POST
        Browser->>Browser: Append hidden input with search term
        Browser->>Browser: Submit form
    else Other Engines (engine0, engine1)
        performSearch->>Browser: Navigate via GET request
    end
    Browser->>User: Execute search
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Helper function logic: Verify submitPostSearch correctly constructs and submits the hidden form with proper parameter names and values
  • Engine routing: Confirm the conditional check for engine2 is placed correctly and doesn't interfere with existing GET-based fallback logic

Possibly related issues

Poem

🐰 A curious hare hops through the post,
DuckDuckGo receives our request with care,
No longer GET, but POST we chose,
Hidden forms whisper through the air,
Search results fly beyond compare! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: DuckDuckGo now uses POST requests for search instead of GET requests.
Description check ✅ Passed The description includes all required sections: Description, Visual Changes, Related Issues, and a completed Checklist. The author provides context about POST request implementation and acknowledges limitations with other search engines.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
scripts/search.js (1)

238-255: Consider adding error handling for robustness.

While the current implementation works correctly for the controlled use case, adding basic error handling and parameter validation would improve robustness.

Consider this enhancement:

 function submitPostSearch(config, searchTerm) {
+    if (!config?.url || !config?.param) {
+        console.error("Invalid POST search configuration");
+        return;
+    }
+    
     const form = document.createElement("form");
     form.method = "POST";
     form.action = config.url;
     form.style.display = "none";
 
     const searchInput = document.createElement("input");
     searchInput.type = "hidden";
     searchInput.name = config.param;
     searchInput.value = searchTerm;
     form.appendChild(searchInput);
 
     document.body.appendChild(form);
-    form.submit();
-    setTimeout(() => {
-        document.body.removeChild(form);
-    }, 0);
+    
+    try {
+        form.submit();
+        setTimeout(() => {
+            document.body.removeChild(form);
+        }, 0);
+    } catch (error) {
+        console.error("Form submission failed:", error);
+        document.body.removeChild(form);
+    }
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4a418d5 and c549724.

📒 Files selected for processing (2)
  • CHANGELOG.md (1 hunks)
  • scripts/search.js (2 hunks)
🔇 Additional comments (4)
CHANGELOG.md (1)

67-67: LGTM!

The changelog entry accurately describes the change and is properly formatted.

scripts/search.js (3)

25-29: LGTM!

The configuration object provides a clean, maintainable approach for POST request handling. The structure allows for easy extension if other search engines support POST in the future.


227-229: LGTM!

The routing logic correctly directs DuckDuckGo searches to the POST handler while maintaining existing GET behavior for other engines.


238-255: Implementation is correct.

The hidden form submission technique is a standard approach for POST requests, and the setTimeout(0) ensures the form is removed after submission completes.

@prem-k-r prem-k-r added the enhancement New feature or request label Jan 25, 2026
Copy link
Owner

@prem-k-r prem-k-r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @spj2401Dev, apologies for joining the PR late.
Could you help me understand what advantages this change provides? From my testing, even with DuckDuckGo set to POST, the search query still appears in the browser history.

@spj2401Dev
Copy link
Author

It's not as big of a change. I think this gets mostly relevant if you are behind corporate proxies or you care for example about refere leaks. Otherwise this is not as interesting.
Maybe one person in this entire world could utilize the longer search request you can send via this, but I myself have never run into any kind of those limitau

@prem-k-r prem-k-r added the on-hold Blocked by another PR or pending feature. Will resume once dependency is resolved. label Jan 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request on-hold Blocked by another PR or pending feature. Will resume once dependency is resolved.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants