From eca698c94d04c090db285efd9aa48c0e598e2b2f Mon Sep 17 00:00:00 2001 From: lolcat Date: Mon, 30 Nov 2026 23:54:44 -0500 Subject: [PATCH] add support for displaying cucked urls --- data/config.php | 2 +- lib/frontend.php | 108 +++++++++++++++++++++++++++++----------------- scraper/brave.php | 10 +++++ static/style.css | 6 +++ 4 files changed, 85 insertions(+), 41 deletions(-) diff --git a/data/config.php b/data/config.php index 80412f6..17688ac 100644 --- a/data/config.php +++ b/data/config.php @@ -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"; diff --git a/lib/frontend.php b/lib/frontend.php index 3c02b03..e30edfd 100644 --- a/lib/frontend.php +++ b/lib/frontend.php @@ -238,7 +238,17 @@ class frontend{ $payload = '
'; // 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 @@ -290,7 +300,7 @@ class frontend{ $payload .= '
'; } - + $payload .= '
'; @@ -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 = '
' . ''; }else{ @@ -529,7 +552,7 @@ class frontend{ $payload = '
' . '' . '
'; @@ -1023,46 +1046,51 @@ class frontend{ /* Draw link */ - $parts = explode("/", $link); - $clickurl = ""; - - // remove trailing / - $c = count($parts) - 1; - if($parts[$c] == ""){ + if($cucked === null){ + $parts = explode("/", $link); + $clickurl = ""; - $parts[$c - 1] = $parts[$c - 1] . "/"; - unset($parts[$c]); - } - - // merge https://site together - if(isset($host["host"])){ - $parts = [ - $parts[0] . $parts[1] . '//' . $parts[2], - ...array_slice($parts, 3, count($parts) - 1) - ]; - } - - $c = count($parts); - for($i=0; $i<$c; $i++){ - - if($i !== 0){ $clickurl .= "/"; } - - $clickurl .= $parts[$i]; - - if($i === $c - 1){ + // remove trailing / + $c = count($parts) - 1; + if($parts[$c] == ""){ - $parts[$i] = rtrim($parts[$i], "/"); + $parts[$c - 1] = $parts[$c - 1] . "/"; + unset($parts[$c]); } - $payload .= - '' . - htmlspecialchars(urldecode($parts[$i])) . - ''; - - if($i !== $c - 1){ - - $payload .= ''; + // merge https://site together + if(isset($host["host"])){ + $parts = [ + $parts[0] . $parts[1] . '//' . $parts[2], + ...array_slice($parts, 3, count($parts) - 1) + ]; } + + $c = count($parts); + for($i=0; $i<$c; $i++){ + + if($i !== 0){ $clickurl .= "/"; } + + $clickurl .= $parts[$i]; + + if($i === $c - 1){ + + $parts[$i] = rtrim($parts[$i], "/"); + } + + $payload .= + '' . + htmlspecialchars(urldecode($parts[$i])) . + ''; + + if($i !== $c - 1){ + + $payload .= ''; + } + } + }else{ + + $payload .= '' . htmlspecialchars($cucked) . ''; } return $payload . '
'; diff --git a/scraper/brave.php b/scraper/brave.php index dfea5bf..82f5a00 100644 --- a/scraper/brave.php +++ b/scraper/brave.php @@ -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, diff --git a/static/style.css b/static/style.css index 6fdfe4d..ee86c6b 100644 --- a/static/style.css +++ b/static/style.css @@ -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;