2024-01-18 06:12:01 +05:00
|
|
|
import re
|
|
|
|
|
|
|
|
def extract_regex_from_js(js_code):
|
2024-03-13 18:04:52 +05:00
|
|
|
pattern1 = r'(?<!//)(?<!/\*)BypassedByBloggerPemula\((.*?),'
|
2024-01-18 06:12:01 +05:00
|
|
|
matches1 = re.findall(pattern1, js_code)
|
|
|
|
matches1 = [match.strip('/') for match in matches1]
|
2024-01-29 22:32:19 +05:00
|
|
|
|
2024-01-28 00:24:39 +05:00
|
|
|
pattern2 = r"(?<!//)BloggerPemula\('([^']+)',"
|
2024-01-18 06:12:01 +05:00
|
|
|
matches2 = re.findall(pattern2, js_code)
|
|
|
|
|
2024-01-28 00:24:39 +05:00
|
|
|
pattern3 = r"(?<!//)RemoveBp\('([^']+)',"
|
2024-01-18 06:12:01 +05:00
|
|
|
matches3 = re.findall(pattern3, js_code)
|
|
|
|
|
2024-01-28 00:24:39 +05:00
|
|
|
pattern4 = r'(?<!//)case \'(.*?)\':'
|
2024-01-18 06:12:01 +05:00
|
|
|
matches4 = re.findall(pattern4, js_code)
|
|
|
|
|
|
|
|
pattern5 = r"h\.href\.includes\('(.*?)'\)"
|
|
|
|
matches5 = re.findall(pattern5, js_code)
|
|
|
|
|
|
|
|
return matches1+matches2+matches3+matches4+matches5
|
|
|
|
|
2024-01-29 22:32:19 +05:00
|
|
|
def write_list_of_strings_to_file(filename, lines):
|
2024-01-25 21:27:17 +05:00
|
|
|
with open(filename, 'w', encoding='utf-8') as file:
|
2024-01-18 06:12:01 +05:00
|
|
|
for line in lines:
|
|
|
|
file.write(line + '\n')
|
|
|
|
print(f"OK: Generated {filename}")
|
|
|
|
|
2024-01-29 22:32:19 +05:00
|
|
|
def generate_include_lines(regex_list):
|
|
|
|
include_rules = []
|
|
|
|
match_rules = []
|
|
|
|
include_and_match_lines = []
|
2024-01-18 06:12:01 +05:00
|
|
|
|
2024-01-29 22:32:19 +05:00
|
|
|
for regex in regex_list:
|
|
|
|
|
|
|
|
#Use @include for more complex regex
|
|
|
|
if any(char in regex for char in ['|', '(', ')', '*']):
|
|
|
|
regex = '(' + regex + ')'
|
|
|
|
include_rule = "/^(https?:\/\/)(.+)?" + regex + "(\/.*)/"
|
|
|
|
include_rule = include_rule.replace( "\.*)(\/.*)/", "\.*)/" ) #clean excess in the regex
|
|
|
|
include_rules.append(include_rule)
|
|
|
|
include_line = "// @include " + include_rule
|
|
|
|
include_and_match_lines.append(include_line)
|
|
|
|
|
|
|
|
#Use @match for simpler regex
|
|
|
|
else:
|
|
|
|
match_rule = '*://*.' + regex + '/*'
|
|
|
|
match_rules.append(match_rule)
|
|
|
|
match_line = '// @match ' + match_rule
|
|
|
|
include_and_match_lines.append(match_line)
|
|
|
|
|
|
|
|
#Output results to txt files
|
|
|
|
write_list_of_strings_to_file('supported_sites.txt', regex_list)
|
|
|
|
write_list_of_strings_to_file('match_rules.txt', match_rules)
|
|
|
|
write_list_of_strings_to_file('include_rules.txt', include_rules)
|
|
|
|
write_list_of_strings_to_file('includes.txt', include_and_match_lines)
|
2024-01-18 06:12:01 +05:00
|
|
|
|
2024-01-19 18:32:10 +05:00
|
|
|
|
2024-01-18 06:12:01 +05:00
|
|
|
def main():
|
2024-02-14 21:23:04 +05:00
|
|
|
file_path = 'untouched_Bypass_All_Shortlinks.user.js'
|
2024-01-29 22:32:19 +05:00
|
|
|
|
2024-01-18 06:12:01 +05:00
|
|
|
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)
|
2024-01-21 00:45:53 +05:00
|
|
|
|
2024-01-21 15:02:58 +05:00
|
|
|
# remove short domains (errors)
|
2024-01-25 13:21:58 +05:00
|
|
|
regex_strings = [s for s in regex_strings if "." in s and len(s) >= 5]
|
2024-01-29 22:32:19 +05:00
|
|
|
|
2024-01-30 16:11:55 +05:00
|
|
|
# remove domains with blocked words (to avoid people worrying)
|
2024-01-25 13:21:58 +05:00
|
|
|
blocked_words_for_includes = [
|
2024-01-30 16:11:55 +05:00
|
|
|
"google", #drive/docs autoDL, bypass redirects, captchas
|
|
|
|
"youtube", #redirecting shorts
|
|
|
|
"twitter.com", #bypass redirects
|
2024-02-12 06:13:21 +05:00
|
|
|
"facebook.com", #bypass redirects
|
2024-01-30 16:11:55 +05:00
|
|
|
"tiktok.com", #bypass redirects
|
2024-02-25 23:37:42 +05:00
|
|
|
"vk.com" #bypass redirects
|
2024-01-25 13:21:58 +05:00
|
|
|
]
|
|
|
|
regex_strings = [s for s in regex_strings if not any(word in s for word in blocked_words_for_includes)]
|
2024-01-21 00:45:53 +05:00
|
|
|
|
2024-01-29 22:32:19 +05:00
|
|
|
generate_include_lines(regex_strings)
|
2024-01-18 06:12:01 +05:00
|
|
|
except FileNotFoundError:
|
|
|
|
print(f"Error: File '{file_path}' not found.")
|
|
|
|
except Exception as e:
|
|
|
|
print(f"An error occurred: {e}")
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|