2024-01-18 06:12:01 +05:00
|
|
|
import re
|
|
|
|
|
|
|
|
def extract_regex_from_js(js_code):
|
|
|
|
pattern1 = r'BypassedByBloggerPemula\((.*?),'
|
|
|
|
matches1 = re.findall(pattern1, js_code)
|
|
|
|
matches1 = [match.strip('/') for match in matches1]
|
|
|
|
|
|
|
|
pattern2 = r"BloggerPemula\('([^']+)',"
|
|
|
|
matches2 = re.findall(pattern2, js_code)
|
|
|
|
#matches2 = ['/' + s + '/' for s in matches2]
|
|
|
|
|
|
|
|
pattern3 = r"RemoveBp\('([^']+)',"
|
|
|
|
matches3 = re.findall(pattern3, js_code)
|
|
|
|
|
|
|
|
pattern4 = r'case \'(.*?)\':'
|
|
|
|
matches4 = re.findall(pattern4, js_code)
|
|
|
|
|
|
|
|
pattern5 = r"h\.href\.includes\('(.*?)'\)"
|
|
|
|
matches5 = re.findall(pattern5, js_code)
|
|
|
|
|
|
|
|
return matches1+matches2+matches3+matches4+matches5
|
|
|
|
|
|
|
|
def regex_to_include_line(regex):
|
|
|
|
#regex = regex.strip("/")
|
2024-01-19 22:13:39 +05:00
|
|
|
|
|
|
|
#Use @include for more complex regex
|
2024-01-20 04:56:46 +05:00
|
|
|
if any(char in regex for char in ['|', '(', ')', '*']):
|
2024-01-19 22:13:39 +05:00
|
|
|
regex = '(' + regex + ')'
|
|
|
|
include_line = "// @include /^(https?:\/\/)(.+)?" + regex + "(\/.*)/"
|
|
|
|
include_line = include_line.replace( "\.*)(\/.*)/", "\.*)/" ) #clean excess in the regex
|
|
|
|
|
|
|
|
#Use @match for simpler regex
|
|
|
|
else:
|
|
|
|
include_line = '// @match *://*.' + regex + '/*'
|
2024-01-18 06:12:01 +05:00
|
|
|
|
|
|
|
return include_line
|
|
|
|
|
|
|
|
def generate_include_lines(regex_list):
|
|
|
|
include_lines = []
|
|
|
|
for regex in regex_list:
|
|
|
|
include_line = regex_to_include_line(regex)
|
|
|
|
include_lines.append(include_line)
|
|
|
|
|
2024-01-21 04:46:55 +05:00
|
|
|
# Manual additions of lines
|
|
|
|
|
|
|
|
## -Adding this so that captchas can be auto-opened by this userscript
|
2024-01-21 00:45:53 +05:00
|
|
|
include_lines.append('// @match *://*/recaptcha/api2/*')
|
|
|
|
|
2024-01-21 04:46:55 +05:00
|
|
|
## -Adding this as a go-to URL for accessing the settings menu in this userscript
|
2024-01-21 04:49:40 +05:00
|
|
|
###include_lines.append('// @match https://codeberg.org/Amm0ni4/bypass-all-shortlinks-debloated*')
|
2024-01-21 04:46:55 +05:00
|
|
|
|
2024-01-18 06:12:01 +05:00
|
|
|
return include_lines
|
|
|
|
|
|
|
|
def write_to_file(filename, lines):
|
|
|
|
with open(filename, 'w') as file:
|
|
|
|
for line in lines:
|
|
|
|
file.write(line + '\n')
|
|
|
|
print(f"OK: Generated {filename}")
|
|
|
|
|
|
|
|
def compile_and_print(regex_strings):
|
|
|
|
#for regex_string in regex_strings: print(regex_string)
|
2024-01-19 18:32:10 +05:00
|
|
|
write_to_file('supported_sites.txt', regex_strings)
|
2024-01-18 06:12:01 +05:00
|
|
|
|
|
|
|
include_lines = generate_include_lines(regex_strings)
|
|
|
|
print(f"OK: Generated {len(include_lines)} include lines.")
|
|
|
|
|
|
|
|
#for line in include_lines: print(line)
|
|
|
|
write_to_file('includes.txt', include_lines)
|
|
|
|
|
2024-01-19 18:32:10 +05:00
|
|
|
def remove_strings_containing_word(word, string_list):
|
|
|
|
return [s for s in string_list if word not in s]
|
|
|
|
|
2024-01-18 06:12:01 +05:00
|
|
|
def filter_strings(input_list):
|
|
|
|
filtered_list = [string for string in input_list if "." in string and len(string) >= 4]
|
2024-01-19 18:32:10 +05:00
|
|
|
filtered_list = remove_strings_containing_word("google", filtered_list)
|
2024-01-18 06:12:01 +05:00
|
|
|
return filtered_list
|
|
|
|
|
2024-01-19 18:32:10 +05:00
|
|
|
|
2024-01-18 06:12:01 +05:00
|
|
|
def main():
|
|
|
|
file_path = 'untouched_Bypass_All_Shortlinks.user.js'
|
|
|
|
|
|
|
|
try:
|
|
|
|
with open(file_path, 'r', encoding='utf-8') as file:
|
|
|
|
js_code = file.read()
|
2024-01-21 00:45:53 +05:00
|
|
|
|
2024-01-18 06:12:01 +05:00
|
|
|
regex_strings = extract_regex_from_js(js_code)
|
|
|
|
regex_strings = filter_strings(regex_strings)
|
2024-01-21 00:45:53 +05:00
|
|
|
|
|
|
|
#Manual additions
|
|
|
|
regex_strings.append('shrinkme.us')
|
|
|
|
|
2024-01-18 06:12:01 +05:00
|
|
|
compile_and_print(regex_strings)
|
|
|
|
except FileNotFoundError:
|
|
|
|
print(f"Error: File '{file_path}' not found.")
|
|
|
|
except Exception as e:
|
|
|
|
print(f"An error occurred: {e}")
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|