mirror of
https://codeberg.org/Amm0ni4/bypass-all-shortlinks-debloated.git
synced 2024-12-28 07:53:01 +05:00
Upload files to "/"
This commit is contained in:
parent
96b508614a
commit
2a996c062f
5 changed files with 182 additions and 0 deletions
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
|
||||
untouched_Bypass_All_Shortlinks.user.js
|
||||
includes.txt
|
20
1_download_untouched.py
Normal file
20
1_download_untouched.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
import requests
|
||||
|
||||
def download_file(url, destination):
|
||||
try:
|
||||
response = requests.get(url)
|
||||
response.raise_for_status() # Check if the request was successful
|
||||
|
||||
with open(destination, 'wb') as file:
|
||||
file.write(response.content)
|
||||
|
||||
print(f"OK: File downloaded successfully as {destination}")
|
||||
|
||||
except requests.exceptions.RequestException as e:
|
||||
print(f"Error downloading file: {e}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
url = "https://update.greasyfork.org/scripts/431691/Bypass%20All%20Shortlinks.user.js"
|
||||
destination = "untouched_Bypass_All_Shortlinks.user.js"
|
||||
|
||||
download_file(url, destination)
|
74
2_generate_includes.py
Normal file
74
2_generate_includes.py
Normal file
|
@ -0,0 +1,74 @@
|
|||
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("/")
|
||||
regex = '(' + regex + ')'
|
||||
include_line = "// @include /^(https?:\/\/)(.+)?" + regex + "(\/.*)/"
|
||||
include_line = include_line.replace( "\.*)(\/.*)/", "\.*)/" ) #clean excess in the regex
|
||||
|
||||
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)
|
||||
|
||||
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)
|
||||
#write_to_file('regexs.txt', regex_strings)
|
||||
|
||||
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)
|
||||
|
||||
def filter_strings(input_list):
|
||||
filtered_list = [string for string in input_list if "." in string and len(string) >= 4]
|
||||
return filtered_list
|
||||
|
||||
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()
|
||||
regex_strings = extract_regex_from_js(js_code)
|
||||
regex_strings = filter_strings(regex_strings)
|
||||
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()
|
67
3_patch.py
Normal file
67
3_patch.py
Normal file
|
@ -0,0 +1,67 @@
|
|||
def modify_script(input_script_path, includes_file_path, output_script_path):
|
||||
# Read the content of the input script
|
||||
with open(input_script_path, 'r') as input_file:
|
||||
script_lines = input_file.readlines()
|
||||
|
||||
# Find the last line that starts with "// @description:"
|
||||
last_description_line_index = None
|
||||
for i in range(len(script_lines) - 1, -1, -1):
|
||||
if script_lines[i].startswith('// @description:'):
|
||||
last_description_line_index = i
|
||||
break
|
||||
|
||||
# Read the content of the includes file
|
||||
with open(includes_file_path, 'r') as includes_file:
|
||||
includes_content = includes_file.read()
|
||||
|
||||
# Remove lines starting with "// @include"
|
||||
script_lines = [line for line in script_lines if not line.startswith('// @include')]
|
||||
|
||||
# Insert includes content after the last description line
|
||||
script_lines.insert(last_description_line_index + 1, includes_content)
|
||||
|
||||
# Write the modified script to the output file
|
||||
with open(output_script_path, 'w') as output_file:
|
||||
output_file.writelines(script_lines)
|
||||
|
||||
print(f"OK: @Include lines added. Script successfully modified and saved to {output_script_path}.")
|
||||
|
||||
|
||||
def modify_script_extra(file_path):
|
||||
try:
|
||||
with open(file_path, 'r') as file:
|
||||
content = file.read()
|
||||
|
||||
#Change title
|
||||
content = content.replace("// @name Bypass All Shortlinks", "// @name Bypass All Shortlinks Debloated")
|
||||
|
||||
#Change source URL
|
||||
content = content.replace("https://update.greasyfork.org/scripts/431691/Bypass%20All%20Shortlinks.user.js",
|
||||
"https://codeberg.org/Amm0ni4/bypass-all-shortlinks-debloated/raw/branch/main/Bypass_All_Shortlinks.user.js")
|
||||
content = content.replace("https://update.greasyfork.org/scripts/431691/Bypass%20All%20Shortlinks.meta.js",
|
||||
"https://codeberg.org/Amm0ni4/bypass-all-shortlinks-debloated/raw/branch/main/Bypass_All_Shortlinks.user.js")
|
||||
|
||||
#Remove tracking
|
||||
content = content.replace("'https://rotator.nurul-huda.sch.id/?BypassResults=' + url", "'' + url")
|
||||
content = content.replace("let respect = 'https://free4u.nurul-huda.or.id/?BypassResults=';", "let respect = '';")
|
||||
content = content.replace("\n// @antifeature tracking", "")
|
||||
|
||||
|
||||
# Write the modified content back to the file
|
||||
with open(file_path, 'w') as file:
|
||||
file.write(content)
|
||||
|
||||
print("OK: Extra Modifications completed successfully.")
|
||||
|
||||
except FileNotFoundError:
|
||||
print(f"File '{file_path}' not found.")
|
||||
except Exception as e:
|
||||
print(f"An error occurred: {e}")
|
||||
|
||||
|
||||
# Example usage
|
||||
input_script_path = 'untouched_Bypass_All_Shortlinks.user.js'
|
||||
includes_file_path = 'includes.txt'
|
||||
output_script_path = 'Bypass_All_Shortlinks.user.js'
|
||||
modify_script(input_script_path, includes_file_path, output_script_path)
|
||||
modify_script_extra(output_script_path)
|
18
README.md
Normal file
18
README.md
Normal file
|
@ -0,0 +1,18 @@
|
|||
Automatically bypass many shortlink sites to skip annoying link shorteners, such as AdFly and Linkvertise, without ads. Reach your destination link more directly.
|
||||
|
||||
## Install
|
||||
Install by clicking this link with the [raw text for the file Bypass_All_Shortlinks.user.js](https://codeberg.org/Amm0ni4/bypass-all-shortlinks-debloated/raw/branch/main/Bypass_All_Shortlinks.user.js)
|
||||
|
||||
(you need a userscript manager like [Violentmonkey](https://violentmonkey.github.io/) installed in your web browser)
|
||||
|
||||
## Improvements in this fork
|
||||
- The script will be loaded only for the sites that are supported. (the original userscript is loaded in every site you visit which is not necessary)
|
||||
- The script will not redirect to 'rotator.nurul-huda.sch.id' or 'free4u.nurul-huda.or.id' before your destination URL, which are intermediary sites set by the developer for [collecting analytics](https://i.ibb.co/D1zYG1v/topcountry17-04-2023.jpg) and showing ads.
|
||||
|
||||
Original script by *bloggerpemula*: https://greasyfork.org/scripts/431691
|
||||
|
||||
## How I modify the original userscript
|
||||
Executing these 3 python scripts in order:
|
||||
- 1_download_untouched.py
|
||||
- 2_generate_includes.py
|
||||
- 3_patch.py
|
Loading…
Reference in a new issue