Compare commits

...

2 commits

3 changed files with 6 additions and 5 deletions

View file

@ -144,16 +144,17 @@ abstract class PatchBase {
return false; return false;
} }
private function regex(string $pattern) { private function regex(string $pattern) {
if (!preg_match($pattern, $this->data, $m)) if (!preg_match_all($pattern, $this->data, $m, PREG_PATTERN_ORDER))
return false; return false;
// suppress full pattern match // suppress full pattern match
unset($m[0]); $m = $m[1];
// TODO - add option: $m = array_reverse($m);
return $m; return $m;
} }
private function regex_str(string $pattern) { private function regex_str(string $pattern) {
$m = $this->regex($pattern); $m = $this->regex($pattern);
if ($m) if ($m)
return $m[1]; return $m[0];
return false; return false;
} }
} }

View file

@ -7,7 +7,7 @@ class CookieAutoDeleteChrome extends PatchBase {
} }
function check() : bool { function check() : bool {
if ($this->fetch('https://chrome.google.com/webstore/detail/cookie-autodelete/fhcgjolkccmbidfldomjliifgaodjagh')) if ($this->fetch('https://chrome.google.com/webstore/detail/cookie-autodelete/fhcgjolkccmbidfldomjliifgaodjagh'))
return $this->parse('/\\\"version\\\": \\\"([\d\.]+)\\\"/'); return $this->parse('/<div class="N3EXSc">([\d\.]+)<\/div>/');
return false; return false;
} }
} }

View file

@ -7,7 +7,7 @@ class LocalCDNChrome extends PatchBase {
} }
function check() : bool { function check() : bool {
if ($this->fetch('https://chrome.google.com/webstore/detail/localcdn/njdfdhgcmkocbgbhcioffdbicglldapd')) if ($this->fetch('https://chrome.google.com/webstore/detail/localcdn/njdfdhgcmkocbgbhcioffdbicglldapd'))
return $this->parse('/\\\"version\\\": \\\"([\d\.]+)\\\"/'); return $this->parse('/<div class="N3EXSc">([\d\.]+)<\/div>/');
return false; return false;
} }
} }