2024-01-18 06:12:01 +05:00
def modify_script ( input_script_path , includes_file_path , output_script_path ) :
# Read the content of the input script
2024-01-25 21:27:17 +05:00
with open ( input_script_path , ' r ' , encoding = ' utf-8 ' ) as input_file :
2024-01-18 06:12:01 +05:00
script_lines = input_file . readlines ( )
# Read the content of the includes file
2024-01-25 21:27:17 +05:00
with open ( includes_file_path , ' r ' , encoding = ' utf-8 ' ) as includes_file :
2024-01-18 06:12:01 +05:00
includes_content = includes_file . read ( )
2024-01-25 21:27:17 +05:00
# Delete lines non english description (because some characters show up with errors in some sites)
script_lines = [ s for s in script_lines if not ( s . startswith ( " // @description: " ) or s . startswith ( " // @name: " ) ) ]
2024-01-22 17:35:21 +05:00
# Delete lines with "@include" or "@match"
script_lines = [ line for line in script_lines if ' @match ' not in line and ' @include ' not in line ]
2024-01-18 06:12:01 +05:00
2024-01-25 21:27:17 +05:00
# Find the last line that starts with "// @description"
2024-01-25 12:56:50 +05:00
last_description_line_index = None
for i in range ( len ( script_lines ) - 1 , - 1 , - 1 ) :
2024-01-25 21:27:17 +05:00
if script_lines [ i ] . startswith ( ' // @description ' ) :
2024-01-25 12:56:50 +05:00
last_description_line_index = i
break
2024-01-22 17:35:21 +05:00
# Insert includes
script_lines . insert ( last_description_line_index + 1 , includes_content )
2024-01-18 06:12:01 +05:00
# 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 } . " )
2024-01-22 17:35:21 +05:00
def does_not_contain_any ( input_string , string_list ) :
for string_to_check in string_list :
if string_to_check in input_string :
return False
return True
2024-01-26 04:38:14 +05:00
def remove_lines_with_strings ( js_code , strings_to_remove ) :
lines = js_code . split ( ' \n ' )
2024-01-30 21:53:34 +05:00
filtered_lines = [ line for line in lines if not any ( s in line for s in strings_to_remove ) ]
2024-01-26 04:38:14 +05:00
filtered_code = ' \n ' . join ( filtered_lines )
return filtered_code
2024-01-18 06:12:01 +05:00
def modify_script_extra ( file_path ) :
try :
2024-01-25 21:27:17 +05:00
with open ( file_path , ' r ' , encoding = ' utf-8 ' ) as file :
2024-01-18 06:12:01 +05:00
content = file . read ( )
#Change title
content = content . replace ( " // @name Bypass All Shortlinks " , " // @name Bypass All Shortlinks Debloated " )
2024-02-22 21:38:36 +05:00
content = content . replace ( " https://i.ibb.co/qgr0H1n/BASS-Blogger-Pemula.png " , " https://cdn-icons-png.flaticon.com/512/14025/14025295.png " )
content = content . replace ( " @author Bloggerpemula " , " @author Amm0ni4 " )
2024-02-24 15:15:19 +05:00
content = content . replace ( " // @description Bypass All Shortlinks Sites Automatically Skips Annoying Link Shorteners , Skip AdFly and No Annoying Ads, Directly to Your Destination, and now Support Auto Downloading Your Files " ,
2024-02-24 08:24:30 +05:00
" // @description Automatically bypass many link shorteners. Originally by BloggerPemula. \n // @homepageURL https://codeberg.org/Amm0ni4/bypass-all-shortlinks-debloated \n // @supportURL https://codeberg.org/Amm0ni4/bypass-all-shortlinks-debloated/issues " )
2024-01-18 06:12:01 +05:00
#Change source URL
content = content . replace ( " https://update.greasyfork.org/scripts/431691/Bypass % 20All % 20Shortlinks.user.js " ,
2024-01-19 18:51:42 +05:00
" https://codeberg.org/Amm0ni4/bypass-all-shortlinks-debloated/raw/branch/main/Bypass_All_Shortlinks.user.js " )
2024-01-18 06:12:01 +05:00
content = content . replace ( " https://update.greasyfork.org/scripts/431691/Bypass % 20All % 20Shortlinks.meta.js " ,
2024-01-25 21:27:17 +05:00
" https://codeberg.org/Amm0ni4/bypass-all-shortlinks-debloated/raw/branch/main/Bypass_All_Shortlinks.meta.js " )
2024-02-24 08:36:00 +05:00
content = content . replace ( " https://openuserjs.org/meta/Bloggerpemula/Bypass_All_Shortlinks_Manual_Captcha.meta.js " ,
" https://codeberg.org/Amm0ni4/bypass-all-shortlinks-debloated/raw/branch/main/Bypass_All_Shortlinks.meta.js " )
2024-02-24 15:15:19 +05:00
# Fixes
content = content . replace ( " case ' work.ink ' : if (/^ \ /([^ \ /]+)/.test(h.pathname)) " , " case ' work.ink ' : if (/^ \ /([^ \ /]+)/.test(h.pathname) && !location.href.includes( ' /token/ ' ) && !location.href.includes( ' ?r= ' ) && !location.href.includes( ' ?ref= ' )) " )
content = content . replace ( " adbypass.org/bypass?bypass= ' + location.href.split( ' ? ' )[0] " , " adbypass.org/bypass?bypass= ' + encodeURIComponent(location.href) " )
2024-01-18 06:12:01 +05:00
2024-04-08 16:12:46 +05:00
content = content . replace ( " ClickIfExists( ' #slu-continue ' ) " , " ClickIfExists( ' #btn-3 ' ) " )
2024-04-17 19:54:59 +05:00
##content = content.replace("ReadytoClick('.btn-primary.btn-warningbtn.btn'", "ReadytoClick('#cbt'")
2024-04-17 19:40:56 +05:00
2024-03-17 02:01:38 +05:00
code_to_replace = """ $( ' form[id=go-link] ' ).unbind().submit(function(e) { e.preventDefault();
var form = $ ( this ) ; var url = form . attr ( ' action ' ) ; const pesan = form . find ( ' button ' ) ; const notforsale = $ ( " .navbar-collapse.collapse " ) ; const blogger = $ ( " .main-header " ) ; const pemula = $ ( " .col-sm-6.hidden-xs " ) ;
$ . ajax ( { type : " POST " , url : url , data : form . serialize ( ) , beforeSend : function ( xhr ) { pesan . attr ( " disabled " , " disabled " ) ; $ ( ' a.get-link ' ) . text ( ' Bypassed by Bloggerpemula ' ) ;
notforsale . replaceWith ( ' <button class= " btn btn-default , col-md-12 text-center " onclick= " javascript: return false; " ><b>Thanks for using Bypass All Shortlinks Scripts and for Donations , Regards : Bloggerpemula</b></button> ' ) ;
blogger . replaceWith ( ' <button class= " btn btn-default , col-md-12 text-center " onclick= " javascript: return false; " ><b>Thanks for using Bypass All Shortlinks Scripts and for Donations , Regards : Bloggerpemula</b></button> ' ) ;
pemula . replaceWith ( ' <button class= " btn btn-default , col-md-12 text-center " onclick= " javascript: return false; " ><b>Thanks for using Bypass All Shortlinks Scripts and for Donations , Regards : Bloggerpemula</b></button> ' ) ; } ,
success : function ( result , status , xhr ) { if ( xhr . responseText . match ( ' (insfly|Insfly|linksly|cosmic-matter).pw|(freecrypto|freeltc|a-s-cracks).top|mdiskshortner.link|(oscut|exashorts).fun|bigbtc.win|gainl.ink|earnify.pro|clockads.in|(promo-visits|rexlink).site ' ) ) { location . href = result . url ; } else { redirect ( result . url ) ; } } } ) ; } ) ; """
content = content . replace ( code_to_replace , " " )
2024-03-09 17:24:05 +05:00
# Remove unused
content = content . replace ( " // @connect nocaptchaai.com \n " , " " )
2024-04-07 16:16:38 +05:00
# Add "@noframes"
if not " @noframes " in content :
content = content . replace ( " \n // @version " , " \n // @noframes \n // @version " )
2024-01-18 06:12:01 +05:00
#Remove tracking
2024-01-22 17:46:07 +05:00
## Remove redirection to tracking site
2024-01-22 17:35:21 +05:00
content = content . replace ( " https://rotator.nurul-huda.sch.id/?BypassResults= " , " " )
content = content . replace ( " https://free4u.nurul-huda.or.id/?BypassResults= " , " " )
content = content . replace ( " blog = true " , " blog = false " )
2024-01-22 17:46:07 +05:00
## Remove tracking iframe being injected
2024-01-30 21:53:34 +05:00
content = remove_lines_with_strings ( content , [ " https://menrealitycalc.com/ " ] )
2024-01-22 17:35:21 +05:00
2024-01-26 04:38:14 +05:00
## Remove weird datalist "adcopy_response" injected
strings_to_remove = [
" elementReady( ' [name=adcopy_response] ' ) " ,
" const PHRASES = [ ' 1.21 gigawatts ' " ,
2024-01-26 04:44:46 +05:00
" ' heart break ' , " ,
" ' rolling stone ' " ,
2024-01-26 04:38:14 +05:00
" const datalist = document.createElement( ' datalist ' ) "
]
content = remove_lines_with_strings ( content , strings_to_remove )
2024-01-26 04:52:49 +05:00
content + = ' \n }})(); \n ' # Add closing bracket
2024-01-26 04:38:14 +05:00
2024-01-22 17:46:07 +05:00
## Check known issues have been removed and remove antifeature label if corrected
2024-01-22 17:35:21 +05:00
strings_to_check = [
" rotator.nurul-huda.sch.id/?BypassResults= " ,
" free4u.nurul-huda.or.id/?BypassResults= " ,
" https://menrealitycalc.com/ " ,
2024-01-26 04:38:14 +05:00
" createElement( ' iframe ' ) " ,
" adcopy_response "
2024-01-22 17:35:21 +05:00
]
if does_not_contain_any ( content , strings_to_check ) :
content = content . replace ( " \n // @antifeature tracking " , " " )
2024-01-22 17:46:07 +05:00
else :
print ( " ERROR: TRACKING NOT REMOVED. " )
2024-01-26 04:38:14 +05:00
#open("Bypass_All_Shortlinks.user.js", "w").close() # Clear file
2024-01-22 17:46:07 +05:00
return False
2024-01-18 06:12:01 +05:00
2024-01-26 04:38:14 +05:00
# Check the code ends with a line jump
if not content . endswith ( ' \n ' ) :
content + = ' \n '
2024-01-18 06:12:01 +05:00
# Write the modified content back to the file
2024-01-25 21:27:17 +05:00
with open ( file_path , ' w ' , encoding = ' utf-8 ' ) as file :
2024-01-18 06:12:01 +05:00
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 } " )
2024-01-25 21:27:17 +05:00
def generate_metadata_file ( input_file , output_file ) :
with open ( input_file , ' r ' , encoding = ' utf-8 ' ) as f :
lines = f . readlines ( )
start_index = None
end_index = None
for i , line in enumerate ( lines ) :
if line . startswith ( " // ==UserScript== " ) :
start_index = i
elif line . startswith ( " // ==/UserScript== " ) :
end_index = i
break
if start_index is not None and end_index is not None :
metadata_lines = lines [ start_index : end_index + 1 ]
with open ( output_file , ' w ' , encoding = ' utf-8 ' ) as f :
f . writelines ( metadata_lines )
print ( " Metadata extracted successfully! " )
else :
print ( " Could not find metadata in the input file. " )
2024-01-19 18:51:42 +05:00
def main ( ) :
2024-02-14 21:23:04 +05:00
input_script_path = ' untouched_Bypass_All_Shortlinks.user.js '
2024-01-19 18:51:42 +05:00
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 )
2024-01-25 21:27:17 +05:00
generate_metadata_file ( " Bypass_All_Shortlinks.user.js " , " Bypass_All_Shortlinks.meta.js " )
2024-01-19 18:51:42 +05:00
if __name__ == " __main__ " :
main ( )