brave pagination fix from upstream
All checks were successful
Build and publish the docker image / build (push) Successful in 21s

Signed-off-by: ngn <ngn@ngn.tf>
This commit is contained in:
ngn 2025-02-04 23:27:01 +03:00
parent 8e125c2eb5
commit e9bbc0f307
Signed by: ngn
GPG Key ID: A3654DF5AD9F641D

View File

@ -400,13 +400,13 @@ class brave{
if($nextpage){ if($nextpage){
$this->fuckhtml->load($nextpage); $this->fuckhtml->load($nextpage);
$nextpage = $nextpage =
$this->fuckhtml $this->fuckhtml
->getElementsByClassName("btn", "a"); ->getElementsByClassName("button", "a");
if(count($nextpage) !== 0){ if(count($nextpage) !== 0){
$nextpage = $nextpage =
$nextpage[count($nextpage) - 1]; $nextpage[count($nextpage) - 1];
@ -1774,48 +1774,63 @@ class brave{
} }
private function generatenextpagetoken($q, $nsfw, $country, $spellcheck, $page, $proxy){ private function generatenextpagetoken($q, $nsfw, $country, $spellcheck, $page, $proxy){
$nextpage = $nextpage =
$this->fuckhtml $this->fuckhtml
->getElementsByClassName("btn", "a"); ->getElementById(
"pagination",
if(count($nextpage) !== 0){ "div"
);
if($nextpage){
$this->fuckhtml->load($nextpage);
$nextpage = $nextpage =
$nextpage[count($nextpage) - 1]; $this->fuckhtml
->getElementsByClassName(
if( "button",
strtolower( "a"
$this->fuckhtml
->getTextContent(
$nextpage
)
) == "next"
){
preg_match(
'/offset=([0-9]+)/',
$this->fuckhtml->getTextContent($nextpage["attributes"]["href"]),
$nextpage
); );
return if(count($nextpage) !== 0){
$this->backend->store(
json_encode( $nextpage =
[ $nextpage[count($nextpage) - 1];
"q" => $q,
"offset" => (int)$nextpage[1], if(
"nsfw" => $nsfw, strtolower(
"country" => $country, $this->fuckhtml
"spellcheck" => $spellcheck ->getTextContent(
] $nextpage
), )
$page, ) == "next"
$proxy ){
preg_match(
'/offset=([0-9]+)/',
$this->fuckhtml->getTextContent($nextpage["attributes"]["href"]),
$nextpage
); );
return
$this->backend->store(
json_encode(
[
"q" => $q,
"offset" => (int)$nextpage[1],
"nsfw" => $nsfw,
"country" => $country,
"spellcheck" => $spellcheck
]
),
$page,
$proxy
);
}
} }
} }
return null; return null;
} }