From 4baa484b84c5184286cac2743575251454a5ee2b Mon Sep 17 00:00:00 2001 From: Agando Date: Mon, 25 May 2026 18:02:02 +0200 Subject: auto: 2026-05-25_18:02 changes --- modules/core/module-duckduckgo.js | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 modules/core/module-duckduckgo.js (limited to 'modules/core/module-duckduckgo.js') diff --git a/modules/core/module-duckduckgo.js b/modules/core/module-duckduckgo.js new file mode 100644 index 0000000..c443b72 --- /dev/null +++ b/modules/core/module-duckduckgo.js @@ -0,0 +1,38 @@ +// Extracted from newOS4 index.html — DuckDuckGoModule + class DuckDuckGoModule { + constructor() { + this.commands = {}; + this.terminal = null; + } + getHelpInfo() { + return { + 'ddg': 'ddg — Search DuckDuckGo (opens query in new tab)', + 'duck': 'duck — Alias for ddg', + }; + } + registerCommands() { + this.commands['ddg'] = (args) => this.search(args); + this.commands['duck'] = (args) => this.search(args); + } + async search(args) { + if (!args[0]) { + this.terminal.print("Usage: ddg ", "warning"); + this.terminal.print("Example: ddg javascript tutorials", "info"); + this.terminal.print("Note: Due to CORS, results may be limited. Try 'search' command for better results.", "warning"); + return; + } + const query = args.join(' '); + this.terminal.print(`šŸ¦† DuckDuckGo Search: ${query}`, "info"); + + // DuckDuckGo doesn't have a public API, so we provide alternatives + this.terminal.print("āš ļø DuckDuckGo doesn't provide a public API for direct access.", "warning"); + this.terminal.print("Opening search in new tab...", "info"); + + // Open in new tab as fallback + const ddgUrl = `https://duckduckgo.com/?q=${encodeURIComponent(query)}`; + window.open(ddgUrl, '_blank'); + + this.terminal.print(`\nšŸ’” Alternative: Use 'search ' for SearXNG (privacy-focused)`, "info"); + this.terminal.print(`šŸ”— Direct link: ${ddgUrl}`, "info"); + } + } -- cgit v1.2.3