// 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");
}
}