Skip to content

Commit

Permalink
Update console.html
Browse files Browse the repository at this point in the history
  • Loading branch information
gnh1201 committed Nov 7, 2024
1 parent 564d3db commit 1c77b64
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions console.html
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,41 @@ <h1>Caterpillar Proxy Console</h1>
show_embed(this, "https://www.youtube.com/embed/" + video_id);
break;
}
},
search: function(...args) {
var term = this;
var q = encodeURIComponent(args.join(' '));
var url = "https://serp.catswords.net/api.php?q=" + q;

$.get(url, function(data) {
if ("error" in data) {
term.echo(data.error.message);
term.echo('');
return;
}

var results = Object.values(data);
if (results.length > 0) {
results.forEach(function(x) {
if (typeof x !== "object") return;

if ("special_response" in x) {
term.echo("< " + x.special_response.response);
term.echo("< " + x.special_response.source);
term.echo('');
} else {
var base_domain = (function(s) {
return s.split("/")[2];
})(x.base_url);
term.echo("< [[!;;;;" + x.url + ";{}]" + x.title + " from " + base_domain + "]: " + x.description);
}
});
} else {
term.echo("No any results");
}

term.echo('');
});
}
}, {
height: "100%",
Expand Down

0 comments on commit 1c77b64

Please sign in to comment.