add support for displaying cucked urls

This commit is contained in:
lolcat committed 2026-11-30 23:54:44 -05:00
1 parent b120d441d5
commit eca698c94d
4 files changed
+49 -5

No files matched your search

+1 -1
View File
@@ -5,7 +5,7 @@ class config{
// any parameters.
// 4get version. Please keep this updated
const VERSION = 9;
const VERSION = 10;
// Will be shown pretty much everywhere.
const SERVER_NAME = "4get";
+32 -4
View File
@@ -238,7 +238,17 @@ class frontend{
$payload = '<div class="text-result">';
// add favicon, link and archive links
$payload .= $this->drawlink($site["url"]);
// add cucked URL if /resolver is present
$cucked =
isset($site["cuckurl"]) &&
preg_match(
'/\/resolver/',
$site["url"]
) !== 0 ?
$site["cuckurl"] : null;
$payload .= $this->drawlink($site["url"], $cucked);
/*
Draw title + description + filetype
@@ -487,11 +497,24 @@ class frontend{
return $text;
}
public function drawlink($link){
public function drawlink(string $link, $cucked = null){
/*
Add favicon
*/
$f404_host = "404";
if($cucked !== null){
// attempt to get the host from the cucked URL
$host = parse_url($cucked);
if(isset($host["host"])){
$f404_host = "https://" . $host["host"];
}
}
$host = parse_url($link);
// special case for when we're not drawing a full url
@@ -500,7 +523,7 @@ class frontend{
$payload =
'<div class="url">' .
'<button class="favicon" tabindex="-1">' .
'<img src="/favicon?s=404" alt="xx">' .
'<img src="/favicon?s=' . urlencode($f404_host) . '" alt="xx">' .
'</button>';
}else{
@@ -529,7 +552,7 @@ class frontend{
$payload =
'<div class="url">' .
'<button class="favicon" tabindex="-1">' .
'<img src="/favicon?s=' . htmlspecialchars($host["scheme"] . "://" . $host["host"]) . '" alt="' . htmlspecialchars($esc) . '">' .
'<img src="/favicon?s=' . urlencode($host["scheme"] . "://" . $host["host"]) . '" alt="' . htmlspecialchars($esc) . '">' .
//'<img src="/404.php" alt="' . htmlspecialchars($esc) . '">' .
'</button>' .
'<div class="favicon-dropdown">';
@@ -1023,6 +1046,7 @@ class frontend{
/*
Draw link
*/
if($cucked === null){
$parts = explode("/", $link);
$clickurl = "";
@@ -1064,6 +1088,10 @@ class frontend{
$payload .= '<span class="separator"></span>';
}
}
}else{
$payload .= '<a class="url-cucked" href="' . $link . '" rel="noreferrer nofollow" tabindex="-1" title="This URL was cucked by the upstream search engine. The full URL is only available by following their redirect endpoint. 4get will proxy your click to prevent tracking.">' . htmlspecialchars($cucked) . '</a>';
}
return $payload . '</div>';
}
+10
View File
@@ -473,6 +473,8 @@ class brave{
$this->fuckhtml->load($html);
$datas = $this->get_js();
//print_r($datas);
$has_found_body = false;
foreach($datas as $data){
@@ -865,6 +867,14 @@ class brave{
)
),
"url" => $this->convert_goto_to_resolver($result["url"]),
"cuckurl" =>
$result["meta_url"]["scheme"] . "://" .
$result["meta_url"]["hostname"] .
preg_replace(
'/ *› */',
"/",
$result["meta_url"]["path"]
),
"date" => $date,
"type" => "web",
"thumb" => $thumb,
+6
View File
@@ -423,6 +423,12 @@ h3,h4,h5,h6{
color:var(--928374);
}
.web .url-cucked{
font-size:15px;
color:var(--string);
cursor:help;
}
.web .separator::before{
content:"/";
padding:0 4px;