diff options
| author | Agando <roduccomm@gmail.com> | 2026-05-25 18:02:02 +0200 |
|---|---|---|
| committer | Agando <roduccomm@gmail.com> | 2026-05-25 18:02:02 +0200 |
| commit | 4baa484b84c5184286cac2743575251454a5ee2b (patch) | |
| tree | cb9002f93644f363d0f35831dc97e6492bbb0ed6 /modules/core/module-duckduckgo.js | |
auto: 2026-05-25_18:02 changes
Diffstat (limited to 'modules/core/module-duckduckgo.js')
| -rw-r--r-- | modules/core/module-duckduckgo.js | 38 |
1 files changed, 38 insertions, 0 deletions
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 <query> — Search DuckDuckGo (opens query in new tab)', + 'duck': 'duck <query> — 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 <search-query>", "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 <query>' for SearXNG (privacy-focused)`, "info"); + this.terminal.print(`🔗 Direct link: ${ddgUrl}`, "info"); + } + } |