fetch( url, {
method: 'POST',
headers: new Headers({
'Content-Type': 'application/x-www-form-urlencoded',
'Cache-Control': 'no-cache'
}),
credentials: 'same-origin',
body: new URLSearchParams({
action: 'ty_questgo',
}),
}).then(response => response.json())
.then(response => console.log(response))
.catch(err => console.log(err));
function clear_string($test_string) {
$test_rules_match = preg_match('/(?P<selector>[^\{\s*]+)\{(?P<rules>[^\}]+)\s*\}/ui', $test_string, $test_string_parts);
$test_selector = $test_string_parts['selector'];
$test_rules = $test_string_parts['rules'];
$new_test_string_array = []; $clean_string = $test_string;
if(preg_match_all('/(?P<prop>[a-z]+):(.*?)(?P<important>!important)*;/i',$test_rules,$matches,PREG_PATTERN_ORDER)) {
foreach ($matches['prop'] as $id=>$selector) {
if(!isset($new_test_string_array[$selector]) || !preg_match('~important~ui',$new_test_string_array[$selector]) || $matches['important'][$id]>'')
$new_test_string_array[$selector] = $matches[0][$id];
}
$clean_string = $test_selector.' {'.implode('',$new_test_string_array).'}';
}
return($clean_string);
}