use match rules instead of include rules whenever possible

This commit is contained in:
Amm0ni4 2024-01-19 17:13:39 +00:00
parent 1ecd379f76
commit 788abf64fd
2 changed files with 544 additions and 537 deletions

View file

@ -22,10 +22,17 @@ def extract_regex_from_js(js_code):
def regex_to_include_line(regex): def regex_to_include_line(regex):
#regex = regex.strip("/") #regex = regex.strip("/")
#Use @include for more complex regex
if '|' in regex:
regex = '(' + regex + ')' regex = '(' + regex + ')'
include_line = "// @include /^(https?:\/\/)(.+)?" + regex + "(\/.*)/" include_line = "// @include /^(https?:\/\/)(.+)?" + regex + "(\/.*)/"
include_line = include_line.replace( "\.*)(\/.*)/", "\.*)/" ) #clean excess in the regex include_line = include_line.replace( "\.*)(\/.*)/", "\.*)/" ) #clean excess in the regex
#Use @match for simpler regex
else:
include_line = '// @match *://*.' + regex + '/*'
return include_line return include_line
def generate_include_lines(regex_list): def generate_include_lines(regex_list):

File diff suppressed because it is too large Load diff